Skip to content

Conversation

@Sgt-Hashtag
Copy link

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

Please attach before and after screenshots of the change if applicable.

| Before | After |
Screenshot_png before
| ------ | ----- |
Screenshot_png after

Checklist

  • I have read and understood the contribution guidelines
  • 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

@Sgt-Hashtag Sgt-Hashtag requested a review from ooctipus as a code owner October 30, 2025 00:51
@github-actions github-actions bot added the isaac-lab Related to Isaac Lab team label Oct 30, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR fixes a bug in the save_images_grid function in scripts/demos/sensors/cameras.py that occurs when displaying a single subplot. The issue stems from matplotlib's behavior where plt.subplots(nrow, ncol) returns a single Axes object for single subplots (when nrow=1 and ncol=1) instead of an array. The original code unconditionally called .flatten() on the axes, which caused an AttributeError when axes was a single object rather than an ndarray.

The fix adds a type check to handle both cases: if axes is an ndarray, it flattens it as before; otherwise, it wraps the single axis in a numpy array to maintain consistency for the subsequent loop that indexes into the axes array. This change ensures the camera demo visualization function works correctly regardless of whether it's displaying one image or multiple images in a grid layout.

Important Files Changed

Filename Score Overview
scripts/demos/sensors/cameras.py 1/5 Fixed matplotlib axes handling for single subplot case but contains a syntax error (missing closing parenthesis)

Confidence score: 1/5

  • This PR cannot be merged due to a critical syntax error that will prevent the code from running
  • Score is 1/5 because while the logic fix is correct and addresses a real matplotlib edge case, there's a missing closing parenthesis on line 144 that makes the code syntactically invalid
  • The scripts/demos/sensors/cameras.py file requires immediate attention to fix the syntax error before merge

Sequence Diagram

sequenceDiagram
    participant User
    participant Main
    participant AppLauncher
    participant SimulationContext
    participant InteractiveScene
    participant Robot
    participant Camera
    participant TiledCamera
    participant RaycastCamera
    participant ImageSaver

    User->>Main: "Execute script with --enable_cameras"
    Main->>AppLauncher: "Launch Isaac Sim app"
    AppLauncher-->>Main: "Simulation app ready"
    
    Main->>SimulationContext: "Initialize simulation context"
    SimulationContext-->>Main: "Simulation ready"
    
    Main->>SimulationContext: "Set camera view"
    Main->>InteractiveScene: "Create scene with sensors config"
    InteractiveScene->>Robot: "Spawn robot in environments"
    InteractiveScene->>Camera: "Create standard camera sensor"
    InteractiveScene->>TiledCamera: "Create tiled camera sensor"
    InteractiveScene->>RaycastCamera: "Create raycast camera sensor"
    InteractiveScene-->>Main: "Scene setup complete"
    
    Main->>SimulationContext: "Reset simulation"
    Main->>Main: "Start simulation loop"
    
    loop "Simulation Loop (every frame)"
        alt "Reset condition (every 500 iterations)"
            Main->>Robot: "Reset root state and joint positions"
            Main->>InteractiveScene: "Reset scene buffers"
        end
        
        Main->>Robot: "Set joint position targets"
        Main->>InteractiveScene: "Write data to simulation"
        Main->>SimulationContext: "Step simulation"
        Main->>InteractiveScene: "Update sensor buffers"
        
        Main->>Camera: "Get RGB and depth data"
        Camera-->>Main: "Return image data"
        Main->>TiledCamera: "Get RGB and depth data"
        TiledCamera-->>Main: "Return image data"
        Main->>RaycastCamera: "Get depth and normals data"
        RaycastCamera-->>Main: "Return sensor data"
        
        alt "Save images (every 10 iterations)"
            Main->>ImageSaver: "Save RGB comparison grid"
            Main->>ImageSaver: "Save depth comparison grid"
            Main->>ImageSaver: "Save tiled RGB images"
            Main->>ImageSaver: "Save camera RGB images"
        end
    end
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

if isinstance(axes, np.ndarray):
axes = axes.flatten()
else:
axes = np.array([axes]
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: Missing closing parenthesis - this will cause a syntax error

Suggested change
axes = np.array([axes]
axes = np.array([axes])

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This review covers only the changes made since the last review, not the entire PR. The developer has successfully addressed the syntax error identified in the previous review by adding the missing closing parenthesis to line 144 in the save_images_grid function. The fix changes axes = np.array([axes] to axes = np.array([axes]), which resolves the critical syntax error that was preventing the camera demo script from running. This function is part of the camera sensor demonstration workflow in Isaac Lab, responsible for creating visualization grids of camera outputs from different sensor configurations including RGB cameras, depth cameras, and raycast cameras.

Important Files Changed

Filename Score Overview
scripts/demos/sensors/cameras.py 5/5 Fixed missing closing parenthesis in save_images_grid function to resolve syntax error

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it fixes a critical syntax error
  • Score reflects a simple, well-targeted fix that addresses the exact issue identified in the previous review with no additional complexity
  • No files require special attention as this is a straightforward syntax correction

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant