Skip to content

fix(newton): support newton 1.5/1.6 (removed attributes, target layout, tiled camera) - #37

Open
geng-haoran wants to merge 1 commit into
mainfrom
fix/newton-1.5-removed-attrs
Open

fix(newton): support newton 1.5/1.6 (removed attributes, target layout, tiled camera)#37
geng-haoran wants to merge 1 commit into
mainfrom
fix/newton-1.5-removed-attrs

Conversation

@geng-haoran

@geng-haoran geng-haoran commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

MetaSim's pyproject installs newton @ git+https://github.com/newton-physics/newton.git (currently 1.6.0.dev0), but NewtonHandler was written against newton < 1.2 and could no longer construct a scene: Model.joint_target_pos was removed in 1.5, the tiled-camera sensor API changed in 1.4, Model.num_worlds was renamed in 1.6, and — the one that bites silently — position targets moved to the joint_q layout. Four changes, all version-guarded so older newton keeps its current path:

  1. Compat shims (_newton_compat.py): Model/Control joint_target_pos/joint_target_veljoint_target_q/joint_target_qd (read/write properties over the 1.5 RemovedAttribute descriptors); Model.num_worldsworld_count.
  2. Position-target layout: newton ≥ 1.5 lays joint_target_q out like joint_q (a free joint takes 7 slots, not 6) and publishes joint_target_q_start. The handler indexed position targets by dof (joint_qd_start) everywhere, so in any scene with a free-floating object every env after env 0 received its targets three joints off (env 1's panda_joint1 was driven to panda_joint4's target). All six write/read sites now use joint_target_q_start when the model has it and fall back to the dof layout otherwise; velocity targets and gains stay dof-indexed as before.
  3. Tiled camera on newton ≥ 1.4: model-wide SensorTiledCamera(model, default_render_config=RenderConfig(...)), rays/outputs/light from sensor.utils, rendering through sensor.update after bvh_refit_shapes; textures that the sensor cannot load (RGB where RGBA is expected) fall back to untextured rendering with a warning instead of disabling cameras.
  4. CameraState.depth is (N, H, W); the handler produced (N, H, W, 1) and CameraState.__post_init__ rejected it.

Verification (RTX 5090, newton 1.6.0.dev0, warp 1.17)

  • pytest metasim/test/ -k newton: before — construction failed outright; with 1+3+4 only — 76 passed, 6 failed (test_set_dof_targets_per_env, test_parallel_envs_actions, test_parallel_envs_simulate_consistency × {2, 4} envs, all "env 1 didn't move towards target"); with 2 — 82 passed, 6 skipped, 6 xfailed, 0 failed.
  • get_started matrix on --sim newton (the four scripts that declare newton): 4/4 pass (0_static_scene, 1_control_robot, 2_add_new_robot, 3_parallel_envs); rendered frames/videos in the session report.
  • metasim/test/test_newton_compat_general.py (new, general): the shims against a synthetic newton module with the 1.5 descriptors and the pre-1.5 attributes; 2 passed.
  • RoboVerse mjlab.velocity_flat_go1_v2 on Newton with 2 envs (for RoboVerse #817) runs on this branch.

Not verified

No newton < 1.5 install was available here, so the legacy branches are exercised only by the synthetic-module test; they are the unchanged code paths behind the version guards.

🤖 Generated with Claude Code

https://claude.ai/code/session_017i6VtKoovBNed815mWFqxw

…t, tiled camera)

The pinned newton (git main, 1.6.0.dev0) could not build a scene: Model.joint_target_pos
was removed in 1.5, the tiled-camera API changed in 1.4, Model.num_worlds was renamed in
1.6, and position targets moved to the joint_q layout so every env after a free joint
received its targets three joints off. Version-guarded shims and index tables fix all
four; CameraState.depth is emitted as (N, H, W). Verified: 82 newton tests pass and the
four newton get_started cases render.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017i6VtKoovBNed815mWFqxw
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.

1 participant