Skip to content

Adds mock interfaces selection API.#4722

Open
AntoineRichard wants to merge 14 commits intoisaac-sim:developfrom
AntoineRichard:antoiner/mock_interfaces_selection_API
Open

Adds mock interfaces selection API.#4722
AntoineRichard wants to merge 14 commits intoisaac-sim:developfrom
AntoineRichard:antoiner/mock_interfaces_selection_API

Conversation

@AntoineRichard
Copy link
Collaborator

@AntoineRichard AntoineRichard commented Feb 25, 2026

Description

Adds mock interfaces selection API. Getting the code ready to write UTs across backends. Built ontop of #4720

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

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 25, 2026

Greptile Summary

This PR introduces a comprehensive mock interface selection API that enables unit testing across different physics backends (PhysX and Newton) without requiring a full simulation environment.

Key Changes:

  • New Mock Infrastructure for Newton Backend: Added factory functions (create_mock_articulation_view, create_mock_quadruped_view, create_mock_humanoid_view) and mock implementations (MockNewtonArticulationView, MockNewtonModel, MockWrenchComposer) that properly handle structured Warp types
  • New Mock Infrastructure for PhysX Backend: Added MockArticulationView with comprehensive getter/setter methods and set_mock_* methods for direct test data injection
  • Validation Framework: Added assert_shape_and_dtype and assert_shape_and_dtype_mask methods to AssetBase for runtime input validation (debug mode only, zero overhead in production)
  • API Consistency Improvements: Updated all mock interfaces to align with current data shapes, removed stale convenience aliases (com_pos_b, com_quat_b), and fixed find_* methods to accept string subsets instead of integer indices
  • Bug Fixes: Corrected body_mass shape from (N, 1, 1) to (N, 1) in rigid objects, unified inertia scaling logic in randomize_rigid_body_mass
  • Enhanced Type Support: Updated tendon setters to accept float values in addition to tensors/arrays
  • Comprehensive Testing: Added extensive test suites for both PhysX and Newton mock implementations

Integration Points:

The validation methods are now called throughout PhysX and Newton articulation implementations, providing runtime verification of input shapes and dtypes for all write methods. This catches common errors early during development while maintaining zero overhead in production builds.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-structured, thoroughly tested, and maintain backward compatibility. The new mock interface API is additive and doesn't modify existing production code paths except for adding debug-mode validation. All changes follow established patterns and conventions.
  • 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 for runtime input validation in debug mode
source/isaaclab_newton/isaaclab_newton/test/mock_interfaces/factories.py New file providing factory functions for creating mock Newton views with pre-configured robot topologies (quadruped, humanoid)
source/isaaclab_newton/isaaclab_newton/test/mock_interfaces/mock_newton.py New file providing mock Newton manager, model, wrench composer, and contact sensor classes for testing
source/isaaclab_newton/isaaclab_newton/test/mock_interfaces/views/mock_articulation_view.py New comprehensive mock Newton articulation view using structured Warp types with proper shape conventions
source/isaaclab_physx/isaaclab_physx/test/mock_interfaces/views/mock_articulation_view.py New comprehensive mock PhysX articulation view with set_mock_* methods for direct test data injection
source/isaaclab/isaaclab/test/mock_interfaces/assets/mock_articulation.py Updated mock articulation to align with new data shapes, remove stale aliases, fix find_* methods to accept string subsets
source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation.py Added assert_shape_and_dtype validation calls to all write methods for runtime input validation in debug mode
source/isaaclab_newton/isaaclab_newton/assets/articulation/articulation.py Added assert_shape_and_dtype validation calls to all write methods for both index and mask-based APIs

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class AssetBase {
        +assert_shape_and_dtype()
        +assert_shape_and_dtype_mask()
    }
    
    class BaseArticulation {
        +write_joint_positions()
        +write_root_pose()
        +find_joints()
    }
    
    class BaseRigidObject {
        +write_root_pose()
        +set_masses()
    }
    
    AssetBase <|-- BaseArticulation
    AssetBase <|-- BaseRigidObject
    
    class PhysXArticulation {
        +_articulation_view
        +assert calls in write methods
    }
    
    class NewtonArticulation {
        +_articulation_view
        +assert calls in write methods
    }
    
    BaseArticulation <|-- PhysXArticulation
    BaseArticulation <|-- NewtonArticulation
    
    class MockArticulationView~PhysX~ {
        +get_root_transforms()
        +set_mock_root_transforms()
        +set_random_mock_data()
    }
    
    class MockNewtonArticulationView {
        +get_root_transforms()
        +get_attribute()
        +set_attribute()
    }
    
    PhysXArticulation o-- MockArticulationView~PhysX~
    NewtonArticulation o-- MockNewtonArticulationView
    
    class FactoryFunctions {
        +create_mock_articulation_view()
        +create_mock_quadruped_view()
        +create_mock_humanoid_view()
    }
    
    FactoryFunctions ..> MockNewtonArticulationView : creates
Loading

Last reviewed commit: 632e8a2

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.

47 files 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.

2 participants