Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates EmbodiChain’s simulation/rendering integration to align with DexSim v0.4.0 by replacing the previous enable_rt-style flags with a structured rendering configuration (RenderCfg) and propagating that change through tests, examples, CLI helpers, configs, and docs.
Changes:
- Introduce
RenderCfgand migrateSimulationManagerCfgrendering settings torender_cfg. - Update scripts/examples/tests to use
--rendererand/orRenderCfg(renderer=...)instead of--enable_rt. - Apply broad formatting/whitespace cleanup across multiple modules and docs.
Reviewed changes
Copilot reviewed 80 out of 80 changed files in this pull request and generated 33 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sim/sensors/test_stereo.py | Migrate stereo camera tests to RenderCfg/renderer-based configuration |
| tests/sim/sensors/test_contact.py | Migrate contact sensor tests to RenderCfg/renderer-based configuration |
| tests/sim/sensors/test_camera.py | Migrate camera tests to RenderCfg/renderer-based configuration |
| tests/sim/objects/test_usd.py | Update USD object tests to use render_cfg |
| tests/sim/objects/test_soft_object.py | Update soft object tests to use render_cfg |
| tests/sim/objects/test_robot.py | Whitespace cleanup |
| tests/gym/envs/test_embodied_env.py | Update env tests to use render_cfg and renderer arg |
| tests/gym/envs/managers/test_dataset_functors.py | Whitespace cleanup |
| tests/common.py | Whitespace cleanup |
| tests/agents/test_shared_rollout.py | Update sim config to use render_cfg |
| scripts/tutorials/sim/import_usd.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/gizmo_robot.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/export_usd.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/create_softbody.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/create_sensor.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/create_scene.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/create_robot.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/sim/create_rigid_object_group.py | Update tutorial script to new env launcher args + RenderCfg |
| scripts/tutorials/gym/random_reach.py | Replace ad-hoc CLI args with shared env launcher args |
| scripts/tutorials/gym/modular_env.py | Update modular env example to pass renderer/device/headless/num_envs |
| examples/sim/utility/workspace_analyzer/analyze_plane_workspace.py | Whitespace cleanup |
| examples/sim/sensors/create_contact_sensor.py | Update example to use env launcher args + RenderCfg |
| examples/sim/sensors/batch_camera.py | Update example to use env launcher args + RenderCfg |
| examples/sim/scene/scene_demo.py | Update scene demo CLI and rendering config to renderer-based setup |
| examples/sim/gizmo/gizmo_w1.py | Update gizmo example CLI and rendering config |
| examples/sim/gizmo/gizmo_scene.py | Update gizmo example CLI and rendering config |
| examples/sim/gizmo/gizmo_robot.py | Update gizmo example CLI and rendering config |
| examples/sim/gizmo/gizmo_object.py | Update gizmo example CLI and rendering config |
| examples/sim/gizmo/gizmo_camera.py | Update gizmo example CLI and rendering config |
| examples/sim/demo/scoop_ice.py | Update demo to use env launcher args + renderer configuration |
| examples/sim/demo/press_softbody.py | Update demo to use env launcher args + renderer configuration |
| examples/sim/demo/grasp_cup_to_caffe.py | Update demo to use env launcher args + renderer configuration |
| examples/agents/datasets/online_dataset_demo.py | Adjust demo engine config keys for renderer-based setup |
| embodichain/utils/warp/kinematics/opw_solver.py | Whitespace cleanup |
| embodichain/utils/configclass.py | Whitespace cleanup |
| embodichain/utils/init.py | Whitespace cleanup |
| embodichain/toolkits/urdf_assembly/component.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/voxel_visualizer.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/sphere_visualizer.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/base_visualizer.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/samplers/base_sampler.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/constraints/workspace_constraint.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/constraints/base_constraint.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/configs/init.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/caches/cache_manager.py | Whitespace cleanup |
| embodichain/lab/sim/utility/workspace_analyzer/caches/base_cache.py | Whitespace cleanup |
| embodichain/lab/sim/types.py | Whitespace cleanup |
| embodichain/lab/sim/solvers/pinocchio_solver.py | Whitespace cleanup |
| embodichain/lab/sim/solvers/opw_solver.py | Whitespace cleanup |
| embodichain/lab/sim/solvers/differential_solver.py | Whitespace cleanup |
| embodichain/lab/sim/sim_manager.py | Replace old RT flags with render_cfg, update renderer wiring and behavior |
| embodichain/lab/sim/robots/dexforce_w1/utils.py | Whitespace cleanup |
| embodichain/lab/sim/objects/gizmo.py | Whitespace cleanup |
| embodichain/lab/sim/cfg.py | Add RenderCfg configclass and DexSim renderer flag mapping |
| embodichain/lab/sim/atom_actions.py | Whitespace cleanup |
| embodichain/lab/scripts/run_agent.py | Whitespace cleanup |
| embodichain/lab/gym/utils/gym_utils.py | Update shared CLI args + config merging to use renderer/RenderCfg |
| embodichain/lab/gym/envs/tasks/tableware/pour_water/action_bank.py | Whitespace cleanup |
| embodichain/lab/gym/envs/managers/randomization/spatial.py | Whitespace cleanup |
| embodichain/lab/gym/envs/managers/randomization/physics.py | Whitespace cleanup |
| embodichain/lab/gym/envs/embodied_env.py | Whitespace cleanup |
| embodichain/lab/gym/envs/action_bank/utils.py | Whitespace cleanup |
| embodichain/data/assets/scene_assets.py | Whitespace cleanup |
| embodichain/data/assets/robot_assets.py | Whitespace cleanup |
| embodichain/data/assets/obj_assets.py | Whitespace cleanup |
| embodichain/data/assets/materials.py | Whitespace cleanup |
| embodichain/data/assets/eef_assets.py | Whitespace cleanup |
| embodichain/agents/rl/train.py | Switch trainer config handling from enable_rt to renderer/RenderCfg |
| embodichain/agents/rl/models/mlp.py | Whitespace cleanup |
| embodichain/agents/engine/data.py | Switch engine sim config from enable_rt to renderer/RenderCfg |
| embodichain/agents/datasets/sampler.py | Whitespace cleanup |
| embodichain/agents/datasets/online_data.py | Whitespace cleanup |
| docs/sync_readme.py | Formatting tweak |
| docs/source/tutorial/sensor.rst | Update tutorial CLI docs from --enable_rt to --renderer |
| docs/source/tutorial/robot.rst | Update tutorial CLI docs from --enable_rt to --renderer |
| docs/source/tutorial/gizmo.rst | Update tutorial CLI docs from --enable_rt to --renderer |
| docs/source/overview/sim/sim_manager.md | Update sim manager docs to reflect renderer configuration changes |
| configs/agents/rl/push_cube/train_config.json | Replace enable_rt with renderer and reformat JSON |
| configs/agents/rl/basic/cart_pole/train_config_grpo.json | Replace enable_rt with renderer and reformat JSON |
| configs/agents/rl/basic/cart_pole/train_config.json | Replace enable_rt with renderer and reformat JSON |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| else: | ||
| logger.log_error( | ||
| f"Invalid renderer type '{self.renderer}' specified. Must be one of 'legacy', 'hybrid', or 'fast-rt'." | ||
| ) |
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| test = CameraTest() | ||
| test.setup_simulation("cpu", enable_rt=False) | ||
| test.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
| gym_config["headless"] = True | ||
| gym_config["enable_rt"] = True | ||
| gym_config.get("renderer", "legacy") = True | ||
| gym_config["gpu_id"] = 0 |
There was a problem hiding this comment.
Pull request overview
This PR adapts the simulation stack and surrounding tooling to DexSim v0.4.0 by replacing the legacy enable_rt flag with a structured rendering configuration (RenderCfg) and a --renderer CLI option across tests, examples, and training/engine code.
Changes:
- Introduce
RenderCfgand migrateSimulationManagerCfgfromenable_rttorender_cfg. - Update CLI utilities and many scripts/examples to use
--renderer(legacy/hybrid/fast-rt). - Refresh tests/configs/docs to reflect the new rendering configuration.
Reviewed changes
Copilot reviewed 81 out of 81 changed files in this pull request and generated 15 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/sim/sensors/test_stereo.py | Migrate stereo sensor tests to new rendering config (currently has call-site issues). |
| tests/sim/sensors/test_contact.py | Migrate contact sensor tests to new rendering config (currently has call-site issues). |
| tests/sim/sensors/test_camera.py | Migrate camera sensor tests to new rendering config (currently has call-site issues). |
| tests/sim/objects/test_usd.py | Update SimulationManagerCfg construction for new renderer config. |
| tests/sim/objects/test_soft_object.py | Update SimulationManagerCfg construction for new renderer config. |
| tests/sim/objects/test_robot.py | Whitespace cleanup. |
| tests/gym/envs/test_embodied_env.py | Update env test sim config for new renderer config (currently has call-site issues). |
| tests/gym/envs/managers/test_dataset_functors.py | Whitespace cleanup. |
| tests/common.py | Whitespace cleanup. |
| tests/agents/test_shared_rollout.py | Update env sim config to use render_cfg in rollout test. |
| scripts/tutorials/sim/import_usd.py | Switch to shared CLI args + renderer config (currently hard-codes values). |
| scripts/tutorials/sim/gizmo_robot.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/sim/export_usd.py | Switch to shared CLI args + renderer gating for lighting. |
| scripts/tutorials/sim/create_softbody.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/sim/create_sensor.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/sim/create_scene.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/sim/create_robot.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/sim/create_rigid_object_group.py | Switch to shared CLI args + RenderCfg(renderer=args.renderer). |
| scripts/tutorials/gym/random_reach.py | Use shared CLI args for env launching. |
| scripts/tutorials/gym/modular_env.py | Add renderer option and build sim config from shared CLI args. |
| examples/sim/utility/workspace_analyzer/analyze_plane_workspace.py | Whitespace cleanup. |
| examples/sim/sensors/create_contact_sensor.py | Switch to shared CLI args + renderer config. |
| examples/sim/sensors/batch_camera.py | Switch to shared CLI args + renderer config. |
| examples/sim/scene/scene_demo.py | Switch to shared CLI args + renderer config. |
| examples/sim/gizmo/gizmo_w1.py | Switch to shared CLI args + renderer config. |
| examples/sim/gizmo/gizmo_scene.py | Switch to shared CLI args + renderer config. |
| examples/sim/gizmo/gizmo_robot.py | Switch to shared CLI args + renderer config. |
| examples/sim/gizmo/gizmo_object.py | Switch to shared CLI args + renderer config. |
| examples/sim/gizmo/gizmo_camera.py | Switch to shared CLI args + renderer config. |
| examples/sim/demo/scoop_ice.py | Add shared CLI args and pass renderer into sim initialization. |
| examples/sim/demo/press_softbody.py | Switch to shared CLI args + renderer config. |
| examples/sim/demo/grasp_cup_to_caffe.py | Switch to shared CLI args + renderer config + lighting gate. |
| examples/agents/datasets/online_dataset_demo.py | Update gym config handling for renderer (currently contains invalid syntax). |
| embodichain/utils/warp/kinematics/opw_solver.py | Whitespace cleanup. |
| embodichain/utils/configclass.py | Whitespace cleanup. |
| embodichain/utils/init.py | Whitespace cleanup. |
| embodichain/toolkits/urdf_assembly/component.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/voxel_visualizer.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/sphere_visualizer.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/visualizers/base_visualizer.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/samplers/base_sampler.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/constraints/workspace_constraint.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/constraints/base_constraint.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/configs/init.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/caches/cache_manager.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/workspace_analyzer/caches/base_cache.py | Whitespace cleanup. |
| embodichain/lab/sim/utility/sim_utils.py | Extend RT detection + (currently) breaks SDF path due to missing import. |
| embodichain/lab/sim/types.py | Whitespace cleanup. |
| embodichain/lab/sim/solvers/pinocchio_solver.py | Whitespace cleanup. |
| embodichain/lab/sim/solvers/opw_solver.py | Whitespace cleanup. |
| embodichain/lab/sim/solvers/differential_solver.py | Whitespace cleanup. |
| embodichain/lab/sim/sim_manager.py | Replace enable_rt with render_cfg and update renderer/RT logic. |
| embodichain/lab/sim/robots/dexforce_w1/utils.py | Whitespace cleanup. |
| embodichain/lab/sim/objects/gizmo.py | Whitespace cleanup. |
| embodichain/lab/sim/cfg.py | Add RenderCfg and renderer mapping into DexSim flags. |
| embodichain/lab/sim/atom_actions.py | Whitespace cleanup. |
| embodichain/lab/scripts/run_agent.py | Whitespace cleanup. |
| embodichain/lab/gym/utils/gym_utils.py | Add --renderer, merge into config, and build sim cfg with RenderCfg. |
| embodichain/lab/gym/envs/tasks/tableware/pour_water/action_bank.py | Whitespace cleanup. |
| embodichain/lab/gym/envs/managers/randomization/spatial.py | Whitespace cleanup. |
| embodichain/lab/gym/envs/managers/randomization/physics.py | Whitespace cleanup. |
| embodichain/lab/gym/envs/embodied_env.py | Whitespace cleanup. |
| embodichain/lab/gym/envs/action_bank/utils.py | Whitespace cleanup. |
| embodichain/data/assets/scene_assets.py | Whitespace cleanup. |
| embodichain/data/assets/robot_assets.py | Whitespace cleanup. |
| embodichain/data/assets/obj_assets.py | Whitespace cleanup. |
| embodichain/data/assets/materials.py | Whitespace cleanup. |
| embodichain/data/assets/eef_assets.py | Whitespace cleanup. |
| embodichain/agents/rl/train.py | Replace trainer enable_rt with renderer and wire into RenderCfg. |
| embodichain/agents/rl/models/mlp.py | Whitespace cleanup. |
| embodichain/agents/engine/data.py | Replace engine sim config enable_rt with RenderCfg(renderer=...). |
| embodichain/agents/datasets/sampler.py | Whitespace cleanup. |
| embodichain/agents/datasets/online_data.py | Whitespace cleanup. |
| docs/sync_readme.py | Formatting tweak. |
| docs/source/tutorial/sensor.rst | Update CLI docs from --enable_rt to --renderer (needs example fix). |
| docs/source/tutorial/robot.rst | Update CLI docs from --enable_rt to --renderer (needs example fix). |
| docs/source/tutorial/gizmo.rst | Update CLI docs from --enable_rt to --renderer (needs wording/example fix). |
| docs/source/overview/sim/sim_manager.md | Update config docs for renderer (currently incorrect type/fields). |
| configs/agents/rl/push_cube/train_config.json | Replace enable_rt with renderer. |
| configs/agents/rl/basic/cart_pole/train_config.json | Replace enable_rt with renderer. |
| configs/agents/rl/basic/cart_pole/train_config_grpo.json | Replace enable_rt with renderer and formatting changes. |
Comments suppressed due to low confidence (3)
embodichain/lab/gym/utils/gym_utils.py:862
build_env_cfg_from_argsimportsRenderCfgfromembodichain.lab.sim, but the packageembodichain.lab.simdoesn't exportRenderCfg(onlySimulationManager*viasim_manager.__all__). This will raiseImportError. Import it fromembodichain.lab.sim.cfgor exportRenderCfginembodichain/lab/sim/__init__.py.
from embodichain.utils.utility import load_json
from embodichain.lab.gym.envs import EmbodiedEnvCfg
from embodichain.lab.sim import RenderCfg, SimulationManagerCfg
gym_config = load_json(args.gym_config)
gym_config = merge_args_with_gym_config(args, gym_config)
cfg: EmbodiedEnvCfg = config_to_cfg(
embodichain/lab/gym/utils/gym_utils.py:801
--gym_configwas changed torequired=False, butbuild_env_cfg_from_argsunconditionally callsload_json(args.gym_config). This makesrun_env.py/run_agent.pyfail later with a less clear error if the flag is omitted. Either keep it required for CLIs that need it, or add an explicit check with a helpful error message whenargs.gym_configis empty.
parser.add_argument(
"--gym_config",
type=str,
help="Path to gym config file.",
default="",
required=False,
)
parser.add_argument(
"--action_config", type=str, help="Path to action config file.", default=None
)
parser.add_argument(
docs/source/overview/sim/sim_manager.md:40
- The
SimulationManagerCfgtable documentsrendereras aboolwith defaultFalse, but the code now usesrender_cfg: RenderCfg(and CLI uses a string backend name). Please update the parameter name/type/default and describe the newRenderCfgfields (renderer/enable_denoiser/spp).
| `width` | `int` | `1920` | The width of the simulation window. |
| `height` | `int` | `1080` | The height of the simulation window. |
| `headless` | `bool` | `False` | Whether to run the simulation in headless mode (no Window). |
| `renderer` | `bool` | `False` | Whether to enable ray tracing rendering. |
| `enable_denoiser` | `bool` | `True` | Whether to enable denoising for ray tracing rendering. |
| `spp` | `int` | `64` | Samples per pixel for ray tracing rendering. Only valid when ray tracing is enabled and denoiser is False. |
| `gpu_id` | `int` | `0` | The gpu index that the simulation engine will be used. Affects gpu physics device. |
| `thread_mode` | `ThreadMode` | `RENDER_SHARE_ENGINE` | The threading mode for the simulation engine. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation now takes renderer (string) but the tests call it with a render_cfg= keyword argument, which will raise TypeError: setup_simulation() got an unexpected keyword argument 'render_cfg'. Update call sites to pass renderer="legacy"/"fast-rt"/... (or change setup_simulation to accept render_cfg).
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestCameraFastRT(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestCameraFastRT(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
There are two classes named TestCameraRaster (and two named TestCameraFastRT) in the same module; the latter definition overwrites the former, so one set of tests will never run. Rename them to distinct CPU/CUDA variants (e.g., TestCameraRasterCPU/TestCameraRasterCUDA).
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation takes renderer (string), but the derived test classes call it with render_cfg=..., which will fail with an unexpected keyword argument. Pass renderer="legacy" / renderer="fast-rt" instead (or update the helper signature).
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
The module defines TestStereoCameraRaster twice and TestStereoCameraFastRT twice; later definitions overwrite earlier ones, so tests are silently dropped. Use distinct class names for CPU vs CUDA variants.
| class TestContactRaster(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactRasterCuda(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactFastRT(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactFastRTCuda(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation signature was changed to accept renderer, but all setup methods call it with render_cfg=... which will raise TypeError. Adjust call sites to pass renderer="legacy"/"fast-rt" (or accept render_cfg in the helper).
| def add_env_launcher_args_to_parser(parser: argparse.ArgumentParser) -> None: | ||
| """Add common environment launcher arguments to an existing argparse parser. | ||
|
|
||
| This function adds the following arguments to the provided parser: | ||
| --num_envs: Number of environments to run in parallel (default: 1) | ||
| --device: Device to run the environment on (default: 'cpu') | ||
| --headless: Whether to perform the simulation in headless mode (default: False) | ||
| --enable_rt: Whether to use RTX rendering backend for the simulation (default: False) | ||
| --renderer: Renderer backend to use for the simulation. Options are 'legacy', 'hybrid', and 'fast-rt'. (default: 'legacy') | ||
| --gpu_id: The GPU ID to use for the simulation (default: 0) | ||
| --gym_config: Path to gym config file (default: '') | ||
| --action_config: Path to action config file (default: None) | ||
| --preview: Whether to preview the environment after launching (default: False) | ||
| --filter_visual_rand: Whether to filter out visual randomization (default: False) | ||
| --filter_dataset_saving: Whether to filter out dataset saving (default: False) | ||
|
|
||
| Note: | ||
| 1. In preview mode, the environment will be launched and keep running in a loop for user interaction. | ||
|
|
||
| Args: | ||
| parser (argparse.ArgumentParser): The parser to which arguments will be added. | ||
| """ | ||
| parser.add_argument( | ||
| "--num_envs", | ||
| help="The number of environments to run in parallel.", | ||
| default=1, | ||
| type=int, | ||
| ) | ||
| parser.add_argument( | ||
| "--device", | ||
| type=str, | ||
| default="cpu", | ||
| help="Device to run the environment on, e.g., 'cpu' or 'cuda'.", | ||
| ) | ||
| parser.add_argument( | ||
| "--headless", | ||
| help="Whether to perform the simulation in headless mode.", | ||
| default=False, | ||
| action="store_true", | ||
| ) | ||
| parser.add_argument( | ||
| "--renderer", | ||
| type=str, | ||
| choices=["legacy", "hybrid", "fast-rt"], | ||
| default="hybrid", | ||
| help="Renderer backend to use for the simulation.", | ||
| ) |
There was a problem hiding this comment.
add_env_launcher_args_to_parser docstring claims --renderer defaults to 'legacy', but the actual argparse default is 'hybrid'. Please align the docstring with the code (and update any other docs that mention the default).
| @@ -60,7 +53,9 @@ def main(): | |||
| headless=True, | |||
| physics_dt=1.0 / 100.0, # Physics timestep (100 Hz) | |||
| sim_device=args.device, | |||
| enable_rt=True, # Enable ray tracing for better visuals | |||
| render_cfg=RenderCfg( | |||
| renderer="fast-rt" if True else "legacy" | |||
| ), # Enable ray tracing for better visuals | |||
| num_envs=1, | |||
| arena_space=3.0, | |||
There was a problem hiding this comment.
The script now parses common launcher args, but the simulation config still hard-codes headless=True (ignoring --headless) and hard-codes the renderer to "fast-rt" via an always-true conditional. Use headless=args.headless and RenderCfg(renderer=args.renderer) so CLI flags actually take effect.
|
|
||
| # Enable ray tracing rendering | ||
| python scripts/tutorials/sim/create_sensor.py --enable_rt | ||
| python scripts/tutorials/sim/create_sensor.py --renderer |
There was a problem hiding this comment.
The documentation shows --renderer without a value. Since --renderer takes a choice (legacy/hybrid/fast-rt), the example should include an explicit value (e.g. --renderer fast-rt).
| python scripts/tutorials/sim/create_sensor.py --renderer | |
| python scripts/tutorials/sim/create_sensor.py --renderer fast-rt |
|
|
||
| # Enable ray tracing rendering | ||
| python scripts/tutorials/sim/create_robot.py --enable_rt | ||
| python scripts/tutorials/sim/create_robot.py --renderer |
There was a problem hiding this comment.
The documentation shows --renderer without a value. Since --renderer expects a backend name (legacy/hybrid/fast-rt), update the example to pass a value (e.g. --renderer hybrid).
| python scripts/tutorials/sim/create_robot.py --renderer | |
| python scripts/tutorials/sim/create_robot.py --renderer hybrid |
| - ``--device cpu|cuda``: Choose simulation device | ||
| - ``--num_envs N``: Number of parallel environments | ||
| - ``--headless``: Run without GUI for automated testing | ||
| - ``--enable_rt``: Enable ray tracing for better visuals | ||
| - ``--renderer``: Enable ray tracing for better visuals |
There was a problem hiding this comment.
The docs say --renderer "Enable ray tracing" but the flag actually selects the backend and requires a value (legacy/hybrid/fast-rt). Update wording and example usage to reflect this (e.g. --renderer fast-rt).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 86 out of 86 changed files in this pull request and generated 13 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestCameraRaster(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
There was a problem hiding this comment.
There are two classes with the same name TestCameraRaster in this module. Pytest will only keep the second definition, so one set of tests is silently dropped. Rename them (e.g., TestCameraRasterCPU / TestCameraRasterCUDA) to ensure both variants execute.
| class TestCameraFastRT(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestCameraFastRT(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
There are two classes with the same name TestCameraFastRT in this module. The latter overwrites the former, so half the tests won't run under pytest. Rename them to distinct CPU/CUDA variants.
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation takes renderer as the second parameter, but the test classes call it with render_cfg=..., which will raise TypeError at runtime. Either pass renderer="legacy"/"fast-rt"/"hybrid" or change setup_simulation's signature to accept a RenderCfg argument consistently.
| class TestContactRaster(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactRasterCuda(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactFastRT(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| class TestContactFastRTCuda(ContactTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation is defined as setup_simulation(self, sim_device, renderer="legacy"), but the test cases call it with render_cfg=.... This will fail with an unexpected keyword argument error; pass renderer=... or update the helper to accept a RenderCfg consistently.
| | `renderer` | `bool` | `False` | Whether to enable ray tracing rendering. | | ||
| | `enable_denoiser` | `bool` | `True` | Whether to enable denoising for ray tracing rendering. | | ||
| | `spp` | `int` | `64` | Samples per pixel for ray tracing rendering. Only valid when ray tracing is enabled and denoiser is False. | |
There was a problem hiding this comment.
The docs table still describes renderer as a bool with default False, and still documents enable_denoiser/spp as top-level SimulationManagerCfg fields. In the code, rendering is now configured via render_cfg: RenderCfg with renderer: Literal[...] and enable_denoiser/spp nested under it. Please update the parameter table to reflect the new API (including the correct type/default).
| | `renderer` | `bool` | `False` | Whether to enable ray tracing rendering. | | |
| | `enable_denoiser` | `bool` | `True` | Whether to enable denoising for ray tracing rendering. | | |
| | `spp` | `int` | `64` | Samples per pixel for ray tracing rendering. Only valid when ray tracing is enabled and denoiser is False. | | |
| | `render_cfg` | `RenderCfg` | `RenderCfg()` | Rendering configuration (renderer type, denoiser, samples per pixel, and other rendering options). | |
| def _proxy_gizmo_callback(self, *args): | ||
| """Generic callback for proxy-based gizmo. | ||
|
|
||
| def _proxy_gizmo_callback(self, node, translation, rotation, flag): | ||
| """Generic callback for proxy-based gizmo: only updates proxy cube transform, defers actual updates""" | ||
| Supports both old signature: (node, translation, rotation, flag) | ||
| and new signature: (node, local_pose, flag) where local_pose is a 4x4 matrix. | ||
| Updates the proxy cube transform and sets `_pending_target_transform`. | ||
| """ | ||
| # New API callback signature: (node, local_pose, flag) | ||
| if len(args) != 3: | ||
| return | ||
| node, local_pose, flag = args |
There was a problem hiding this comment.
The updated docstring says this callback supports both the old 4-arg signature and the new 3-arg signature, but the implementation returns early unless len(args) == 3. If backward compatibility is intended, handle the 4-arg case; otherwise, update the docstring to avoid misleading callers.
| @@ -61,7 +52,7 @@ def main(): | |||
| height=1080, | |||
| physics_dt=1.0 / 100.0, | |||
| sim_device=args.device, | |||
| enable_rt=args.enable_rt, | |||
| render_cfg=RenderCfg(renderer=args.renderer), | |||
| ) | |||
There was a problem hiding this comment.
add_env_launcher_args_to_parser adds --headless, --num_envs, etc., but those values are not applied to SimulationManagerCfg here, and open_window() is called unconditionally. This makes --headless ineffective and can break headless runs; wire headless=args.headless (and likely num_envs=args.num_envs) into SimulationManagerCfg, and only open a window when not headless.
| @pytest.mark.skip(reason="Skipping CUDA tests temporarily") | ||
| class TestCPU(EmbodiedEnvTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Skipping CUDA tests temporarily") | ||
| class TestCPURT(EmbodiedEnvTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.skip(reason="Skipping CUDA tests temporarily") | ||
| class TestCUDA(EmbodiedEnvTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation is defined as setup_simulation(self, sim_device, renderer="legacy"), but the test classes call it with render_cfg=..., which will raise TypeError if these tests are ever un-skipped. Pass renderer=... (string) or update the helper to accept a RenderCfg consistently.
| config = SimulationManagerCfg( | ||
| headless=True, | ||
| sim_device=args.device, | ||
| enable_rt=args.enable_rt, | ||
| render_cfg=RenderCfg(renderer=args.renderer), | ||
| physics_dt=1.0 / 100.0, | ||
| num_envs=1, | ||
| arena_space=2.5, | ||
| ) |
There was a problem hiding this comment.
add_env_launcher_args_to_parser provides --headless, but the simulation is always created with headless=True here. If the script is intended to support GUI mode, use headless=args.headless so the CLI flag actually controls window creation.
Co-authored-by: liwenfeng <liwenfeng@dexforce.top>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 86 out of 86 changed files in this pull request and generated 15 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| class TestCameraFastRT(CameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
TestCameraFastRT is also defined twice (CPU and CUDA). The second class overwrites the first, so one variant may not run under pytest. Rename these classes to unique names.
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
There was a problem hiding this comment.
setup_simulation() takes a renderer string, but this test class calls it with render_cfg=..., which will raise an unexpected-keyword TypeError. Either change calls to pass renderer="legacy"/"fast-rt"/... or change setup_simulation() to accept render_cfg: RenderCfg.
| class TestStereoCameraFastRT(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cpu", enable_rt=True) | ||
| self.setup_simulation( | ||
| "cpu", render_cfg=RenderCfg(renderer="fast-rt" if True else "legacy") | ||
| ) |
There was a problem hiding this comment.
TestStereoCameraFastRT is also defined twice (CPU and CUDA). Since Python overwrites the first class with the second, one set of tests may never run. Rename the classes to distinct names.
| class TestStereoCameraRaster(StereoCameraTest): | ||
| def setup_method(self): | ||
| self.setup_simulation("cuda", enable_rt=False) | ||
| self.setup_simulation( | ||
| "cuda", render_cfg=RenderCfg(renderer="fast-rt" if False else "legacy") | ||
| ) |
There was a problem hiding this comment.
This is a second definition of TestStereoCameraRaster; it overwrites the earlier class with the same name, so only one of the CPU/CUDA variants will be collected by pytest. Rename to distinct class names per variant.
| from embodichain.lab.sim import SimulationManager, SimulationManagerCfg | ||
| from embodichain.lab.sim.sensors import StereoCamera, SensorCfg | ||
| import time | ||
| import torch | ||
|
|
There was a problem hiding this comment.
This file now has duplicated imports (torch and SimulationManager are imported twice). It’s harmless at runtime but makes the module harder to maintain; remove the duplicate import block and keep a single canonical import section.
| - ``--renderer``: Enable ray tracing for better visuals | ||
|
|
There was a problem hiding this comment.
The CLI option is now --renderer with explicit choices, but this bullet reads like a boolean toggle. Consider documenting it as --renderer {legacy,hybrid,fast-rt} and explaining what each value does (and/or the default) to match the new argparse contract.
| - ``--renderer``: Enable ray tracing for better visuals | |
| - ``--renderer {legacy,hybrid,fast-rt}``: Select rendering backend (default: ``fast-rt``) | |
| - ``legacy``: Classic rasterized renderer, compatible with older hardware | |
| - ``hybrid``: Mixed rasterization and ray tracing for balanced quality and performance | |
| - ``fast-rt``: Optimized real-time ray tracing for highest visual quality |
| sim_cfg = SimulationManagerCfg( | ||
| width=1920, | ||
| height=1080, | ||
| num_envs=args.num_envs, | ||
| headless=args.headless, | ||
| headless=True, | ||
| physics_dt=1.0 / 100.0, # Physics timestep (100 Hz) | ||
| sim_device=args.device, | ||
| enable_rt=args.enable_rt, # Enable ray tracing for better visuals | ||
| render_cfg=RenderCfg( |
There was a problem hiding this comment.
SimulationManagerCfg is constructed with headless=True regardless of args.headless, but later the script conditionally calls sim.open_window() based on args.headless. This can lead to inconsistent behavior (trying to open a window in a headless sim). Pass headless=args.headless into SimulationManagerCfg to keep the flags consistent.
| gym_env_cfg.sim_cfg.enable_rt = enable_rt | ||
| gym_env_cfg.sim_cfg.gpu_id = local_rank if distributed else gpu_id | ||
| gym_env_cfg.sim_cfg.render_cfg = RenderCfg(renderer=renderer) | ||
| gym_env_cfg.sim_cfg.gpu_id = gpu_id |
There was a problem hiding this comment.
When distributed=True, the process GPU is set via local_rank, but gym_env_cfg.sim_cfg.gpu_id is then overwritten with the config-file gpu_id (not local_rank). This can desync the engine GPU selection from the actual process device. Keep gpu_id=local_rank in distributed mode (or at least don’t override the earlier gpu_index).
| gym_env_cfg.sim_cfg.gpu_id = gpu_id | |
| if device.type != "cuda" and hasattr(gym_env_cfg.sim_cfg, "gpu_id"): | |
| gym_env_cfg.sim_cfg.gpu_id = gpu_id |
| node.set_translation(translation) | ||
| elif flag == (TransformMask.TRANSFORM_LOCAL | TransformMask.TRANSFORM_R): | ||
| node.set_rotation_rpy(rotation) | ||
| # convert to numpy 4x4 matrix |
There was a problem hiding this comment.
There’s an indentation issue on the comment at line 239 (# convert to numpy 4x4 matrix) — it’s indented as if it were inside the previous if block, but it isn’t. This is misleading and may indicate accidental whitespace changes; align it with the surrounding code.
| # convert to numpy 4x4 matrix | |
| # convert to numpy 4x4 matrix |
| headless: bool = False | ||
| """Whether to run the simulation in headless mode (no Window).""" | ||
|
|
||
| enable_rt: bool = False | ||
| """Whether to enable ray tracing rendering.""" | ||
|
|
||
| enable_denoiser: bool = True | ||
| """Whether to enable denoising for ray tracing rendering.""" | ||
|
|
||
| spp: int = 64 | ||
| """Samples per pixel for ray tracing rendering. This parameter is only valid when ray tracing is enabled and enable_denoiser is False.""" | ||
| render_cfg: RenderCfg = field(default_factory=RenderCfg) | ||
| """The rendering configuration parameters.""" |
There was a problem hiding this comment.
SimulationManagerCfg.enable_rt/enable_denoiser/spp were removed in favor of render_cfg, but there are still call sites in the repo passing enable_rt (e.g., embodichain/lab/scripts/preview_asset.py:63-66, scripts/tutorials/sim/create_cloth.py:99-106, examples/sim/demo/pick_up_cloth.py:81-86). These will now crash with unexpected-keyword errors; either update those call sites in this PR or provide a backwards-compatible alias/deprecation path in SimulationManagerCfg.
Description
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
black .command to format the code base.