Split qpos/qvel into translation/attitude StateData for better integrator tolerances#1392
Draft
ReeceHumphreys wants to merge 1 commit into
Draft
Split qpos/qvel into translation/attitude StateData for better integrator tolerances#1392ReeceHumphreys wants to merge 1 commit into
ReeceHumphreys wants to merge 1 commit into
Conversation
d9e41d8 to
2172383
Compare
Contributor
|
This is definitely a move in the right direction. Packaging the entire multibody state into a single
This actually completely removes the need for |
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.
Description
The adaptive integrator's step-size controller computes an error norm per StateData object. With a single unified mujocoQpos/mujocoQvel state, orbital translational velocity (~7600 m/s) dominated the norm which would make the adaptive tolerance far too loose to properly control integration error in the for things like attitude and hinge DOFs as found by my testing in #1287.
As a temporary workaround I was forcing relTol = 0 on mujocoQvel, which effectively disabled relative tolerance entirely. However a better solution is to split this tolerancing out:
mujocoQposTranslation / mujocoQposAttitude
mujocoQvelTranslation / mujocoQvelAttitude
Now each gets its own error norm, so orbital and attitude DOFs are controlled independently at their natural scales. A new MJQPosAttitudeStateData class handles the quaternion-aware propagation (mju_quatIntegrate) needed for the attitude qpos block. Index maps are also built at compile and recompile time to pack and unpack between the split states and MuJoCo's flat qpos/qvel arrays.
Context
RKF45 integrator computes its step-size tolerance as
|state| * relTol + absTol. With the velocities on the order of orbital speeds in the mujocoQvel state, the tolerance became7616[m/s] * 1e-4. This allowed substeps large enough to numerically destabilise the stiff panel joint ODE used in the solar panel deploy scenario I made. Thats how the issue was identified and why this needs a fix.Verification
Ran a MuJoCo vizard scenario I have been developing to validate everything works.
Documentation
N/A
Future work
Sliding joints would get looped into the new attitude bucket alongside hinge joints. A slide joint is in metres, not radians, so its scale is different from both orbital translation and angular DOFs. In practice this is probably fine because a regular boom like a 2-meter boom extension is small compared to orbital distances, so it won't dominate the attitude norm. In the future we should probably handle this separately though.