Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 Jul 25, 2024
b7c172f
Fixes the number of meshes for dynamic raycasting with an regex expre…
pascal-roth Oct 23, 2024
e1a9124
Separates our multi-mesh raycaster as its own file (#63)
pascal-roth Feb 8, 2025
4ca82f6
Removes ClassVar `meshes` and `mesh_views` from MultiMeshRayCatser an…
pascal-roth Feb 10, 2025
d13331c
forgotten merge
pascal-roth Aug 9, 2025
3f5d008
revert classvar changes and apply formatter
pascal-roth Aug 9, 2025
5decd09
revert device change in ray caster
pascal-roth Aug 9, 2025
f585a31
update tests from unittest to pytest
pascal-roth Aug 17, 2025
7242ea2
add initial benchmark scripts and formatter
pascal-roth Aug 17, 2025
2c6c607
Fix check script
renezurbruegg Aug 17, 2025
86418d3
Manually merging pascal-roth changes from static vars branch
renezurbruegg Aug 17, 2025
fa6b498
remove wrongfully pushed wheels
renezurbruegg Aug 17, 2025
8beb0d2
Merge changes from #90 - dropping support for cache_combined_meshes …
renezurbruegg Aug 17, 2025
5ca6e6e
add memory benchmark
renezurbruegg Aug 18, 2025
eefcb3a
fix garbage collection issue
renezurbruegg Aug 18, 2025
6eda9c8
Add initial offset if mesh transform track is set to false
renezurbruegg Aug 23, 2025
0712ee5
avoid visualization when ray hits is not instantiated yet
renezurbruegg Aug 23, 2025
004184e
Add resolve world pose
renezurbruegg Aug 23, 2025
9287efe
Change benchmark to sphere. Add different amount of faces and multi i…
renezurbruegg Aug 23, 2025
f80e384
fix local offsets
renezurbruegg Aug 24, 2025
bcd747a
add example allegro hand
renezurbruegg Aug 24, 2025
4f6c772
Fix local offsets
renezurbruegg Aug 24, 2025
f98150e
Added regex lookups
renezurbruegg Aug 24, 2025
5940b98
Add num assets flag.
renezurbruegg Aug 24, 2025
500931c
Add anymal demo
renezurbruegg Aug 24, 2025
586858c
Add scale randomizations. Drop support for instancer meshes
renezurbruegg Aug 26, 2025
4d167ec
add shapes
renezurbruegg Aug 26, 2025
5b8563d
update benchmark scripts for different use cases - WIP
renezurbruegg Aug 26, 2025
17b5819
cleanup tests
renezurbruegg Aug 27, 2025
b3747c4
Add is shared functionality back
renezurbruegg Aug 27, 2025
ad7cbfc
change default
renezurbruegg Aug 27, 2025
e2e7f9e
cleanup
renezurbruegg Aug 27, 2025
8a37d61
Cleanup benchmark. Add flag to specify if meshse should be referenced
renezurbruegg Aug 28, 2025
3a6a242
remove old scripts
renezurbruegg Aug 28, 2025
16cd7c2
lint
renezurbruegg Aug 29, 2025
8efd58d
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth Aug 29, 2025
7509d45
Update source/isaaclab/isaaclab/sensors/ray_caster/ray_caster.py
renezurbruegg Aug 29, 2025
4e40239
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Aug 29, 2025
88da283
Move move merge_prim_meshes to RaycastTargetCfg
renezurbruegg Sep 5, 2025
13ba4e2
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
abbc8ed
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
df9f660
Update source/isaaclab/isaaclab/sensors/utils.py
renezurbruegg Sep 5, 2025
f2894a0
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
3eaecb5
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
0a47268
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
b27caa5
Move track_mesh_transforms to target config
renezurbruegg Sep 5, 2025
39fa91b
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
82f72ce
Add specification about string targets
renezurbruegg Sep 5, 2025
332b8be
improve docstrings
renezurbruegg Sep 5, 2025
f5e91cf
lint
renezurbruegg Sep 5, 2025
7c98e27
remove absolute paths
renezurbruegg Sep 5, 2025
a048c16
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
123cd01
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
bfeaf48
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
532b1f6
Update docstrings
renezurbruegg Sep 5, 2025
cc7dfee
minor fixes for track mesh transforms
renezurbruegg Sep 5, 2025
2ec9bd7
Improve docstring
renezurbruegg Sep 5, 2025
2743d03
lint
renezurbruegg Sep 5, 2025
b44eaf2
Migrating to pytest
renezurbruegg Sep 5, 2025
7ce6d6d
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
6066474
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
5984c82
Update source/isaaclab/isaaclab/sensors/utils.py
renezurbruegg Sep 5, 2025
09f17f5
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
3a2de0d
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
7b39736
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
e9fb9a1
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
43da984
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
12de1fa
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
1635968
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 5, 2025
115ce9f
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg Sep 5, 2025
636406b
lint
renezurbruegg Sep 5, 2025
8ac9ad6
move track_mesh_transforms to target cfg
renezurbruegg Sep 5, 2025
404bc69
migrate to pytest
renezurbruegg Sep 5, 2025
eef0399
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 6, 2025
d9a5f3a
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 6, 2025
d196bbd
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 6, 2025
f094b27
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 6, 2025
c764f0c
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
renezurbruegg Sep 6, 2025
bccb267
removes ununsed files
Mayankm96 Sep 6, 2025
3d7c8f7
adds test for instanced proxies
Mayankm96 Sep 6, 2025
ab7eac2
runs formatter
Mayankm96 Sep 6, 2025
8ae7743
adds resolve prim funcs
Mayankm96 Sep 6, 2025
e6cbead
Apply suggestion from @Copilot
Mayankm96 Sep 6, 2025
796c1a4
updates changelog
Mayankm96 Sep 6, 2025
9c34e95
Merge branch 'feature/prim-prop-funcs' of github.com:Mayankm96/IsaacL…
Mayankm96 Sep 6, 2025
41c5f7a
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 Sep 7, 2025
371785d
Move utils to sim_utils
renezurbruegg Sep 7, 2025
90ef912
rename to obtain_world_pose_from_view
renezurbruegg Sep 7, 2025
616d677
lint
renezurbruegg Sep 7, 2025
2d1c3c2
fix tests
renezurbruegg Sep 7, 2025
a289d1c
lint
renezurbruegg Sep 7, 2025
20772f4
Remove is global configuration
renezurbruegg Sep 8, 2025
04a7185
lint
renezurbruegg Sep 8, 2025
5c927da
Merge branch 'main' into feature/prim-prop-funcs
kellyguo11 Sep 8, 2025
7864b21
Merge branch 'main' into fix/instanced-proxies
kellyguo11 Sep 8, 2025
dd61d3e
revert changes to merge prs
renezurbruegg Sep 9, 2025
82819d8
Merge branch 'sim_utils' into feature/multi-mesh-ray-caster
renezurbruegg Sep 9, 2025
f5af366
Merge branch 'prim_utils' into feature/multi-mesh-ray-caster
renezurbruegg Sep 9, 2025
50fc172
fix typo
renezurbruegg Sep 9, 2025
c891112
Update trimesh functions
renezurbruegg Sep 9, 2025
85fbe94
Merge branch 'main' into feature/multi-mesh-ray-caster
jtigue-bdai Sep 9, 2025
c251913
Also lookup physics prim for sensor origin
renezurbruegg Sep 16, 2025
22040a7
fix merge issue
renezurbruegg Sep 16, 2025
0c2955b
update benchmarking
renezurbruegg Sep 16, 2025
41924f2
formatter and fix multi mesh raycaster
pascal-roth Sep 18, 2025
a194b3b
image based benchmark
pascal-roth Sep 19, 2025
9a0f5ab
fixes
pascal-roth Sep 19, 2025
80908ed
fix md
pascal-roth Sep 19, 2025
30ceb59
fix data type name
pascal-roth Sep 19, 2025
4439744
fix benchmark ray caster
pascal-roth Sep 21, 2025
0a832b5
plot scripts
pascal-roth Sep 22, 2025
e1a5780
update plot script
pascal-roth Sep 22, 2025
c09b9d0
update
pascal-roth Sep 22, 2025
b2103cb
Create agg. plot script
renezurbruegg Sep 22, 2025
335dc71
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg Sep 22, 2025
3c5bd81
updated plotting scripts
renezurbruegg Sep 23, 2025
0d3f5be
Change output dir, disable non cached tests
renezurbruegg Sep 23, 2025
ee12bb3
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
pascal-roth Sep 23, 2025
bc6886f
allow plot single nav environment
pascal-roth Sep 23, 2025
8d84fb1
refactor camera benchmark
pascal-roth Sep 24, 2025
8796999
add bash scripts
renezurbruegg Sep 24, 2025
9b2871b
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg Sep 24, 2025
64a9a61
add fps plot
renezurbruegg Sep 25, 2025
04cd1c5
bugfix
pascal-roth Sep 26, 2025
ee857ce
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth Sep 26, 2025
dfc9283
Add more mesh types
renezurbruegg Oct 10, 2025
8b2de9b
Add generic fan triangulation
renezurbruegg Oct 10, 2025
c97b616
Merge remote-tracking branch 'public/main' into upstream/feature/mult…
renezurbruegg Oct 10, 2025
0dbb2da
Remove unusued benchmarks
renezurbruegg Oct 10, 2025
ddcc3d8
lint
renezurbruegg Oct 10, 2025
dfd08df
remove benchmarks
renezurbruegg Oct 10, 2025
193e02a
fix clipping depth camera and formatter
pascal-roth Oct 22, 2025
f87ac8b
Merge remote-tracking branch 'public/main' into upstream/feature/mult…
renezurbruegg Oct 25, 2025
9ddab8f
Add example for camera raycaster
renezurbruegg Oct 25, 2025
0f7635e
Add Raycaster Data to init
renezurbruegg Oct 25, 2025
5f4b475
Remove unusued Triggered
renezurbruegg Oct 25, 2025
412cf7a
Fix docstring
renezurbruegg Oct 25, 2025
ea6f322
Fix docstring
renezurbruegg Oct 25, 2025
2b6421e
always use env_ids as indexing tensor
renezurbruegg Oct 25, 2025
f5ca3e3
fix docs
renezurbruegg Oct 25, 2025
b467e79
update typing
renezurbruegg Oct 25, 2025
362e358
add warning on duplicate targets
renezurbruegg Oct 25, 2025
657d8f2
remove unused prim lookup
renezurbruegg Oct 25, 2025
92750b2
Address remaining PR comments
renezurbruegg Oct 25, 2025
766bf98
remove typo
renezurbruegg Oct 25, 2025
2e152f0
downgrade gymnasium
renezurbruegg Oct 25, 2025
8c59a07
Fix device and Warp Camera prim
renezurbruegg Oct 25, 2025
4b05304
revert change
renezurbruegg Oct 25, 2025
153894b
update quat_w
renezurbruegg Oct 25, 2025
2c4040e
fix docstring
renezurbruegg Oct 25, 2025
6a1d06e
fix mesh tensor shape for single raycast
renezurbruegg Oct 25, 2025
685885e
fix warp camera
renezurbruegg Oct 25, 2025
98ec5c5
Fix race conditions
renezurbruegg Oct 26, 2025
35c5c1f
Lint
renezurbruegg Oct 26, 2025
4fed595
Apply suggestions from code review
renezurbruegg Oct 26, 2025
c3115cd
Add check for ray alignment
renezurbruegg Oct 26, 2025
ae34fa7
lint
renezurbruegg Oct 26, 2025
dadec71
Move obtain_prim pose to custom utils
renezurbruegg Oct 26, 2025
571e4e9
Merge branch 'upstream/feature/multi-mesh-ray-caster' into feature/mu…
renezurbruegg Oct 26, 2025
80542aa
lint
renezurbruegg Oct 26, 2025
8bedf43
Apply suggestions from code review
renezurbruegg Oct 26, 2025
c62ae1d
minor changes from code review
renezurbruegg Oct 26, 2025
aba6b95
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
renezurbruegg Oct 26, 2025
c4218df
Typos and formatting
renezurbruegg Oct 26, 2025
f525ff1
Move mesh_views to parent class
renezurbruegg Oct 26, 2025
6e89052
make order alphabetical
renezurbruegg Oct 26, 2025
b7f06dc
Make assignment more clear
renezurbruegg Oct 26, 2025
c3dcb2b
Fix tests
renezurbruegg Oct 26, 2025
2c16763
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 Nov 6, 2025
e786cfe
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 Nov 11, 2025
9de7ddf
Merge branch 'main' into feature/multi-mesh-ray-caster
pascal-roth Nov 18, 2025
d8be9e2
remove omni.log, fix env_ids bug, formatter
pascal-roth Nov 18, 2025
1c546f0
Update source/isaaclab/isaaclab/sensors/ray_caster/multi_mesh_ray_cas…
pascal-roth Nov 18, 2025
5cacc70
rename target_prim_expr to prim_expr
pascal-roth Nov 18, 2025
76d2353
Merge branch 'feature/multi-mesh-ray-caster' of github.com:renezurbru…
pascal-roth Nov 18, 2025
919b39e
Merge branch 'main' into feature/multi-mesh-ray-caster
kellyguo11 Dec 10, 2025
fcd9110
Clean up imports in ray_caster_camera.py
kellyguo11 Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/source/api/lab/isaaclab.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
dict
interpolation
math
mesh
modifiers
noise
string
Expand Down Expand Up @@ -89,6 +90,14 @@ Math operations
:inherited-members:
:show-inheritance:

Mesh operations
~~~~~~~~~~~~~~~

.. automodule:: isaaclab.utils.mesh
:members:
:imported-members:
:show-inheritance:

Modifier operations
~~~~~~~~~~~~~~~~~~~

Expand Down
294 changes: 294 additions & 0 deletions scripts/demos/sensors/multi_mesh_raycaster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
# 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(prim_expr="{ENV_REGEX_NS}/Robot/thumb_link_.*/visuals_xform"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/index_link.*/visuals_xform"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/middle_link_.*/visuals_xform"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/ring_link_.*/visuals_xform"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/palm_link/visuals_xform"),
MultiMeshRayCasterCfg.RaycastTargetCfg(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(prim_expr="{ENV_REGEX_NS}/Robot/LF_.*/visuals"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/RF_.*/visuals"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/LH_.*/visuals"),
MultiMeshRayCasterCfg.RaycastTargetCfg(prim_expr="{ENV_REGEX_NS}/Robot/RH_.*/visuals"),
MultiMeshRayCasterCfg.RaycastTargetCfg(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(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()
Loading
Loading