Skip to content

Fixes suction cup status tensor shape in terminations.py#4507

Open
808brick wants to merge 4 commits intoisaac-sim:mainfrom
808brick:main
Open

Fixes suction cup status tensor shape in terminations.py#4507
808brick wants to merge 4 commits intoisaac-sim:mainfrom
808brick:main

Conversation

@808brick
Copy link

@808brick 808brick commented Feb 1, 2026

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Description

Changed the view shape in line 63 of terminations.py from

suction_cup_status = surface_gripper.state.view(-1, 1) 

to

suction_cup_status = surface_gripper.state.view(-1) 

Which provided the correct tensor shape expected by termination_manager.py

Fixes # 4506

Type of change

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

Screenshots

Before

Screenshot from 2026-01-31 19-25-22

After

Screenshot from 2026-01-31 19-22-44

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 [Not Needed, should return normal functionality]
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works [Open To Feedback Here]
  • 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 [Not Needed]

The termination_manager expects a tensor of [1] but the previous view setup was creating a tensor of [1,1] causing the IsaacLab sim/task to crash

Signed-off-by: Raymond Andrade <[email protected]>
Fix suction cup status tensor shape in terminations.py
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 1, 2026

Greptile Overview

Greptile Summary

Changed surface_gripper.state.view(-1, 1) to surface_gripper.state.view(-1) in the cubes_stacked termination function to fix a tensor shape mismatch.

Key Changes:

  • Fixed tensor reshape from [num_envs, 1] to [num_envs] on line 63
  • The TerminationManager expects termination functions to return boolean tensors of shape [num_envs] (1D), not [num_envs, 1] (2D)
  • This resolves the crash when the termination manager tries to store the result in _term_dones[:, i]

Additional Notes:

  • The same pattern exists in place/mdp/terminations.py at lines 53 and 101, which may need the same fix
  • The observation functions in stack/mdp/observations.py correctly use .view(-1, 1) since observations have different shape requirements

Confidence Score: 4/5

  • Safe to merge - fixes a clear shape mismatch bug with minimal risk
  • The fix is correct and addresses a real bug. The change is minimal (removing one dimension from tensor reshape) and directly resolves the shape mismatch between what the termination function returns and what TerminationManager expects. However, there appear to be similar issues in other files that may need attention.
  • Check place/mdp/terminations.py for similar shape issues at lines 53 and 101

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/mdp/terminations.py Fixed tensor shape from [num_envs, 1] to [num_envs] to match TerminationManager requirements

Sequence Diagram

sequenceDiagram
    participant Env as ManagerBasedRLEnv
    participant TM as TerminationManager
    participant CT as cubes_stacked()
    participant SG as SurfaceGripper
    
    Env->>TM: compute()
    TM->>CT: call termination function
    CT->>SG: surface_gripper.state
    SG-->>CT: raw state tensor
    CT->>CT: view(-1) reshape to [num_envs]
    CT->>CT: compare with -1 (open state)
    CT->>CT: logical_and with stacked condition
    CT-->>TM: boolean tensor [num_envs]
    TM->>TM: store in _term_dones[:, i]
    TM-->>Env: combined termination signal [num_envs]
Loading

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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@AntoineRichard
Copy link
Collaborator

AntoineRichard commented Feb 4, 2026

Hi @808brick. Thanks for reporting this! That looks like a bug indeed! Could you follow Greptiles suggestion and update place/mdp/terminations.py ? Thanks! @kellyguo11 for viz. We may want to get that in both main and develop.

@kellyguo11 kellyguo11 changed the title Fix suction cup status tensor shape in terminations.py Fixes suction cup status tensor shape in terminations.py Feb 4, 2026
@808brick
Copy link
Author

808brick commented Feb 6, 2026 via email

@808brick
Copy link
Author

Hey @AntoineRichard, apologies for the delay on this fix. I've gone ahead and made the change requested by greptile.

It is worth noting that the average user would never run into the tensor shape mismatch error since the two tasks in the place env [Isaac-Place-Toy2Box-Agibot-Right-Arm-RmpFlow-v0, Isaac-Place-Mug-Agibot-Left-Arm-RmpFlow-v0] do not utilize surface grippers. Thus the if statement which encompass the "buggy" lines never gets triggered.

But I was able to reproduce the tensor shape mismatch error by importing a suction gripper into the environment/task:

 File "/home/ray/Workspaces/IsaacLab/source/isaaclab/isaaclab/envs/manager_based_rl_env.py", line 204, in step
    self.reset_buf = self.termination_manager.compute()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/Workspaces/IsaacLab/source/isaaclab/isaaclab/managers/termination_manager.py", line 173, in compute
    self._terminated_buf |= value
RuntimeError: output with shape [1] doesn't match the broadcast shape [1, 1]

Which was remedied by changing the shape from (-1, 1) to surface_gripper.state.view(-1).

So for the sake of modularity, I indeed agree with changes proposed by greptile and do not recommend removing these code blocks as it is still needed for users who may want to complete the place task with a custom suction based robot.

Let me know if there are any other additional changes which should be made for this particular issue.

@AntoineRichard
Copy link
Collaborator

No worries! Thanks for making the changes! @rebeccazhang0707 could you take a look?

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.

2 participants