-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
base: main
Are you sure you want to change the base?
Adds Raycaster with tracking for Dynamic Meshes #3298
Conversation
Add the efficient multi-mesh raycasting function implemented in Orbit. Moreover, this PR fixes the test of it. The new raycaster allows to raycast against multiple objects, which can be located at different positions in each environment. The positions can be tracked over time if enabled in the config. - New feature (non-breaking change which adds functionality) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: zrene <zrene@ethz.ch>
…ssion (isaac-sim#48) Fixes number of meshes in the `RayCaster` when raycasting dynamically against a regex expression of multiple objects in the scene. - Bug fix (non-breaking change which fixes an issue) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
Change Mulit-mesh raycaster and raycaster camera to own files, restore the ones of main to simplify the merge. NOTE: test of the camera is currently failing, similar as on public main at that time, should be fixed after update to latest main - Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
…d fixes tests (isaac-sim#65) ClassVar not correctly destroyed, thus removing it (follow changes of original RayCaster). Fixing tests to comply with changes of our internal code with 1.4.1. - Bug fix (non-breaking change which fixes an issue) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Co-authored-by: zrene <zrene@ethz.ch>
…_meshes for now
…nstances to benchmark. Fix callback issues for mulit mesh
…egg/IsaacLab into upstream/feature/multi-mesh-ray-caster
…egg/IsaacLab into feature/multi-mesh-ray-caster
…egg/IsaacLab into feature/multi-mesh-ray-caster
Thanks for this feature! I've noticed that the duplicate mesh detection in Currently, A more efficient alternative could be to use a hash-based lookup table to detect mesh duplicates. We can assign a hash key to each mesh based on its vertices and use it for fast duplicate checks. This would reduce the overall complexity to O(n * V) for the entire duplicate mesh detection process. Example implementation: def _get_mesh_key(vertices: np.ndarray) -> tuple[int, int, bytes]:
"""Build a key from the shape and data hash of a mesh vertex array."""
data = np.ascontiguousarray(vertices).view(np.uint8) # Ensure array is contiguous
h = hashlib.blake2b(data, digest_size=16)
return (vertices.shape[0], vertices.shape[1], h.digest()) And in def _initialize_warp_meshes(self):
...
for target_cfg in self._raycast_targets_cfg:
...
registered_meshes: dict[tuple[int, int, bytes], int] = {} # Maps mesh keys to wp_mesh indices
wp_mesh_ids = []
for target_prim in target_prims:
...
if str(target_prim.GetPath()) in MultiMeshRayCaster.meshes:
wp_mesh_ids.append(MultiMeshRayCaster.meshes[str(target_prim.GetPath())].id)
continue
...
mesh_key = _get_mesh_key(trimesh_mesh.vertices)
registered_idx = registered_meshes.get(mesh_key, -1)
if registered_idx != -1 and self.cfg.reference_meshes:
omni.log.info("Found a duplicate mesh, only reference the mesh.")
wp_mesh_ids.append(wp_mesh_ids[registered_idx])
else:
wp_mesh = convert_to_warp_mesh(trimesh_mesh.vertices, trimesh_mesh.faces, device=self.device)
MultiMeshRayCaster.meshes[str(target_prim.GetPath())] = wp_mesh
wp_mesh_ids.append(wp_mesh.id)
registered_meshes[mesh_key] = len(wp_mesh_ids) - 1 # Store wp_mesh idx This approach should reduce initialization time significantly when processing multiple meshes (from O(n² * V) to O(n * V)). |
Thanks a lot for the valuable feedback. Hashing the vertices is a great idea to speed up retrieval. I’ll incorporate this, along with an additional check for potential hash collisions, once I find the time. Also, note that cache lookups can be further accelerated by setting the is_shared flag in the configuration to true. This assumes that all environments share the same meshes, avoiding redundant checking for each one. |
This is definitely useful feedback @pavelacamposp @renezurbruegg I suggest though that we keep this MR to the current limitation and make a separate one with the hashing implementation. Just to not have this MR hanging around for too long :) |
Thanks a lot for the input. I added all prim types now and verified that they work correctly: |
Thanks, Updated it with your generic fan triangulation |
Description
This PR introduces
MultiMeshRayCaster
andMultiMeshRayCasterCamera
, an extension of the defaultRayCaster
with the following enhancements:This is joint work with @pascal-roth and @Mayankm96.
The default
RayCaster
was limited to static environments and required manual handling of moving meshes, which restricted its use for robotics scenarios where robots or obstacles move dynamically.MultiMeshRayCaster
addresses these limitations by and now supports raycasting against robot parts and other moving entities.Usage
For a quick demo, run:
Drop-in replacement
Example change to migrate from
RayCasterCfg
toMultiMeshRayCasterCfg
:Benchmarking & Validation
To benchmark the new raycaster, run:
Then plot the results with:
This will generate outputs under:
outputs/benchmarks/raycast_benchmark...
Example plots
Type of Change
Checklist
pre-commit
checks with./isaaclab.sh --format
config/extension.toml
fileCONTRIBUTORS.md
or my name already exists there