Repository navigation
Make bodies below a mocap body follow the mocap pose in MJX - #3759
Open
JOhnsonKC201 wants to merge 1 commit into
Open
JOhnsonKC201 wants to merge 1 commit into
JOhnsonKC201 wants to merge 1 commit into
Conversation
mjx.kinematics ran the body tree scan from body_pos and body_quat, and only afterwards wrote mocap_pos and mocap_quat into the mocap bodies. Their descendants were therefore placed from the model's default mocap pose, so their positions, orientations, joint anchors and axes, geoms and sites ignored the mocap pose. MuJoCo C (mj_kinematics) uses the mocap pose as the body pose before computing the children. Mocap bodies are static children of the world, so the mocap pose is their pose relative to the parent. Substitute it into the scan inputs, which also makes the overwrite after the scan unnecessary.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mjx.kinematicsignores the mocap pose for every body attached below a mocap body. The mocap body itself is placed correctly, but its descendants are placed as if the mocap body were still at its default pose, so theirxpos,xquat,xmat,xanchor,xaxis, geom and site frames are all wrong, and so is everything computed from them afterwards (com, cdof, collisions, sensors).The cause is the order in
kinematics: the body tree scan runs fromm.body_posandm.body_quat, andmocap_pos/mocap_quatare written into the mocap bodies only after the scan, when the children have already been computed. MuJoCo C uses the mocap pose as the body pose inmj_kinematics1before it reaches the children.Repro
Fix
Mocap bodies are static children of the world, so the mocap pose is their pose relative to the parent. This change substitutes
mocap_posand the normalizedmocap_quatinto thebody_pos/body_quatinputs of the scan, so the children are computed from it. The write after the scan is no longer needed, since the scan now produces the mocap bodies' own frames directly.Tests
test_mocap_childreninsmooth_test.pybuilds a model with two mocap bodies, one of them with a hinged child and a ball-jointed grandchild, sets random mocap poses (with unnormalized quaternions) and comparesxanchor,xaxis,xpos,xquat,xmat, geom and site frames againstmj_kinematics. On main it fails atxanchorwith a max absolute difference of 0.94; with the fix it passes.test_smoothalready randomizes the mocap pose, butpendula.xmlhas no bodies below its mocap body, which is why this was not caught.smooth_test.py,forward_test.pyandsensor_test.pypass locally (59 tests, JAX 0.11.1 on CPU, Linux, with the current nightlymujocowheel).