Repository navigation
Feat/sim backend kinematics api - #42
Merged
Merged
Conversation
Add base and body kinematics interfaces to SimBackend and implement
them in both MuJoCo and MotrixSim backends.
New abstract methods on SimBackend:
- get_base_pos / get_base_quat (wxyz) / get_base_lin_vel / get_base_ang_vel
- get_body_{pos,quat,lin_vel,ang_vel}_w — world frame, (N, B, 3/4)
- get_body_{pos,quat,lin_vel,ang_vel}_b — baselink frame, (N, B, 3/4)
MuJoCo backend:
- Zero-copy views for all base kinematics from physics_state
- Body kinematics via existing sensor-data views
MotrixSim backend:
- Base kinematics via floatingbase API (get_translation / get_rotation /
get_global_*_velocity); xyzw→wxyz conversion applied
- Body _w via per-body get_position / get_rotation / get_*_velocity API
- Body _b via injected framepos/framequat/framelinvel/frameangvel sensors
(add_body_sensors=True); reuses inject_motrix_tracking_sensors
xml_utils: split inject_tracking_sensors_to_xml into
- inject_mujoco_tracking_sensors (_w + _b)
- inject_motrix_tracking_sensors (_b only)
with shared private helpers _get_named_bodies / _add_w_sensors /
_add_b_sensors / _write_temp_xml.
- MuJoCo: add try/finally for temp XML cleanup; run forward pass at init to populate sensor data from qpos0; skip world body (index 0) in _get_named_bodies to avoid motrixsim "invalid link name: world" error - MotrixSim: fix get_body_*_w to use link indices via get_link_index; fix get_body_quat_b to convert xyzw→wxyz (framequat sensor is xyzw); add forward_kinematic call at init; add try/finally for temp XML cleanup - xml_utils: skip body[0] (world) when enumerating tracked bodies - tests: add TestCrossBackend and TestCrossBackendBodySensors comparing all kinematics methods across MuJoCo and MotrixSim backends (161/163 pass; 2 failures in test_dof_pos_after_step are expected integrator divergence)
- math_utils: add np_quat_conjugate and np_quat_to_axis_angle (NumPy batch implementations previously duplicated in both rotation files) - rotation.py / rotation_sac.py: remove local _quat_conjugate/_quat_mul/ _quat_to_axis_angle; import np_quat_* from unilab.utils.math_utils - Fix mypy errors across backends (no-any-return, no-redef, arg-type): xml_utils: annotate ElementTree[Element]; mujoco_backend: wrap slices with np.asarray and type: ignore[no-any-return]; motrix_backend: drop duplicate type annotation on _body_id_to_name; motrix_numba_backend: implement all abstract methods (get_base_*, get_body_*_w, get_body_*_b)
get_qpos() exposed internal state layout and was only ever used to read base Z height (qpos[:, 2]), which get_base_pos()[:, 2] provides directly. The motion_tracking usage was a dead parameter. - base.py: remove get_qpos abstract method - mujoco_backend, motrix_backend, motrix_numba_backend: remove get_qpos - g1/joystick.py: drop qpos from update_state, _compute_reward and all _reward_* signatures; _reward_base_height calls get_base_pos()[:, 2] - go1/joystick.py: same refactor - go2/joystick.py: inline get_base_pos()[:, 2] in _reward_base_height - g1/motion_tracking/tracking.py: remove dead qpos parameter from _compute_terminations (was passed but never read) - test_sim_backend.py: remove get_qpos tests; fix motrix test_set_state_moves_base to derive nq from get_dof_pos()
The parameter body_name was misleading — it refers specifically to the floating base link, not an arbitrary body. Renamed everywhere: - mujoco_backend, motrix_backend, motrix_numba_backend: constructor parameter body_name → base_name - g1/base.py, go1/base.py, go2/base.py: Asset.body_name → base_name - g1/joystick.py, g1/joystick_sac.py, go1/joystick.py, go2/joystick.py, g1/motion_tracking/tracking.py: call sites updated to base_name= - motrix_backend._process_rigid_body_props: cfg.asset.body_name → cfg.asset.base_name - tests/base/test_sim_backend.py: all body_name keys/kwargs updated
TATP-233
added a commit
that referenced
this pull request
May 4, 2026
Feat/sim backend kinematics api
TATP-233
added a commit
that referenced
this pull request
Sep 4, 2026
Feat/sim backend kinematics api
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.
No description provided.