Repository navigation
Add PhysX support for DR Legs - #6667
Conversation
Greptile SummaryThis PR adds a PhysX physics backend preset to the DR Legs hold-pose and walking environments, alongside the existing Kamino/Newton configuration. The Kamino defaults are preserved unchanged; the new PhysX variant selects a reduced action scale (0.1), zero-range joint reset (for assembled coordinates), and the PhysX-native contact sensor.
Confidence Score: 4/5Safe to merge; the Kamino path is demonstrably unchanged and the PhysX preset has been smoke-tested at 4096 environments with measured FPS and reward metrics. The logic is straightforward preset branching with no shared mutable state between backends. The two minor observations — missing type annotations on DrLegsContactSensorCfg and an incomplete assertion in the regression test — do not affect runtime correctness. walk_env_cfg.py for the annotation inconsistency; test_dr_legs_physics_presets.py for the incomplete physics.physx assertion in the Kamino test. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["presets=physx / presets=newton_kamino"]
CLI --> RP["resolve_presets()"]
RP --> PHYS["DrLegsPhysicsCfg"]
RP --> ACT["DrLegsActionsCfg"]
RP --> EVT["DrLegsEventCfg"]
RP --> SENS["DrLegsContactSensorCfg\n(walk env only)"]
PHYS -->|physx| PX_PHY["PhysxCfg()"]
PHYS -->|newton_kamino / default| NK_PHY["NewtonCfg + KaminoSolverCfg"]
ACT -->|physx| PX_ACT["scale=0.1"]
ACT -->|newton_kamino / default| NK_ACT["scale=0.3"]
EVT -->|physx| PX_EVT["position_range=(0,0)\nvelocity_range=(0,0)"]
EVT -->|newton_kamino / default| NK_EVT["position_range=(-0.1,0.1)\nvelocity_range=(-0.05,0.05)"]
SENS -->|physx| PX_SENS["PhysXContactSensorCfg"]
SENS -->|newton_kamino / default| NK_SENS["NewtonContactSensorCfg"]
Reviews (1): Last reviewed commit: "Add PhysX support for DR Legs" | Re-trigger Greptile |
| @configclass | ||
| class WalkSceneCfg(HoldPoseSceneCfg): | ||
| contact_forces = NewtonContactSensorCfg( | ||
| class DrLegsContactSensorCfg(PresetCfg): | ||
| """Backend-specific foot contact sensor configuration.""" | ||
|
|
||
| default = NewtonContactSensorCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot/foot_.*", | ||
| history_length=3, | ||
| track_air_time=True, | ||
| ) | ||
| newton_kamino = default | ||
| physx = PhysXContactSensorCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot/foot_.*", | ||
| history_length=3, | ||
| track_air_time=True, | ||
| ) |
There was a problem hiding this comment.
Missing type annotations on
DrLegsContactSensorCfg fields
Unlike DrLegsActionsCfg and DrLegsEventCfg introduced in the same PR — which use explicit type annotations (default: ActionsCfg = ActionsCfg()) — the three fields on DrLegsContactSensorCfg carry no annotations. Since _preset_fields falls back to vars(cls) for unannotated attributes, this works at runtime, but the fields won't appear in __dataclass_fields__ and won't benefit from type checking. A base class annotation (e.g., ContactSensorCfg from a shared module, or simply object) would make the pattern consistent with the rest of this PR.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| def test_dr_legs_kamino_presets_remain_unchanged() -> None: | ||
| """PhysX support must not change the existing Kamino task distribution.""" | ||
| physics = DrLegsPhysicsCfg() | ||
| env_cfg = resolve_presets(DrLegsHoldPoseEnvCfg(), selected=("newton_kamino",)) | ||
|
|
||
| assert isinstance(physics.default, NewtonCfg) | ||
| assert isinstance(physics.newton_kamino.solver_cfg, KaminoSolverCfg) | ||
| assert env_cfg.events.reset_base.params["pose_range"]["x"] == (-0.05, 0.05) | ||
| assert env_cfg.events.reset_robot_joints.params["position_range"] == (-0.1, 0.1) | ||
| assert env_cfg.events.reset_robot_joints.params["velocity_range"] == (-0.05, 0.05) | ||
| assert env_cfg.actions.joint_pos.scale == 0.3 |
There was a problem hiding this comment.
DrLegsPhysicsCfg.physx not asserted in the Kamino regression test
test_dr_legs_kamino_presets_remain_unchanged instantiates DrLegsPhysicsCfg and asserts on physics.default and physics.newton_kamino, but never checks physics.physx. Adding assert isinstance(physics.physx, PhysxCfg) here (the import is already present) would complete the round-trip coverage and guard against accidental drift of the new preset's type in the same test that validates the existing ones.
## Summary - Add a PhysX physics preset for the DR Legs hold-pose and walking environments. - Select the PhysX contact sensor and an assembled-joint reset profile for PhysX. - Bound driven and passive joint simulation velocities at 100 rad/s instead of inheriting the USD limit of about 17,000 rad/s. - Keep the PhysX-only 0.1 action scale because it provides the best velocity-tracking success, while preserving the existing Kamino solver and task presets. ## Testing - `./isaaclab.sh -p -m pytest source/isaaclab_tasks/test/core/test_dr_legs_physics_presets.py -q` (`2 passed`) - `./isaaclab.sh -f` - Final configuration smoke: RSL-RL, `IsaacContrib-DrLegs-Walk`, `presets=physx`, 4096 environments, seed 42, 5 iterations; completed and reported 100 rad/s for all 30 joints. - Action-scale experiments at 4096 environments, seed 42, 300 iterations: - 0.3 without the limit: value loss became `inf` at iteration 1 and observations became NaN at iteration 3. - 0.3 with the 100 rad/s limit: completed without NaNs. Final-20 reward 326.16, episode length 494.20, success rate 0%, XY error 0.276 m/s, yaw error 0.829 rad/s. - 0.2 with the limit: completed without NaNs. Final-20 reward 356.03, episode length 496.36, success rate 51.95%, XY error 0.232 m/s, yaw error 0.423 rad/s; mean throughput 49.8k FPS. - 0.1 baseline: completed without NaNs. Final-20 reward 342.15, episode length 492.11, success rate 94.21%, XY error 0.237 m/s, yaw error 0.318 rad/s. - The solver clamp fixes numerical stability at larger scales. Scale 0.2 maximizes aggregate reward and slightly improves XY error, but scale 0.1 remains substantially better for yaw tracking and overall success.
Summary
Testing
./isaaclab.sh -p -m pytest source/isaaclab_tasks/test/core/test_dr_legs_physics_presets.py -q(2 passed)./isaaclab.sh -fIsaacContrib-DrLegs-Walk,presets=physx, 4096 environments, seed 42, 5 iterations; completed and reported 100 rad/s for all 30 joints.infat iteration 1 and observations became NaN at iteration 3.