Skip to content

Fix subtitle list lengths in cameras demo#5954

Merged
AntoineRichard merged 1 commit into
isaac-sim:developfrom
pascal-roth:proth/fix-cameras-demo-subtitles
Jun 4, 2026
Merged

Fix subtitle list lengths in cameras demo#5954
AntoineRichard merged 1 commit into
isaac-sim:developfrom
pascal-roth:proth/fix-cameras-demo-subtitles

Conversation

@pascal-roth

@pascal-roth pascal-roth commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

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 #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

  • Reproduced the failure with a minimal standalone harness that calls save_images_grid(2_images, subtitles=["Camera"]) and observed the same IndexError
  • 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
  • Reviewer to run ./isaaclab.sh -p scripts/demos/sensors/cameras.py --enable_cameras --headless end-to-end and confirm no crash

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.
@pascal-roth pascal-roth requested a review from ooctipus as a code owner June 4, 2026 06:47
@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Jun 4, 2026
@greptile-apps

greptile-apps Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR restores two missing "TiledCamera" subtitle entries in scripts/demos/sensors/cameras.py that were accidentally dropped by PR #5377, causing an IndexError crash on the first image-grid save every 10th simulation step.

  • RGB grid fix: subtitles=[\"Camera\"][\"Camera\", \"TiledCamera\"] to match the 2-element rgb_images list.
  • Depth grid fix: subtitles=[\"Camera\", \"RaycasterCamera\"][\"Camera\", \"TiledCamera\", \"RaycasterCamera\"] to match the 3-element depth_images list.

Confidence Score: 5/5

Safe 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

Filename Overview
scripts/demos/sensors/cameras.py Restores two missing "TiledCamera" subtitle entries so subtitle list lengths match image list lengths, fixing an IndexError crash on every 10th simulation step.

Sequence Diagram

sequenceDiagram
    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 ✓
Loading

Reviews (1): Last reviewed commit: "Fix subtitle list lengths in cameras dem..." | Re-trigger Greptile

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 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_images has 2 elements (scene["camera"]... and scene["tiled_camera"]...), now correctly matched by subtitles=["Camera", "TiledCamera"]
  • Line 260: depth_images has 3 elements (Camera, TiledCamera, RaycasterCamera), now correctly matched by subtitles=["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_grid with 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.

@pascal-roth

Copy link
Copy Markdown
Collaborator Author

End-to-end verification in the IsaacLab Docker container (Isaac Sim 6.0.0-dev2, RTX 6000 Ada):

docker exec isaac-lab-base bash -c '
  cd /workspace/isaaclab &&
  ./isaaclab.sh -p scripts/demos/sensors/cameras.py --enable_cameras --headless --visualizer none
'

Result with this fix applied:

  • Setup completes, scene initializes, robot reset, simulation runs.
  • 200 JPEGs produced across all four output dirs (rgb/, distance_to_camera/, tiled_rgb/, cam_rgb/) — including both formerly-crashing call sites.
  • grep -cE 'IndexError|Traceback|set_title' run.log0.

Reverting just cameras.py to the pre-fix subtitle lists and re-running reproduces the original IndexError: list index out of range at cameras.py:155 on the first frame-10 image save. The fix is necessary and sufficient.

@AntoineRichard AntoineRichard merged commit 79e6a02 into isaac-sim:develop Jun 4, 2026
37 checks passed
matthewtrepte pushed a commit to matthewtrepte/IsaacLab that referenced this pull request Jun 4, 2026
## 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
@kellyguo11

Copy link
Copy Markdown
Contributor

pls also cherry pick this to the release branch

AntoineRichard pushed a commit to AntoineRichard/IsaacLab that referenced this pull request Jun 5, 2026
## 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)
kellyguo11 pushed a commit that referenced this pull request Jun 7, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants