Skip to content

[BUG FIX] Preserve URDF mimic joint relations when scaling robots. - #3271

Open
ktyang512 wants to merge 4 commits into
Genesis-Embodied-AI:mainfrom
ktyang512:scale_urdf_mimic_coefficients
Open

[BUG FIX] Preserve URDF mimic joint relations when scaling robots.#3271
ktyang512 wants to merge 4 commits into
Genesis-Embodied-AI:mainfrom
ktyang512:scale_urdf_mimic_coefficients

Conversation

@ktyang512

Copy link
Copy Markdown

Description

Preserve the dimensionally correct URDF mimic relation when loading scaled robots. The follower offset now scales with its coordinate type, while the multiplier scales by the ratio between the follower and driver coordinate scales.

Related Issue

Resolves #3270

Motivation and Context

Uniformly scaling a URDF currently changes common revolute-to-revolute and prismatic-to-prismatic mimic relations, causing the constraint solver to drive scaled mechanisms to unintended joint positions.

How Has This Been / Can This Be Tested?

  • Added scale-2 revolute/revolute, prismatic/prismatic, revolute/prismatic, and prismatic/revolute coverage to the existing URDF mimic capability test.
  • Initialized every scaled follower away from its authored non-zero mimic offset and verified that stepping actively restores all four relations.
  • Verified the regression test fails on the base commit with parsed coefficients [[0.5, 4.0], [0.5, 4.0]] for the two same-type cases.
  • Passed the updated test on CPU and NVIDIA RTX 5090 GPU with n_envs=0 and n_envs=2.
  • Passed the adjacent JOINT, CONNECT, and WELD equality tests, the CPU Go2 scale/armature test, and both URDF mesh-scale cases.
  • Passed pre-commit for all three changed files.

CPU targeted and adjacent validation:

uv run pytest -q tests/rigid/test_constraints.py::test_urdf_mimic tests/rigid/test_constraints.py::test_equality_joint 'tests/rigid/test_asset_loading.py::test_robot_scale_and_dofs_armature[urdf/go2/urdf/go2.urdf-cpu]' --backend=cpu

GPU targeted validation:

uv run pytest -q tests/rigid/test_constraints.py::test_urdf_mimic --backend=gpu

Additional equality and URDF scale regression validation:

uv run pytest -q tests/rigid/test_constraints.py::test_equality_link --backend=cpu
uv run pytest -q tests/parsers/test_mesh.py::test_urdf_scale --backend=cpu

Checklist

  • I read the CONTRIBUTING document.
  • I followed the Submitting Code Changes section of the CONTRIBUTING document.
  • I tagged the title correctly.
  • No documentation change is needed.
  • I tested my changes and added instructions for reviewers.
  • I added tests to cover my changes.
  • All existing tests passed; targeted and adjacent tests passed, but the full suite was not run locally.

Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread genesis/utils/urdf.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/conftest.py Outdated
@ktyang512

Copy link
Copy Markdown
Author

Thanks for the review. I removed the batch parameterization, the redundant zero_velocity argument and initial qpos check, changed the horizon to 80 steps, and compacted the inertia construction.

Regarding the deleted scaling line, data[0] is the mimic offset and data[1] is the multiplier. For q_f = m * q_d + b, scaling requires b' = s_f * b and m' = (s_f / s_d) * m, since prismatic coordinates scale with the geometry while revolute coordinates do not. Therefore, data[:6] *= morph.scale incorrectly scales both values in the same way except for the prismatic-follower/revolute-driver case; the explicit assignments above replace it. The remaining coefficients stay zero for a linear URDF mimic.

The targeted test passes locally on CPU and GPU, and the adjacent CPU tests and Ruff checks also pass.

Comment thread genesis/utils/urdf.py
Comment thread genesis/utils/urdf.py Outdated
Comment thread genesis/utils/urdf.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
Comment thread tests/rigid/conftest.py Outdated
Comment thread tests/rigid/test_constraints.py Outdated
@ktyang512
ktyang512 force-pushed the scale_urdf_mimic_coefficients branch from 3364d03 to e2608e2 Compare August 31, 2026 13:29
@ktyang512

Copy link
Copy Markdown
Author

Thanks for the follow-up. I rebased onto the latest main and added the same coordinate-aware scaling to MJCF joint equalities (a_k' = s_f / s_d^k * a_k), with a nonlinear regression covering all revolute/prismatic driver-follower pairings. I also applied the requested cleanup around naming, joint indices, lookup placement, and the no-op setup.

The targeted tests pass on CPU and GPU, along with the adjacent rigid constraint and URDF scale tests and Ruff checks.

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.

[Bug]: Scaling a URDF changes mimic joint coefficients and enforces the wrong joint relation

3 participants