Skip to content

Adds assertions for shapes on the asset APIs. - #4719

Merged
kellyguo11 merged 14 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/assert_shapes
Feb 27, 2026
Merged

kellyguo11 merged 14 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/assert_shapes

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Adds an optional check to validate the shapes and dtype of the inputs fed into the asset API.

Type of change

  • New feature (non-breaking change which adds functionality)

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

@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Feb 25, 2026
@greptile-apps

greptile-apps Bot commented Feb 25, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds optional runtime validation for shape and dtype of inputs to asset APIs across the IsaacLab codebase.

Key Changes:

  • Added assert_shape_and_dtype and assert_shape_and_dtype_mask validation methods to AssetBase class
  • Validation checks are only active in debug mode (if __debug__:) so they have zero performance impact in production
  • Added assertions to all setter methods across articulations, rigid objects, deformable objects, and surface grippers
  • Extended type signatures for tendon properties to accept float in addition to torch.Tensor | wp.array
  • Implemented kernel dispatching to handle float inputs for tendon stiffness, damping, limit stiffness, position limits, rest length, and offset properties
  • Updated tests to use the new float API for cleaner code
  • Fixed deformable object test to properly unsqueeze kinematic target data

Benefits:

  • Catches shape/dtype mismatches early during development with clear error messages
  • Helps developers identify incorrect API usage before cryptic kernel errors occur
  • No runtime overhead in optimized builds
  • Improves API ergonomics by accepting scalar floats where appropriate

Confidence Score: 5/5

  • This PR is safe to merge with no significant risks
  • The implementation is well-structured and defensive. Assertions only run in debug mode, preserving production performance. The changes are comprehensive across all asset types, maintaining API consistency. Type signature extensions are backward compatible. Tests have been updated to verify the new functionality.
  • No files require special attention

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/assets/asset_base.py Added validation methods assert_shape_and_dtype and assert_shape_and_dtype_mask to base class
source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation.py Added shape/dtype assertions to all setter methods and implemented float support for tendon properties
source/isaaclab_physx/isaaclab_physx/assets/deformable_object/deformable_object.py Registered custom vec6f dtype and added assertions for nodal positions, velocities, and kinematic targets
source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation.py Added comprehensive shape/dtype assertions for index and mask-based methods, updated tendon signatures

Last reviewed commit: 321c578

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

11 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@alexmillane alexmillane left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding this!

@AntoineRichard AntoineRichard mentioned this pull request Feb 25, 2026
7 tasks done
@kellyguo11

Copy link
Copy Markdown
Contributor

test failure that looks related to these changes

=================================== FAILURES ===================================
_________________________ test_cube_contact_time[True] _________________________
source/isaaclab_physx/test/sensors/test_contact_sensor.py:235: in test_cube_contact_time
    _run_contact_sensor_test(CUBE_CFG, sim_dt, devices, terrains, settings, durations)
source/isaaclab_physx/test/sensors/test_contact_sensor.py:635: in _run_contact_sensor_test
    _test_sensor_contact(
source/isaaclab_physx/test/sensors/test_contact_sensor.py:706: in _test_sensor_contact
    shape.write_root_pose_to_sim(root_pose=torch.tensor(test_pose, device=shape.device))
source/isaaclab/isaaclab/assets/rigid_object/base_rigid_object.py:724: in write_root_pose_to_sim
    self.write_root_pose_to_sim_index(root_pose=root_pose, env_ids=env_ids)
source/isaaclab_physx/isaaclab_physx/assets/rigid_object/rigid_object.py:236: in write_root_pose_to_sim_index
    self.write_root_link_pose_to_sim_index(root_pose=root_pose, env_ids=env_ids)
source/isaaclab_physx/isaaclab_physx/assets/rigid_object/rigid_object.py:338: in write_root_link_pose_to_sim_index
    self.assert_shape_and_dtype(root_pose, (env_ids.shape[0],), wp.transformf, "root_pose")
source/isaaclab/isaaclab/assets/asset_base.py:279: in assert_shape_and_dtype
    assert tensor.shape == (*shape, *offset), (
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AssertionError: RigidObject: 'root_pose' Shape mismatch: torch.Size([7]) != (1, 7)

@kellyguo11
kellyguo11 merged commit 7bfb3a4 into isaac-sim:develop Feb 27, 2026
7 of 10 checks passed
AntoineRichard added a commit that referenced this pull request Feb 27, 2026
# Description

Updates the mocks to match the API signature after the latest changes.
Builds on top of #4719

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have read and understood the [contribution
guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html)
- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
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.

4 participants