Skip to content

Fix runtime site pose updates after default initialization#3251

Open
cvan20191 wants to merge 1 commit intogoogle-deepmind:mainfrom
cvan20191:fix-runtime-site-pose
Open

Fix runtime site pose updates after default initialization#3251
cvan20191 wants to merge 1 commit intogoogle-deepmind:mainfrom
cvan20191:fix-runtime-site-pose

Conversation

@cvan20191
Copy link
Copy Markdown

Fixes #3029.

Summary

This fixes runtime updates to site poses when a site was initialized with a default position and/or identity quaternion.

Problem

Sites initialized with default pose values can be compiled with site_sameframe shortcuts such as mjSAMEFRAME_BODY or mjSAMEFRAME_BODYROT.

After users mutate model->site_pos or model->site_quat at runtime and call mj_forward, those compiled shortcuts can remain active. As a result, mj_local2Global may skip the current local site position or quaternion, causing data->site_xpos / data->site_xmat not to reflect the mutated model fields.

This made behavior depend on the site's initial XML pose: non-default-initialized sites updated as expected, while default-initialized sites could appear static.

Fix

mj_kinematics2 now revalidates site same-frame shortcuts against the current site pose before calling mj_local2Global.

The change is limited to site transform computation and preserves valid shortcuts where possible, including downgrading shortcuts when only part of the shortcut remains valid.

Tests

Added C++ regression coverage:

  • CoreSmoothTest.SitePositionMutationUpdatesDefaultSiteXpos
  • CoreSmoothTest.SiteQuatMutationUpdatesDefaultSiteXmat

These tests failed before the fix and pass after it.

Locally run:

git diff --check
# narrow gtest filter for the two new tests
# full engine_core_smooth_test
ctest --test-dir build-gcc15 -R '^CoreSmoothTest\.' --output-on-failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent behaviour of Site (quat, pos) dependent on initialization

1 participant