Fix subtitle list lengths in cameras demo#5954
Conversation
The cameras.py sensor demo was crashing with IndexError on the first image grid save because two save_images_grid calls passed subtitle lists shorter than the image lists: - rgb_images had 2 entries (Camera + TiledCamera) but subtitles had only "Camera" - depth_images had 3 entries (Camera + TiledCamera + RaycasterCamera) but subtitles had only ["Camera", "RaycasterCamera"] Restore the missing "TiledCamera" subtitle entries that were dropped in isaac-sim#5377.
Greptile SummaryThis PR restores two missing
Confidence Score: 5/5Safe to merge — the two-line change is a minimal, targeted restoration of dropped list entries with no side effects. The change is exactly two string additions that realign subtitle list lengths with their corresponding image lists. The root cause, fix, and affected code path are all clearly identifiable and the logic is straightforward. The other save_images_grid calls in the same file already use correctly sized subtitle lists and are unaffected. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Sim as run_simulator
participant SIG as save_images_grid
participant MPL as matplotlib
Sim->>SIG: "rgb_images=[Camera, TiledCamera], subtitles=["Camera","TiledCamera"]"
SIG->>MPL: ax.set_title(subtitles[0]) → "Camera"
SIG->>MPL: ax.set_title(subtitles[1]) → "TiledCamera"
MPL-->>Sim: JPEG saved ✓
Sim->>SIG: "depth_images=[Camera, TiledCamera, Raycast], subtitles=["Camera","TiledCamera","RaycasterCamera"]"
SIG->>MPL: ax.set_title(subtitles[0]) → "Camera"
SIG->>MPL: ax.set_title(subtitles[1]) → "TiledCamera"
SIG->>MPL: ax.set_title(subtitles[2]) → "RaycasterCamera"
MPL-->>Sim: JPEG saved ✓
Reviews (1): Last reviewed commit: "Fix subtitle list lengths in cameras dem..." | Re-trigger Greptile |
There was a problem hiding this comment.
🤖 Isaac Lab Review Bot
Summary
This PR fixes an IndexError: list index out of range crash in the cameras demo script. The root cause was that two save_images_grid calls had subtitle lists shorter than their corresponding image lists after PR #5377 accidentally dropped the "TiledCamera" entries.
Design Assessment
Design is sound — This is a straightforward fix restoring accidentally deleted list elements. The fix correctly matches subtitle list lengths to image list lengths.
Findings
No issues found. The fix is minimal, correct, and addresses the exact root cause described.
Verified correctness:
- Line 246:
rgb_imageshas 2 elements (scene["camera"]...andscene["tiled_camera"]...), now correctly matched bysubtitles=["Camera", "TiledCamera"] - Line 260:
depth_imageshas 3 elements (Camera, TiledCamera, RaycasterCamera), now correctly matched bysubtitles=["Camera", "TiledCamera", "RaycasterCamera"]
Test Coverage
- Bug fix: No automated regression test included
- Mitigating factors: This is a demo script (not core library code), and the author documented manual testing in the PR description. The crash was deterministic and immediate — any run of the script would have caught a regression.
- Recommendation: While a unit test for
save_images_gridwith mismatched list lengths would be nice-to-have, it's not critical for a demo script fix.
CI Status
Core checks passing (pre-commit, build wheel, labeler). Some jobs still pending (license-check, docker builds, docs).
Verdict
No issues found
Clean, minimal fix that correctly addresses the documented crash. The change is self-evidently correct — the subtitle lists now match the image lists they label.
|
End-to-end verification in the IsaacLab Docker container (Isaac Sim 6.0.0-dev2, RTX 6000 Ada): Result with this fix applied:
Reverting just |
## Summary
The `scripts/demos/sensors/cameras.py` demo crashes on its first
image-grid save with an `IndexError: list index out of range` because
two `save_images_grid` calls pass subtitle lists shorter than the image
lists they label.
```
Traceback (most recent call last):
File "scripts/demos/sensors/cameras.py", line 299, in main
run_simulator(sim, scene)
File "scripts/demos/sensors/cameras.py", line 244, in run_simulator
save_images_grid(
File "scripts/demos/sensors/cameras.py", line 155, in save_images_grid
ax.set_title(subtitles[idx])
~~~~~~~~~^^^^^
IndexError: list index out of range
```
## Root cause
PR isaac-sim#5377 dropped the `"TiledCamera"` subtitle entries from two
`save_images_grid` calls but kept the corresponding images in the
`rgb_images` and `depth_images` lists:
- `rgb_images` has 2 entries (`Camera`, `TiledCamera`) but
`subtitles=["Camera"]` had 1
- `depth_images` has 3 entries (`Camera`, `TiledCamera`,
`RaycasterCamera`) but `subtitles=["Camera", "RaycasterCamera"]` had 2
`save_images_grid` iterates `enumerate(zip(images, axes))` and indexes
`subtitles[idx]`, so as soon as `idx >= len(subtitles)` the demo
crashes.
## Fix
Restore the missing `"TiledCamera"` subtitle entries.
## Test plan
- [x] Reproduced the failure with a minimal standalone harness that
calls `save_images_grid(2_images, subtitles=["Camera"])` and observed
the same `IndexError`
- [x] Re-ran the same harness after the fix with subtitle lists of
matching lengths — all four `save_images_grid` call shapes (2/3/N
images) produce JPEGs without error
- [x] Reviewer to run `./isaaclab.sh -p scripts/demos/sensors/cameras.py
--enable_cameras --headless` end-to-end and confirm no crash
|
pls also cherry pick this to the release branch |
## Summary
The `scripts/demos/sensors/cameras.py` demo crashes on its first
image-grid save with an `IndexError: list index out of range` because
two `save_images_grid` calls pass subtitle lists shorter than the image
lists they label.
```
Traceback (most recent call last):
File "scripts/demos/sensors/cameras.py", line 299, in main
run_simulator(sim, scene)
File "scripts/demos/sensors/cameras.py", line 244, in run_simulator
save_images_grid(
File "scripts/demos/sensors/cameras.py", line 155, in save_images_grid
ax.set_title(subtitles[idx])
~~~~~~~~~^^^^^
IndexError: list index out of range
```
## Root cause
PR isaac-sim#5377 dropped the `"TiledCamera"` subtitle entries from two
`save_images_grid` calls but kept the corresponding images in the
`rgb_images` and `depth_images` lists:
- `rgb_images` has 2 entries (`Camera`, `TiledCamera`) but
`subtitles=["Camera"]` had 1
- `depth_images` has 3 entries (`Camera`, `TiledCamera`,
`RaycasterCamera`) but `subtitles=["Camera", "RaycasterCamera"]` had 2
`save_images_grid` iterates `enumerate(zip(images, axes))` and indexes
`subtitles[idx]`, so as soon as `idx >= len(subtitles)` the demo
crashes.
## Fix
Restore the missing `"TiledCamera"` subtitle entries.
## Test plan
- [x] Reproduced the failure with a minimal standalone harness that
calls `save_images_grid(2_images, subtitles=["Camera"])` and observed
the same `IndexError`
- [x] Re-ran the same harness after the fix with subtitle lists of
matching lengths — all four `save_images_grid` call shapes (2/3/N
images) produce JPEGs without error
- [x] Reviewer to run `./isaaclab.sh -p scripts/demos/sensors/cameras.py
--enable_cameras --headless` end-to-end and confirm no crash
(cherry picked from commit 79e6a02)
Cherry-picks the following PRs from develop to release/3.0.0-beta2: - #5958 Fix stale SimulationContext script APIs - #5960 docs: Update RL entrypoint examples - #5925 Fix memory leak in ManagerBasedEnv.close - #5987 Add interop to imitation learning scripts - #5954 Fix subtitle list lengths in cameras demo Validation: - ./isaaclab.sh -f --------- Signed-off-by: Clemens Volk <cvolk@nvidia.com> Co-authored-by: Clemens Volk <cvolk@nvidia.com> Co-authored-by: Alex Millane <alex.millane@gmail.com> Co-authored-by: Pascal Roth <57946385+pascal-roth@users.noreply.github.com>
Summary
The
scripts/demos/sensors/cameras.pydemo crashes on its first image-grid save with anIndexError: list index out of rangebecause twosave_images_gridcalls pass subtitle lists shorter than the image lists they label.Root cause
PR #5377 dropped the
"TiledCamera"subtitle entries from twosave_images_gridcalls but kept the corresponding images in thergb_imagesanddepth_imageslists:rgb_imageshas 2 entries (Camera,TiledCamera) butsubtitles=["Camera"]had 1depth_imageshas 3 entries (Camera,TiledCamera,RaycasterCamera) butsubtitles=["Camera", "RaycasterCamera"]had 2save_images_griditeratesenumerate(zip(images, axes))and indexessubtitles[idx], so as soon asidx >= len(subtitles)the demo crashes.Fix
Restore the missing
"TiledCamera"subtitle entries.Test plan
save_images_grid(2_images, subtitles=["Camera"])and observed the sameIndexErrorsave_images_gridcall shapes (2/3/N images) produce JPEGs without error./isaaclab.sh -p scripts/demos/sensors/cameras.py --enable_cameras --headlessend-to-end and confirm no crash