Skip to content
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

Adds dynamic and multi-mesh support for ray caster #1886

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

timkobiolka
Copy link

Description

This PR extends the ray caster to support multiple meshes in mesh_prim_paths, enabling it to interact with complex environments. Additionally, it now supports dynamic meshes, allowing real-time updates to mesh positions during simulation.

This update is fully backward-compatible with existing single-mesh configuration.

A test file is included which shows that multiple and dynamic meshes are processed by the updated ray caster.

Fixes #1804 #1395 #1259 #553

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist

  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog 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

Copy link

@cornuco-pia cornuco-pia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it gives an error if we're adding raycaster to observations and resetting an env. you have some mismatch in array shapes, i believe this on lines 292-297 fixes it:

mask = distance < final_distances[env_ids]
                final_distances[env_ids][mask] = distance[mask]
                final_hits[env_ids][mask] = hit[mask]

        # update the ray hit data for the specified environments
        self._data.ray_hits_w[env_ids] = final_hits[env_ids]

@Mayankm96
Copy link
Contributor

Thanks for the MR. This is an interesting addition. However, using a for loop over all the meshes will be rather slow. Especially if we go for multiple meshes per environment -- two mesh per environment with 4096 environments will mean 8192 separate warp kernel calls. This is rather expensive as launching a kernel takes time.

Is it possible to make a new warp kernel that parallelizes this as well?

@timkobiolka
Copy link
Author

it gives an error if we're adding raycaster to observations and resetting an env. you have some mismatch in array shapes, i believe this on lines 292-297 fixes it:

mask = distance < final_distances[env_ids]
                final_distances[env_ids][mask] = distance[mask]
                final_hits[env_ids][mask] = hit[mask]

        # update the ray hit data for the specified environments
        self._data.ray_hits_w[env_ids] = final_hits[env_ids]

Thanks for catching that! I have applied the fix 😃

@timkobiolka
Copy link
Author

Thanks for the MR. This is an interesting addition. However, using a for loop over all the meshes will be rather slow. Especially if we go for multiple meshes per environment -- two mesh per environment with 4096 environments will mean 8192 separate warp kernel calls. This is rather expensive as launching a kernel takes time.

Is it possible to make a new warp kernel that parallelizes this as well?

Thanks for reviewing the MR and for the feedback! I initially structured it with a loop over the meshes to keep the logic more straightforward. However, I agree that parallelizing the kernel calls for all meshes would be much more efficient, especially at scale with many environments. I’ll look into adding a new Warp kernel this week to handle multiple meshes.

@timkobiolka
Copy link
Author

I have now implemented a new Warp kernel (multi_mesh_raycast_kernel) to efficiently handle multiple meshes in parallel. The previous for-loop has been replaced with a single batched kernel that processes all rays against multiple meshes simultaneously. I have also added caching for mesh-to-environment mappings to reduce CPU overhead between frames. This should significantly improve the raycasting performance, especially for larger numbers of environments and meshes. Let me know if any further adjustments or improvements are needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Question] raycast sensor to measure objects generated in each environment.
3 participants