You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Proposal] Add ray_distances for RayCasterData #2946
Add a ray_distances field to the RayCasterData output to directly provide Euclidean distances for all rays.
Motivation
Current implementation forces users to manually calculate distances using ray_hits_w and pos_w (e.g., torch.norm(ray_hits_w - pos_w, axis=-1)). This requires redundant boilerplate code in every RL environment implementation and introduces unnecessary complexity and potential errors for common tasks like collision avoidance.
Alternatives
Considered providing a helper function, but direct integration offers better API consistency and eliminates redundant user-side calculations.
Implementation
Simple interface modification using existing raycast data. Requires minimal changes to compute distances from ray_hits_w and pos_w. For unhit rays, returns max-distance to match existing convention.
Additional context
Fundamental for RL tasks like navigation and object avoidance. Eliminates common pain point reported by users.
Checklist
I have checked that there is no similar issue in the repo
Can I ask how you use LiDAR for RL training? I can't figure out how my robot can use RTX LiDAR to scan environment. I don't really understand how to get a environement /laser_scan if I can only have one prim_path_mesh
Can I ask how you use LiDAR for RL training? I can't figure out how my robot can use RTX LiDAR to scan environment. I don't really understand how to get a environement /laser_scan if I can only have one prim_path_mesh
Hello, I didn't use RTX LiDAR in isaacsim, I just used Ray Caster to detect the distance information from the robot to the obstacle, just like the official document example https://Isaac-sim.github.io/Isaacslab/main/source/overview/core-concepts/sensors/ray_caster.html. For multiple mesh, the Ray Caster class corresponding to isaacsim5.0 branch seems to have realized this function. In the current version, a simplified method is to use terrain-geneater to realize a terrain with random columns as a large mesh.
Hi, I’d like to work on this issue as my first contribution to Isaac Lab.
I noticed that #2947 was closed without merging, while the current Newton-specific sensor data class already exposes ray_distances. I’d like to explore adding consistent distance output to the general ray casters, with focused tests and documentation.
Is anyone actively working on this? Would a new PR be welcome? I’d also appreciate guidance on whether missed rays should return inf or max_distance.
I narrowed #8781 to the mesh triangulation and ray-input validation fixes, removing the proposed shared RayCasterData.ray_distances output. The existing options below are worth trying before adding another always-stored sensor field:
If you own the mesh query, request distances from that same query. The existing raycast_mesh wrapper already supports this:
Here starts/directions are Torch tensors in the same frame, directions are unit vectors, and mesh is a Warp mesh. This does not require a second query.
For cached sensor hits, distance can be derived from the hit point and the actual origin of each ray. In the common case where every ray starts at data.pos_w and no artificial post-hit bias is applied:
For grid patterns, offsets, or drift that move ray origins away from data.pos_w, use the corresponding world-frame per-ray origins instead. sensor.ray_starts is local-frame data, so it cannot be subtracted directly from world-frame hits. Post-hit Z bias also changes the published hit points; use the query's distance output when you need the geometric range before that bias.
The existing query/Newton outputs use inf for misses. If an observation requires a finite maximum, clamp the resulting ranges explicitly, e.g. ranges.clamp(max=max_distance).
A uniform high-level field remains a separate API proposal here; it is not required to fix the mesh/input bugs in #8781.
@pedestrian6
Feature is definitely welcomed if they are genuily missing.
Before introducing another output field, could you try the existing options described above? raycast_mesh(..., return_distance=True) already returns distances when you control the query, and Newton exposes them directly.
I narrowed #8781 to the mesh triangulation and ray-input validation fixes, removing the proposed shared RayCasterData.ray_distances output. The existing options below are worth trying before adding another always-stored sensor field:
If you own the mesh query, request distances from that same query. The existing raycast_mesh wrapper already supports this:
from isaaclab.utils.warp.ops import raycast_mesh
Here starts/directions are Torch tensors in the same frame, directions are unit vectors, and mesh is a Warp mesh. This does not require a second query.
For cached sensor hits, distance can be derived from the hit point and the actual origin of each ray. In the common case where every ray starts at data.pos_w and no artificial post-hit bias is applied:
import torch
For grid patterns, offsets, or drift that move ray origins away from data.pos_w, use the corresponding world-frame per-ray origins instead. sensor.ray_starts is local-frame data, so it cannot be subtracted directly from world-frame hits. Post-hit Z bias also changes the published hit points; use the query's distance output when you need the geometric range before that bias.
The existing query/Newton outputs use inf for misses. If an observation requires a finite maximum, clamp the resulting ranges explicitly, e.g. ranges.clamp(max=max_distance).
A uniform high-level field remains a separate API proposal here; it is not required to fix the mesh/input bugs in #8781.
Hi @ooctipus, thanks for outlining the existing options. I looked into the current implementation, and I think there is still a useful, narrowly scoped case for exposing ray_distances on MultiMeshRayCasterData.
For users of the existing MultiMeshRayCaster, the sensor owns the ray query. Although raycast_mesh(..., return_distance=True) is useful when calling the query directly, it does not expose the result of the query already performed by the sensor through sensor.data.
More importantly, the multi-mesh implementation already computes and stores the closest-hit distances:
Could MultiMeshRayCasterData.ray_distances expose a ProxyArray view of that existing buffer, following the public interface used by NewtonRaycastSensorData? This would not require another ray query, another distance buffer, or recomputing distances from the hit points. It would be an additive API change, preserving existing outputs and behavior. Keeping inf for misses would also match the existing query and Newton conventions; applications could clamp distances explicitly when needed.
There is also a practical limitation to deriving distances from the currently exposed data. As you noted, ray_hits_w - pos_w[:, None, :] is valid only when each ray actually starts at pos_w.
For example, my LiDAR uses a nonzero mounting offset. Subtracting data.pos_w gives the distance to the tracked frame origin rather than the actual ray origin. Reconstructing the correct origins requires handling the local pattern, offset, alignment mode, and relevant drift semantics.
If exposing distances is still not preferred, could the sensor at least expose the actual world-frame per-ray origins, for example as data.ray_starts_w, backed by the existing _ray_starts_w buffer? That would make the suggested manual calculation possible through the public API:
This would still require care for any post-hit bias, as you mentioned. For MultiMeshRayCaster, exposing the already-computed query distances seems the simpler and less error-prone interface.
Would a small PR limited to exposing that existing multi-mesh distance buffer, with focused tests and documentation, be welcome?
Activity
ducmngx commentedon Jul 16, 2025
Can I ask how you use LiDAR for RL training? I can't figure out how my robot can use RTX LiDAR to scan environment. I don't really understand how to get a environement /laser_scan if I can only have one prim_path_mesh
taceris commentedon Jul 17, 2025
Hello, I didn't use RTX LiDAR in isaacsim, I just used Ray Caster to detect the distance information from the robot to the obstacle, just like the official document example
https://Isaac-sim.github.io/Isaacslab/main/source/overview/core-concepts/sensors/ray_caster.html.For multiple mesh, the Ray Caster class corresponding to isaacsim5.0 branch seems to have realized this function. In the current version, a simplified method is to use terrain-geneater to realize a terrain with random columns as a large mesh.RandomOakForest commentedon Jul 17, 2025
Thank you for posting this proposal. The team will review it.
pedestrian6 commentedon Oct 21, 2026
Hi, I’d like to work on this issue as my first contribution to Isaac Lab.
I noticed that #2947 was closed without merging, while the current Newton-specific sensor data class already exposes
ray_distances. I’d like to explore adding consistent distance output to the general ray casters, with focused tests and documentation.Is anyone actively working on this? Would a new PR be welcome? I’d also appreciate guidance on whether missed rays should return
informax_distance.ooctipus commentedon Oct 22, 2026
I narrowed #8781 to the mesh triangulation and ray-input validation fixes, removing the proposed shared
RayCasterData.ray_distancesoutput. The existing options below are worth trying before adding another always-stored sensor field:If you own the mesh query, request distances from that same query. The existing
raycast_meshwrapper already supports this:Here starts/directions are Torch tensors in the same frame, directions are unit vectors, and
meshis a Warp mesh. This does not require a second query.Newton's existing BVH sensor (
NewtonRaycastSensor) already exposessensor.data.ray_distances.torch.For cached sensor hits, distance can be derived from the hit point and the actual origin of each ray. In the common case where every ray starts at
data.pos_wand no artificial post-hit bias is applied:For grid patterns, offsets, or drift that move ray origins away from
data.pos_w, use the corresponding world-frame per-ray origins instead.sensor.ray_startsis local-frame data, so it cannot be subtracted directly from world-frame hits. Post-hit Z bias also changes the published hit points; use the query's distance output when you need the geometric range before that bias.The existing query/Newton outputs use
inffor misses. If an observation requires a finite maximum, clamp the resulting ranges explicitly, e.g.ranges.clamp(max=max_distance).A uniform high-level field remains a separate API proposal here; it is not required to fix the mesh/input bugs in #8781.
ooctipus commentedon Oct 22, 2026
@pedestrian6
Feature is definitely welcomed if they are genuily missing.
Before introducing another output field, could you try the existing options described above? raycast_mesh(..., return_distance=True) already returns distances when you control the query, and Newton exposes them directly.
Fix ray mesh triangulation and query shape validation (#8781)
taceris commentedon Nov 5, 2026
Hi @ooctipus, thanks for outlining the existing options. I looked into the current implementation, and I think there is still a useful, narrowly scoped case for exposing
ray_distancesonMultiMeshRayCasterData.For users of the existing
MultiMeshRayCaster, the sensor owns the ray query. Althoughraycast_mesh(..., return_distance=True)is useful when calling the query directly, it does not expose the result of the query already performed by the sensor throughsensor.data.More importantly, the multi-mesh implementation already computes and stores the closest-hit distances:
raycast_dynamic_meshesinops.pyalways allocates the distance buffer because the kernels need it to resolve the closest hit.[BaseMultiMeshRayCaster](https://github.com/isaac-sim/IsaacLab/blob/main/source/isaaclab/isaaclab/sensors/ray_caster/base_multi_mesh_ray_caster.py#L406-L408)already maintains a persistent_ray_distance_wpbuffer and passes it to the ray-casting kernel.Could
MultiMeshRayCasterData.ray_distancesexpose aProxyArrayview of that existing buffer, following the public interface used byNewtonRaycastSensorData? This would not require another ray query, another distance buffer, or recomputing distances from the hit points. It would be an additive API change, preserving existing outputs and behavior. Keepinginffor misses would also match the existing query and Newton conventions; applications could clamp distances explicitly when needed.There is also a practical limitation to deriving distances from the currently exposed data. As you noted,
ray_hits_w - pos_w[:, None, :]is valid only when each ray actually starts atpos_w.In the current implementation,
cfg.offset.posis applied to the local ray starts, whiledata.pos_wis written before those local starts are transformed into world space. Thus,data.pos_wrepresents the tracked frame position, including the frame-to-body transform and position drift, but does not include the configured ray-pattern translationcfg.offset.pos.For example, my LiDAR uses a nonzero mounting offset. Subtracting
data.pos_wgives the distance to the tracked frame origin rather than the actual ray origin. Reconstructing the correct origins requires handling the local pattern, offset, alignment mode, and relevant drift semantics.If exposing distances is still not preferred, could the sensor at least expose the actual world-frame per-ray origins, for example as
data.ray_starts_w, backed by the existing_ray_starts_wbuffer? That would make the suggested manual calculation possible through the public API:This would still require care for any post-hit bias, as you mentioned. For
MultiMeshRayCaster, exposing the already-computed query distances seems the simpler and less error-prone interface.Would a small PR limited to exposing that existing multi-mesh distance buffer, with focused tests and documentation, be welcome?