fix raycaster visulization errors printed in the terminal#4519
fix raycaster visulization errors printed in the terminal#4519DreaverZhao wants to merge 2 commits intoisaac-sim:developfrom
Conversation
…t contributors' names
Greptile OverviewGreptile SummaryThis PR fixes a bug where raycaster visualization would throw errors when all ray hits are invalid (inf values). The fix adds an early return check after filtering infinite values to prevent calling the visualizer with an empty tensor, which would cause a Key Changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Event as Simulation Event
participant RC as RayCaster
participant Data as ray_hits_w
participant VM as VisualizationMarkers
Event->>RC: _debug_vis_callback(event)
RC->>Data: Check if ray_hits_w is None
alt ray_hits_w is None
RC->>Event: return early
else ray_hits_w exists
RC->>Data: Filter inf values
RC->>RC: Check if viz_points.shape[0] == 0
alt No valid points (NEW FIX)
RC->>Event: return early (prevents error)
else Has valid points
RC->>VM: visualize(viz_points)
VM->>VM: Update point instances
end
end
|
There was a problem hiding this comment.
Code Review Summary
Fix is correct — the root cause is accurately identified and the guard prevents the ValueError from VisualizationMarkers.visualize() when all rays miss (returning inf). The change is minimal, safe, and non-breaking.
Two observations worth considering:
1. Stale markers persist when all rays miss (minor)
When all hit points are inf and we early-return, the markers from the previous frame remain visible in the viewport. This is cosmetically wrong — the user sees phantom hit points that no longer correspond to reality. Consider calling self.ray_visualizer.set_visibility(False) before returning (and re-enabling at the top of the function), or visualizing an empty set some other way.
This is minor enough that it doesn't block the PR, but it's worth a follow-up.
2. Same bug exists in RayCasterCamera._debug_vis_callback (not in scope, but worth noting)
RayCasterCamera._debug_vis_callback (line 339 on develop) passes self.ray_hits_w.view(-1, 3) directly to visualize() with no inf filtering at all. If all rays miss, it will pass inf values to USD (bad), and if filtering were added it would hit the same zero-count crash. Since the issue reporter specifically mentions MultiMeshRayCaster (which inherits RayCaster and gets this fix), the RayCasterCamera path is a separate but identical bug. Worth a follow-up issue or expanding this PR's scope.
CI: Pre-commit passes. Other checks still pending (just triggered by merge with develop).
Verdict: LGTM with the minor nit about stale markers. The core fix is correct.
| # if no points to visualize, skip | ||
| if viz_points.shape[0] == 0: | ||
| return | ||
|
|
There was a problem hiding this comment.
Nit (non-blocking): When all rays are inf and we return early, the markers from the previous frame remain visible — they're stale. This means the user briefly sees phantom hit points that don't correspond to the current sensor state.
A simple fix would be to hide the visualizer when there's nothing to show:
# if no points to visualize, hide stale markers and skip
if viz_points.shape[0] == 0:
self.ray_visualizer.set_visibility(False)
return
else:
self.ray_visualizer.set_visibility(True)This is cosmetic and non-blocking — the core fix (preventing the ValueError) is correct. But it would make the debug visualization more accurate.
Description
Fixes #4518 by not calling the visualize function if all ray_hits_w are invalid values. I've also re-sorted the contributors' names alphabetically.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there