Repository navigation
Support Multi-Back for Demo Scripts (Part 2) and Unify Code Structure - #6140
Conversation
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Signed-off-by: Yize Wang <[email protected]>
Greptile SummaryThis PR unifies the structure of demo scripts to use
Confidence Score: 4/5The PR is mostly safe to merge; the structural cleanup across all demo scripts is straightforward, with one robot reset block in multi_asset.py that dropped .clone() inconsistently and may silently corrupt default tensor buffers on repeated resets. The structural unification is clean and consistent across all 14 scripts. The .clone() removal for robot joint/velocity tensors in multi_asset.py is a concrete defect that could produce incorrect simulation state on reset without any error message. Everything else is cosmetic. scripts/demos/multi_asset.py — specifically the robot reset block where .clone() was dropped for default_root_vel and default_joint_pos/vel tensors. Important Files Changed
|
| root_vel = robot.data.default_root_vel.torch | ||
| robot.write_root_velocity_to_sim_index(root_velocity=root_vel) | ||
| # -- joint state | ||
| joint_pos, joint_vel = ( | ||
| robot.data.default_joint_pos.torch.clone(), | ||
| robot.data.default_joint_vel.torch.clone(), | ||
| ) | ||
| joint_pos = robot.data.default_joint_pos.torch | ||
| joint_vel = robot.data.default_joint_vel.torch |
There was a problem hiding this comment.
.clone() is omitted for root_vel, joint_pos, and joint_vel when resetting the robot, but the immediately preceding root_pose reset still uses .clone(). The same applies to rigid_object reset at line 251 (.clone() is preserved there). If write_*_to_sim_index modifies the tensor in-place, skipping .clone() would corrupt the default_root_vel / default_joint_* buffers and produce wrong values on subsequent resets.
| root_vel = robot.data.default_root_vel.torch | |
| robot.write_root_velocity_to_sim_index(root_velocity=root_vel) | |
| # -- joint state | |
| joint_pos, joint_vel = ( | |
| robot.data.default_joint_pos.torch.clone(), | |
| robot.data.default_joint_vel.torch.clone(), | |
| ) | |
| joint_pos = robot.data.default_joint_pos.torch | |
| joint_vel = robot.data.default_joint_vel.torch | |
| root_vel = robot.data.default_root_vel.torch.clone() | |
| robot.write_root_velocity_to_sim_index(root_velocity=root_vel) | |
| # -- joint state | |
| joint_pos = robot.data.default_joint_pos.torch.clone() | |
| joint_vel = robot.data.default_joint_vel.torch.clone() |
There was a problem hiding this comment.
root_vel joint_pos joint_vel are not modified. No need to clone these variables. root_pose is cloned because of root_pose[:, :3] += scene.env_origins.
| description="View ARL Robot 1 with Lee Position Controller.", | ||
| conflict_handler="resolve", | ||
| ) | ||
| parser.add_argument("--physics", default="physx", choices=["physx"], help="Physics backend.") |
There was a problem hiding this comment.
The Newton backend is not supported because the Multirotor class is directly tied to the physx backend. Filed Proposal#6141: Add Newton Backend Support for Multirotor Asset.
There was a problem hiding this comment.
I think this is Ok for now. We can look into drones later.
| ) | ||
| parser.add_argument("--physics", default="physx", choices=["physx", "newton_mjwarp"], help="Physics backend.") | ||
| # Newton visualizer not supported for deformables | ||
| parser.add_argument("--visualizer", default="kit", choices=["kit"], help="Visualizer backend.") |
There was a problem hiding this comment.
The Newton visualizer is not supported because the Newton shadow-model fails to import PhysX-authored deformable USD. Filed Proposal#6142: Support Kit-less Deformable USD.
There was a problem hiding this comment.
Answered in the proposal! Thanks for bringing this up, this is something we aim to have in the future! So far only newton backend can be visualized in newton, but ideally we can also visualize physx backend in newton.
| sim_device=args_cli.device, | ||
| limit_force=2.0, | ||
| ) | ||
| haply_device = haply_cfg.class_type(cfg=haply_cfg) |
There was a problem hiding this comment.
This script has NOT been validated, because HaplyDevice requires peripheral devices of Inverse3 and VerseGrip, which are not available on my device. If needed, I can coordinate with Nic Ma to perform a validation.
| description="This script demonstrates different types of markers.", | ||
| conflict_handler="resolve", | ||
| ) | ||
| parser.add_argument("--physics", default="physx", choices=["physx"], help="Physics backend.") |
There was a problem hiding this comment.
The Newton backend is not supported. Filed Proposal#6143: Support General USD Models in Netwon. We will leave this script kit-and-physx-only as discussed in https://nvidia.slack.com/archives/C0AV4B102HG/p1781038183961149?thread_ts=1781013526.172589&cid=C0AV4B102HG.
|
|
||
| def randomize_shape_color(prim_path_expr: str): | ||
| """Randomize the color of the geometry.""" | ||
| from pxr import Gf, Sdf |
There was a problem hiding this comment.
Discussion with @ooctipus in progress. We want to avoid all local imports.
Signed-off-by: Yize Wang <[email protected]>
| import carb | ||
| import omni | ||
| from omni.kit.viewport.utility import get_viewport_from_window_name | ||
| from omni.kit.viewport.utility.camera_state import ViewportCameraState | ||
| from pxr import Gf, Sdf |
There was a problem hiding this comment.
In discussion with @ooctipus on how to avoid local imports for carb omni pxr.
Signed-off-by: Yize Wang <[email protected]>
| # append AppLauncher cli args | ||
| AppLauncher.add_app_launcher_args(parser) | ||
| # demos should open Kit visualizer by default | ||
| parser.add_argument("--physics", default="physx", choices=["physx"], help="Physics backend.") |
There was a problem hiding this comment.
The Newton physics backend is not support because MJWarp requires at least 1 joint while this scene only contains a ground. Filed Proposal#6144: Support Newton MJWarp for No-joint Scenes.
| if args_cli.physics == "newton_mjwarp": | ||
| # Newton/MJWarp requires a uniform layout, not supporting different setups across environments. | ||
| scene_cfg.object.spawn.assets_cfg = scene_cfg.object.spawn.assets_cfg[1:2] | ||
| scene_cfg.robot.spawn.usd_path = scene_cfg.robot.spawn.usd_path[0] |
There was a problem hiding this comment.
The newton backend does not support heterogeneous spawning. Filed Proposal#6162: Support Mixed Spawns with Newton-MJWarp.
| # Get the color for each vertex based on the height | ||
| color_map = kwargs.pop("color_map", "turbo") | ||
| # Valid options are ["viridis", "inferno", "plasma", "magma"] | ||
| color_map = kwargs.pop("color_map", "inferno") |
There was a problem hiding this comment.
Rationale: "turbo" is not available anymore.
| spawn=sim_utils.MultiAssetSpawnerCfg( | ||
| assets_cfg=[ | ||
| sim_utils.ConeCfg( | ||
| (sim_utils.CylinderCfg)( |
There was a problem hiding this comment.
Rational: I replaced ConeCfg with CylinderCfg because the former is not supported in Newton.
There was a problem hiding this comment.
Maybe it should be. Can you open a discussion with Newton?
Signed-off-by: Yize Wang <[email protected]>
| @@ -111,7 +115,7 @@ class MultiObjectSceneCfg(InteractiveSceneCfg): | |||
| prim_path="/World/envs/env_.*/Object", | |||
There was a problem hiding this comment.
@AntoineRichard The newton backend requires this to be "/World/envs/env_.*/ObjectCollection/Object_A".
There was a problem hiding this comment.
[Update] @AntoineRichard is working on cleaning up this. Filed Proposal#6147: Fix Newton Object Collection Path Matching.
There was a problem hiding this comment.
[Update] The discussion is in https://nvidia.slack.com/archives/C0AV4B102HG/p1781501068492329. We have not reached an agreement with colleagues from the newton backend.
There was a problem hiding this comment.
[Update] @AntoineRichard will draft a PR on the newton side.
There was a problem hiding this comment.
AntoineRichard
left a comment
There was a problem hiding this comment.
A high level comment, I'm wondering if we could add tests to validate that most the examples are working as expected. This would be great to maintain things in the future.
| spawn=sim_utils.MultiAssetSpawnerCfg( | ||
| assets_cfg=[ | ||
| sim_utils.ConeCfg( | ||
| (sim_utils.CylinderCfg)( |
There was a problem hiding this comment.
Maybe it should be. Can you open a discussion with Newton?
| description="View ARL Robot 1 with Lee Position Controller.", | ||
| conflict_handler="resolve", | ||
| ) | ||
| parser.add_argument("--physics", default="physx", choices=["physx"], help="Physics backend.") |
There was a problem hiding this comment.
I think this is Ok for now. We can look into drones later.
| ) | ||
| parser.add_argument("--physics", default="physx", choices=["physx", "newton_mjwarp"], help="Physics backend.") | ||
| # Newton visualizer not supported for deformables | ||
| parser.add_argument("--visualizer", default="kit", choices=["kit"], help="Visualizer backend.") |
There was a problem hiding this comment.
It also looks like the deformable look a lot better with newton? At least in the video @YizeWang shared
There was a problem hiding this comment.
it might make more sense to have an error thrown specifically for backend physx and visualizer newton, since the current setup excludes backend newton and visualizer newton.
@YizeWang Would it be possible to run the two at a fixed seed for comparison? Then the same objects are spawned and we can compare them more fairly, I think Newton is still struggling a bit with friction and collision, which by default isn't great so needs to be tuned. But I would say this is down to default parameter choice.
Signed-off-by: Yize Wang <[email protected]>
…isaac-sim#6140) # Description This PR updates several demo scripts to support multi-backends and unify the code structure of all demo scripts. No new required dependencies. ## Type of change - New feature (non-breaking change which adds functionality) - Bug fix (non-breaking change which fixes an issue) - Documentation update ## Screenshots <img width="3290" height="1016" alt="arl_robot_1_3x_compressed" src="https://github.com/user-attachments/assets/5681a5d9-de29-4e8a-878f-a203b81590f8" /> <img width="1440" height="450" alt="deformables_3x_compressed_half_1p5x" src="https://github.com/user-attachments/assets/ad0d2490-143a-43aa-bb2d-a1afcbd8fdfe" /> <img width="1440" height="900" alt="markers_3x_compressed" src="https://github.com/user-attachments/assets/37b26c85-e050-4483-851d-51276f498a0e" /> <img width="1866" height="1170" alt="procedural_terrain" src="https://github.com/user-attachments/assets/f8190bc0-7360-4266-85fc-64d84758061d" /> ## Checklist - [ ] I have read and understood the contribution guidelines - [x] I have run the pre-commit checks with ./isaaclab.sh -f - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog - [x] I have added my name to CONTRIBUTORS.md or my name already exists there --------- Signed-off-by: Yize Wang <[email protected]> Co-authored-by: Yize Wang <[email protected]> Co-authored-by: Octi Zhang <[email protected]>
Description
This PR updates several demo scripts to support multi-backends and unify the code structure of all demo scripts.
No new required dependencies.
Type of change
Screenshots
Checklist