Skip to content

Extend gyroscopic stabilization to free rigid subtrees - #3554

Draft
ruziniuuuuu wants to merge 1 commit into
google-deepmind:mainfrom
ruziniuuuuu:codex/free-rigid-subtree-gyro
Draft

Extend gyroscopic stabilization to free rigid subtrees#3554
ruziniuuuuu wants to merge 1 commit into
google-deepmind:mainfrom
ruziniuuuuu:codex/free-rigid-subtree-gyro

Conversation

@ruziniuuuuu

Copy link
Copy Markdown

Fixes #3553.

A free rigid object can diverge under implicitfast simply because its inertia is represented on a fixed child body. In the issue's contact-free reproduction, a massless free root with one inertial child emits BADQACC at step 4294; moving the same inertial element to the root, or using implicit, completes 10,000 steps.

This extends the existing local gyroscopic solve to free rigid subtrees. The six-DOF tree check remains, and the bias derivative sums each body's contribution about the free joint's origin and orientation. mjd_freeMhat reuses that aggregate derivative. Fluid geoms on fixed descendants retain the asymmetric derivatives required by the local solve. The shared helper also extends the existing discrete treatment to eligible rigid subtrees.

The implementation continues using the global Cholesky solve and a local 6-by-6 LU solve; descendant aggregation adds work proportional to the number of bodies in each eligible rigid subtree. No model rewriting, inertia regularization, new settings, or integrator fallback is introduced. Trees with articulated descendants remain excluded.

Validation

Built against upstream 707f4735e248872a38c5040a21b510a5bd386459 using GCC 11.5.0, Linux x86_64, CMake Release, double precision.

  • Before the fix: the minimal C API reproduction fails at step 4294; new energy-stability, derivative, and implicit comparison checks fail.
  • After the fix: all four flat/nested and implicitfast/implicit reproduction combinations complete 10,000 steps without BADQACC.
  • Full engine_forward_test: 129 tests pass.
  • Full engine_derivative_test: 34 tests pass.
  • Coverage includes a massless free root, multiple levels of rotated and offset inertias, another independent free body, fixed-child ellipsoid fluid forces, full RNE and central finite-difference derivative comparisons, discrete energy stability, and rejection of articulated descendants.
  • Changed C++ lines formatted with the repository's clang-format configuration; git diff --check passes.

Build and test commands (run test binaries from the source test/ directory so fixtures resolve):

cmake -S . -B ../build -DMUJOCO_BUILD_EXAMPLES=OFF -DMUJOCO_BUILD_SIMULATE=OFF \
  -DMUJOCO_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build ../build --target engine_forward_test engine_derivative_test -j 6
cd test
../../build/bin/engine_forward_test
../../build/bin/engine_derivative_test

This is a draft for maintainer feedback on extending the documented standalone-body eligibility rule. Validation is limited to the two complete test binaries above and the synthetic reproduction; other platforms, single precision, the full repository suite, and application workloads have not been tested.

@google-cla

google-cla Bot commented Sep 6, 2026

Copy link
Copy Markdown

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.

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.

Extend implicitfast gyroscopic stabilization to free bodies with fixed descendants

1 participant