-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Adds Raycaster with tracking for dynamic meshes #3298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Mayankm96
merged 177 commits into
isaac-sim:main
from
renezurbruegg:feature/multi-mesh-ray-caster
Dec 16, 2025
Merged
Changes from 170 commits
Commits
Show all changes
177 commits
Select commit
Hold shift + click to select a range
c9bcd3b
Adds multi-mesh raycaster from Orbit (#4)
pascal-roth b7c172f
Fixes the number of meshes for dynamic raycasting with an regex expre…
pascal-roth e1a9124
Separates our multi-mesh raycaster as its own file (#63)
pascal-roth 4ca82f6
Removes ClassVar `meshes` and `mesh_views` from MultiMeshRayCatser an…
pascal-roth d13331c
forgotten merge
pascal-roth 3f5d008
revert classvar changes and apply formatter
pascal-roth 5decd09
revert device change in ray caster
pascal-roth f585a31
update tests from unittest to pytest
pascal-roth 7242ea2
add initial benchmark scripts and formatter
pascal-roth 2c6c607
Fix check script
renezurbruegg 86418d3
Manually merging pascal-roth changes from static vars branch
renezurbruegg fa6b498
remove wrongfully pushed wheels
renezurbruegg 8beb0d2
Merge changes from #90 - dropping support for cache_combined_meshes …
renezurbruegg 5ca6e6e
add memory benchmark
renezurbruegg eefcb3a
fix garbage collection issue
renezurbruegg 6eda9c8
Add initial offset if mesh transform track is set to false
renezurbruegg 0712ee5
avoid visualization when ray hits is not instantiated yet
renezurbruegg 004184e
Add resolve world pose
renezurbruegg 9287efe
Change benchmark to sphere. Add different amount of faces and multi i…
renezurbruegg f80e384
fix local offsets
renezurbruegg bcd747a
add example allegro hand
renezurbruegg 4f6c772
Fix local offsets
renezurbruegg f98150e
Added regex lookups
renezurbruegg 5940b98
Add num assets flag.
renezurbruegg 500931c
Add anymal demo
renezurbruegg 586858c
Add scale randomizations. Drop support for instancer meshes
renezurbruegg 4d167ec
add shapes
renezurbruegg 5b8563d
update benchmark scripts for different use cases - WIP
renezurbruegg 17b5819
cleanup tests
renezurbruegg b3747c4
Add is shared functionality back
renezurbruegg ad7cbfc
change default
renezurbruegg e2e7f9e
cleanup
renezurbruegg 8a37d61
Cleanup benchmark. Add flag to specify if meshse should be referenced
renezurbruegg 3a6a242
remove old scripts
renezurbruegg 16cd7c2
lint
renezurbruegg 8efd58d
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth 7509d45
Update source/isaaclab/isaaclab/sensors/ray_caster/ray_caster.py
renezurbruegg 4e40239
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 88da283
Move move merge_prim_meshes to RaycastTargetCfg
renezurbruegg 13ba4e2
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg abbc8ed
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg df9f660
Update source/isaaclab/isaaclab/sensors/utils.py
renezurbruegg f2894a0
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 3eaecb5
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 0a47268
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg b27caa5
Move track_mesh_transforms to target config
renezurbruegg 39fa91b
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 82f72ce
Add specification about string targets
renezurbruegg 332b8be
improve docstrings
renezurbruegg f5e91cf
lint
renezurbruegg 7c98e27
remove absolute paths
renezurbruegg a048c16
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 123cd01
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg bfeaf48
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 532b1f6
Update docstrings
renezurbruegg cc7dfee
minor fixes for track mesh transforms
renezurbruegg 2ec9bd7
Improve docstring
renezurbruegg 2743d03
lint
renezurbruegg b44eaf2
Migrating to pytest
renezurbruegg 7ce6d6d
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 6066474
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 5984c82
Update source/isaaclab/isaaclab/sensors/utils.py
renezurbruegg 09f17f5
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 3a2de0d
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 7b39736
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg e9fb9a1
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 43da984
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 12de1fa
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 1635968
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg 115ce9f
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg 636406b
lint
renezurbruegg 8ac9ad6
move track_mesh_transforms to target cfg
renezurbruegg 404bc69
migrate to pytest
renezurbruegg eef0399
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg d9a5f3a
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg d196bbd
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg f094b27
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg c764f0c
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg bccb267
removes ununsed files
Mayankm96 3d7c8f7
adds test for instanced proxies
Mayankm96 ab7eac2
runs formatter
Mayankm96 8ae7743
adds resolve prim funcs
Mayankm96 e6cbead
Apply suggestion from @Copilot
Mayankm96 796c1a4
updates changelog
Mayankm96 9c34e95
Merge branch 'feature/prim-prop-funcs' of github.com:Mayankm96/IsaacL…
Mayankm96 41c5f7a
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 371785d
Move utils to sim_utils
renezurbruegg 90ef912
rename to obtain_world_pose_from_view
renezurbruegg 616d677
lint
renezurbruegg 2d1c3c2
fix tests
renezurbruegg a289d1c
lint
renezurbruegg 20772f4
Remove is global configuration
renezurbruegg 04a7185
lint
renezurbruegg 5c927da
Merge branch 'main' into feature/prim-prop-funcs
kellyguo11 7864b21
Merge branch 'main' into fix/instanced-proxies
kellyguo11 dd61d3e
revert changes to merge prs
renezurbruegg 82819d8
Merge branch 'sim_utils' into feature/multi-mesh-ray-caster
renezurbruegg f5af366
Merge branch 'prim_utils' into feature/multi-mesh-ray-caster
renezurbruegg 50fc172
fix typo
renezurbruegg c891112
Update trimesh functions
renezurbruegg 85fbe94
Merge branch 'main' into feature/multi-mesh-ray-caster
jtigue-bdai c251913
Also lookup physics prim for sensor origin
renezurbruegg 22040a7
fix merge issue
renezurbruegg 0c2955b
update benchmarking
renezurbruegg 41924f2
formatter and fix multi mesh raycaster
pascal-roth a194b3b
image based benchmark
pascal-roth 9a0f5ab
fixes
pascal-roth 80908ed
fix md
pascal-roth 30ceb59
fix data type name
pascal-roth 4439744
fix benchmark ray caster
pascal-roth 0a832b5
plot scripts
pascal-roth e1a5780
update plot script
pascal-roth c09b9d0
update
pascal-roth b2103cb
Create agg. plot script
renezurbruegg 335dc71
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg 3c5bd81
updated plotting scripts
renezurbruegg 0d3f5be
Change output dir, disable non cached tests
renezurbruegg ee12bb3
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
pascal-roth bc6886f
allow plot single nav environment
pascal-roth 8d84fb1
refactor camera benchmark
pascal-roth 8796999
add bash scripts
renezurbruegg 9b2871b
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg 64a9a61
add fps plot
renezurbruegg 04cd1c5
bugfix
pascal-roth ee857ce
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth dfc9283
Add more mesh types
renezurbruegg 8b2de9b
Add generic fan triangulation
renezurbruegg c97b616
Merge remote-tracking branch 'public/main' into upstream/feature/mult…
renezurbruegg 0dbb2da
Remove unusued benchmarks
renezurbruegg ddcc3d8
lint
renezurbruegg dfd08df
remove benchmarks
renezurbruegg 193e02a
fix clipping depth camera and formatter
pascal-roth f87ac8b
Merge remote-tracking branch 'public/main' into upstream/feature/mult…
renezurbruegg 9ddab8f
Add example for camera raycaster
renezurbruegg 0f7635e
Add Raycaster Data to init
renezurbruegg 5f4b475
Remove unusued Triggered
renezurbruegg 412cf7a
Fix docstring
renezurbruegg ea6f322
Fix docstring
renezurbruegg 2b6421e
always use env_ids as indexing tensor
renezurbruegg f5ca3e3
fix docs
renezurbruegg b467e79
update typing
renezurbruegg 362e358
add warning on duplicate targets
renezurbruegg 657d8f2
remove unused prim lookup
renezurbruegg 92750b2
Address remaining PR comments
renezurbruegg 766bf98
remove typo
renezurbruegg 2e152f0
downgrade gymnasium
renezurbruegg 8c59a07
Fix device and Warp Camera prim
renezurbruegg 4b05304
revert change
renezurbruegg 153894b
update quat_w
renezurbruegg 2c4040e
fix docstring
renezurbruegg 6a1d06e
fix mesh tensor shape for single raycast
renezurbruegg 685885e
fix warp camera
renezurbruegg 98ec5c5
Fix race conditions
renezurbruegg 35c5c1f
Lint
renezurbruegg 4fed595
Apply suggestions from code review
renezurbruegg c3115cd
Add check for ray alignment
renezurbruegg ae34fa7
lint
renezurbruegg dadec71
Move obtain_prim pose to custom utils
renezurbruegg 571e4e9
Merge branch 'upstream/feature/multi-mesh-ray-caster' into feature/mu…
renezurbruegg 80542aa
lint
renezurbruegg 8bedf43
Apply suggestions from code review
renezurbruegg c62ae1d
minor changes from code review
renezurbruegg aba6b95
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg c4218df
Typos and formatting
renezurbruegg f525ff1
Move mesh_views to parent class
renezurbruegg 6e89052
make order alphabetical
renezurbruegg b7f06dc
Make assignment more clear
renezurbruegg c3dcb2b
Fix tests
renezurbruegg 2c16763
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 e786cfe
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 9de7ddf
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth d8be9e2
remove omni.log, fix env_ids bug, formatter
pascal-roth 1c546f0
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
pascal-roth 5cacc70
rename target_prim_expr to prim_expr
pascal-roth 76d2353
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
pascal-roth 919b39e
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 fcd9110
Clean up imports in ray_caster_camera.py
kellyguo11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,296 @@ | ||
| # Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
|
|
||
| """Example on using the MultiMesh Raycaster sensor. | ||
|
|
||
| Usage: | ||
| `python scripts/demos/sensors/multi_mesh_raycaster.py --num_envs 16 --asset_type <allegro_hand|anymal_d|multi>` | ||
| """ | ||
|
|
||
| import argparse | ||
|
|
||
| from isaaclab.app import AppLauncher | ||
|
|
||
| # add argparse arguments | ||
| parser = argparse.ArgumentParser(description="Example on using the raycaster sensor.") | ||
| parser.add_argument("--num_envs", type=int, default=16, help="Number of environments to spawn.") | ||
| parser.add_argument( | ||
| "--asset_type", | ||
| type=str, | ||
| default="allegro_hand", | ||
| help="Asset type to use.", | ||
| choices=["allegro_hand", "anymal_d", "multi"], | ||
| ) | ||
| # append AppLauncher cli args | ||
| AppLauncher.add_app_launcher_args(parser) | ||
| # parse the arguments | ||
| args_cli = parser.parse_args() | ||
|
|
||
| # launch omniverse app | ||
| app_launcher = AppLauncher(args_cli) | ||
| simulation_app = app_launcher.app | ||
|
|
||
| """Rest everything follows.""" | ||
|
|
||
| import random | ||
| import torch | ||
|
|
||
| import omni.usd | ||
| from pxr import Gf, Sdf | ||
|
|
||
| ## | ||
| # Pre-defined configs | ||
| ## | ||
| from isaaclab_assets.robots.allegro import ALLEGRO_HAND_CFG | ||
| from isaaclab_assets.robots.anymal import ANYMAL_D_CFG | ||
|
|
||
| import isaaclab.sim as sim_utils | ||
| from isaaclab.assets import Articulation, AssetBaseCfg, RigidObjectCfg | ||
| from isaaclab.markers.config import VisualizationMarkersCfg | ||
| from isaaclab.scene import InteractiveScene, InteractiveSceneCfg | ||
| from isaaclab.sensors.ray_caster import MultiMeshRayCasterCfg, patterns | ||
| from isaaclab.utils import configclass | ||
| from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR | ||
|
|
||
| RAY_CASTER_MARKER_CFG = VisualizationMarkersCfg( | ||
| markers={ | ||
| "hit": sim_utils.SphereCfg( | ||
| radius=0.01, | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0)), | ||
| ), | ||
| }, | ||
| ) | ||
|
|
||
|
|
||
| if args_cli.asset_type == "allegro_hand": | ||
| asset_cfg = ALLEGRO_HAND_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot") | ||
| ray_caster_cfg = MultiMeshRayCasterCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot", | ||
| update_period=1 / 60, | ||
| offset=MultiMeshRayCasterCfg.OffsetCfg(pos=(0, -0.1, 0.3)), | ||
| mesh_prim_paths=[ | ||
| "/World/Ground", | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/thumb_link_.*/visuals_xform"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/index_link.*/visuals_xform"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg( | ||
| target_prim_expr="{ENV_REGEX_NS}/Robot/middle_link_.*/visuals_xform" | ||
| ), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/ring_link_.*/visuals_xform"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/palm_link/visuals_xform"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/allegro_mount/visuals_xform"), | ||
| ], | ||
| ray_alignment="world", | ||
| pattern_cfg=patterns.GridPatternCfg(resolution=0.005, size=(0.4, 0.4), direction=(0, 0, -1)), | ||
| debug_vis=not args_cli.headless, | ||
| visualizer_cfg=RAY_CASTER_MARKER_CFG.replace(prim_path="/Visuals/RayCaster"), | ||
| ) | ||
|
|
||
| elif args_cli.asset_type == "anymal_d": | ||
| asset_cfg = ANYMAL_D_CFG.replace(prim_path="{ENV_REGEX_NS}/Robot") | ||
| ray_caster_cfg = MultiMeshRayCasterCfg( | ||
| prim_path="{ENV_REGEX_NS}/Robot", | ||
| update_period=1 / 60, | ||
| offset=MultiMeshRayCasterCfg.OffsetCfg(pos=(0, -0.1, 0.3)), | ||
| mesh_prim_paths=[ | ||
| "/World/Ground", | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/LF_.*/visuals"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/RF_.*/visuals"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/LH_.*/visuals"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/RH_.*/visuals"), | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Robot/base/visuals"), | ||
| ], | ||
| ray_alignment="world", | ||
| pattern_cfg=patterns.GridPatternCfg(resolution=0.02, size=(2.5, 2.5), direction=(0, 0, -1)), | ||
| debug_vis=not args_cli.headless, | ||
| visualizer_cfg=RAY_CASTER_MARKER_CFG.replace(prim_path="/Visuals/RayCaster"), | ||
| ) | ||
|
|
||
| elif args_cli.asset_type == "multi": | ||
| asset_cfg = RigidObjectCfg( | ||
| prim_path="{ENV_REGEX_NS}/Object", | ||
| spawn=sim_utils.MultiAssetSpawnerCfg( | ||
| assets_cfg=[ | ||
| sim_utils.CuboidCfg( | ||
| size=(0.3, 0.3, 0.3), | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 0.0), metallic=0.2), | ||
| ), | ||
| sim_utils.SphereCfg( | ||
| radius=0.3, | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 0.0, 1.0), metallic=0.2), | ||
| ), | ||
| sim_utils.CylinderCfg( | ||
| radius=0.2, | ||
| height=0.5, | ||
| axis="Y", | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.0, 1.0, 0.0), metallic=0.2), | ||
| ), | ||
| sim_utils.CapsuleCfg( | ||
| radius=0.15, | ||
| height=0.5, | ||
| axis="Z", | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 1.0, 0.0), metallic=0.2), | ||
| ), | ||
| sim_utils.ConeCfg( | ||
| radius=0.2, | ||
| height=0.5, | ||
| axis="Z", | ||
| visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(1.0, 0.0, 1.0), metallic=0.2), | ||
| ), | ||
| ], | ||
| random_choice=True, | ||
| rigid_props=sim_utils.RigidBodyPropertiesCfg( | ||
| solver_position_iteration_count=4, solver_velocity_iteration_count=0 | ||
| ), | ||
| mass_props=sim_utils.MassPropertiesCfg(mass=1.0), | ||
| collision_props=sim_utils.CollisionPropertiesCfg(), | ||
| ), | ||
| init_state=RigidObjectCfg.InitialStateCfg(pos=(0.0, 0.0, 2.0)), | ||
| ) | ||
| ray_caster_cfg = MultiMeshRayCasterCfg( | ||
| prim_path="{ENV_REGEX_NS}/Object", | ||
| update_period=1 / 60, | ||
| offset=MultiMeshRayCasterCfg.OffsetCfg(pos=(0, 0.0, 0.6)), | ||
| mesh_prim_paths=[ | ||
| "/World/Ground", | ||
| MultiMeshRayCasterCfg.RaycastTargetCfg(target_prim_expr="{ENV_REGEX_NS}/Object"), | ||
| ], | ||
| ray_alignment="world", | ||
| pattern_cfg=patterns.GridPatternCfg(resolution=0.01, size=(0.6, 0.6), direction=(0, 0, -1)), | ||
| debug_vis=not args_cli.headless, | ||
| visualizer_cfg=RAY_CASTER_MARKER_CFG.replace(prim_path="/Visuals/RayCaster"), | ||
| ) | ||
| else: | ||
| raise ValueError(f"Unknown asset type: {args_cli.asset_type}") | ||
|
|
||
|
|
||
| @configclass | ||
| class RaycasterSensorSceneCfg(InteractiveSceneCfg): | ||
| """Design the scene with sensors on the asset.""" | ||
|
|
||
| # ground plane | ||
| ground = AssetBaseCfg( | ||
| prim_path="/World/Ground", | ||
| spawn=sim_utils.UsdFileCfg( | ||
| usd_path=f"{ISAAC_NUCLEUS_DIR}/Environments/Terrains/rough_plane.usd", | ||
| scale=(1, 1, 1), | ||
| ), | ||
| ) | ||
|
|
||
| # lights | ||
| dome_light = AssetBaseCfg( | ||
| prim_path="/World/Light", spawn=sim_utils.DomeLightCfg(intensity=3000.0, color=(0.75, 0.75, 0.75)) | ||
| ) | ||
|
|
||
| # asset | ||
| asset = asset_cfg | ||
| # ray caster | ||
| ray_caster = ray_caster_cfg | ||
|
|
||
|
|
||
| def randomize_shape_color(prim_path_expr: str): | ||
| """Randomize the color of the geometry.""" | ||
|
|
||
| # acquire stage | ||
| stage = omni.usd.get_context().get_stage() | ||
| # resolve prim paths for spawning and cloning | ||
| prim_paths = sim_utils.find_matching_prim_paths(prim_path_expr) | ||
| # manually clone prims if the source prim path is a regex expression | ||
|
|
||
| with Sdf.ChangeBlock(): | ||
| for prim_path in prim_paths: | ||
| print("Applying prim scale to:", prim_path) | ||
| # spawn single instance | ||
| prim_spec = Sdf.CreatePrimInLayer(stage.GetRootLayer(), prim_path) | ||
|
|
||
| # DO YOUR OWN OTHER KIND OF RANDOMIZATION HERE! | ||
| # Note: Just need to acquire the right attribute about the property you want to set | ||
| # Here is an example on setting color randomly | ||
| color_spec = prim_spec.GetAttributeAtPath(prim_path + "/geometry/material/Shader.inputs:diffuseColor") | ||
| color_spec.default = Gf.Vec3f(random.random(), random.random(), random.random()) | ||
|
|
||
| # randomize scale | ||
| scale_spec = prim_spec.GetAttributeAtPath(prim_path + ".xformOp:scale") | ||
| scale_spec.default = Gf.Vec3f(random.uniform(0.5, 1.5), random.uniform(0.5, 1.5), random.uniform(0.5, 1.5)) | ||
|
|
||
|
|
||
| def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene): | ||
| """Run the simulator.""" | ||
| # Define simulation stepping | ||
| sim_dt = sim.get_physics_dt() | ||
| sim_time = 0.0 | ||
| count = 0 | ||
|
|
||
| # Simulate physics | ||
| while simulation_app.is_running(): | ||
|
|
||
| if count % 500 == 0: | ||
| # reset counter | ||
| count = 0 | ||
| # reset the scene entities | ||
| # root state | ||
| root_state = scene["asset"].data.default_root_state.clone() | ||
| root_state[:, :3] += scene.env_origins | ||
| scene["asset"].write_root_pose_to_sim(root_state[:, :7]) | ||
| scene["asset"].write_root_velocity_to_sim(root_state[:, 7:]) | ||
|
|
||
| if isinstance(scene["asset"], Articulation): | ||
| # set joint positions with some noise | ||
| joint_pos, joint_vel = ( | ||
| scene["asset"].data.default_joint_pos.clone(), | ||
| scene["asset"].data.default_joint_vel.clone(), | ||
| ) | ||
| joint_pos += torch.rand_like(joint_pos) * 0.1 | ||
| scene["asset"].write_joint_state_to_sim(joint_pos, joint_vel) | ||
| # clear internal buffers | ||
| scene.reset() | ||
| print("[INFO]: Resetting Asset state...") | ||
|
|
||
| if isinstance(scene["asset"], Articulation): | ||
| # -- generate actions/commands | ||
| targets = scene["asset"].data.default_joint_pos + 5 * ( | ||
| torch.rand_like(scene["asset"].data.default_joint_pos) - 0.5 | ||
| ) | ||
| # -- apply action to the asset | ||
| scene["asset"].set_joint_position_target(targets) | ||
| # -- write data to sim | ||
| scene.write_data_to_sim() | ||
| # perform step | ||
| sim.step() | ||
| # update sim-time | ||
| sim_time += sim_dt | ||
| count += 1 | ||
| # update buffers | ||
| scene.update(sim_dt) | ||
|
|
||
|
|
||
| def main(): | ||
| """Main function.""" | ||
|
|
||
| # Initialize the simulation context | ||
| sim_cfg = sim_utils.SimulationCfg(dt=0.005, device=args_cli.device) | ||
| sim = sim_utils.SimulationContext(sim_cfg) | ||
| # Set main camera | ||
| sim.set_camera_view(eye=[3.5, 3.5, 3.5], target=[0.0, 0.0, 0.0]) | ||
| # design scene | ||
| scene_cfg = RaycasterSensorSceneCfg(num_envs=args_cli.num_envs, env_spacing=2.0, replicate_physics=False) | ||
| scene = InteractiveScene(scene_cfg) | ||
|
|
||
| if args_cli.asset_type == "multi": | ||
| randomize_shape_color(scene_cfg.asset.prim_path.format(ENV_REGEX_NS="/World/envs/env_.*")) | ||
|
|
||
| # Play the simulator | ||
| sim.reset() | ||
| # Now we are ready! | ||
| print("[INFO]: Setup complete...") | ||
| # Run the simulator | ||
| run_simulator(sim, scene) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| # run the main function | ||
| main() | ||
| # close sim app | ||
| simulation_app.close() | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.