Skip to content

Conversation

@AntoineRichard
Copy link
Collaborator

Description

Add mock interfaces for PhysX's TensorAPI views as well as for the base asset/sensor abstractions. These are targeted for towards unit testing and benchmarking without starting kit.

New Features:

  • MockArticulationData & MockArticulation
  • MockRigidObjectData & MockRigidObject
  • MockRigidObjectCollectionData & MockRigidObjectCollection
  • MockIMUData & MockIMU
  • MockFrameTransformerData & MockFrameTransformer
  • MockContactSensorData & MockContactSensor
  • MockRigidBodyView - Mock for physx.RigidBodyView
  • MockArticulationView - Mock for physx.ArticulationView
  • MockRigidContactView - Mock for physx.RigidContactView
  • Pre-configured factories for quadruped (12 DOFs) and humanoid (21 DOFs) robots
  • Patching utilities (context managers and decorators) for easy test setup
  • Tests to ensure coverage is correct

Type of change

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

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 documentation Improvements or additions to documentation isaac-sim Related to Isaac Sim team isaac-lab Related to Isaac Lab team labels Jan 29, 2026
@AntoineRichard AntoineRichard changed the title Adds Mock Interfaces to enable unit-testing and isolated benchmaking. Adds mock interfaces to enable unit-testing and isolated benchmaking. Jan 29, 2026
@AntoineRichard
Copy link
Collaborator Author

@greptile give it a looksy

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 3, 2026

Greptile Overview

Greptile Summary

This PR adds comprehensive mock interfaces for unit testing IsaacLab components without requiring Isaac Sim or GPU simulation. The implementation includes two layers: high-level mocks for sensors and assets (isaaclab.test.mock_interfaces) and low-level PhysX TensorAPI view mocks (isaaclab_physx.test.mock_interfaces).

Key additions:

  • Mock implementations for Articulation, RigidObject, RigidObjectCollection assets with full state management
  • Mock sensors: ContactSensor, IMU, FrameTransformer with configurable data outputs
  • Mock PhysX views: ArticulationView, RigidBodyView, RigidContactView mimicking TensorAPI
  • Factory functions for common robot morphologies (quadruped with 12 DOFs, humanoid with 21 DOFs)
  • Patching utilities (context managers and decorators) for easy test injection
  • Comprehensive test coverage (840+ lines of property tests, 340+ lines of integration tests)
  • Complete documentation with usage examples and patterns

Architectural improvements:

  • Refactored production code to use TYPE_CHECKING for PhysX imports, enabling mock injection
  • Removed auto-import of sensors module from isaaclab_physx.__init__.py to prevent circular dependencies
  • Lazy tensor initialization in mocks to optimize memory usage
  • Proper separation between high-level asset/sensor mocks and low-level PhysX view mocks

Issue found:

  • All 31 new mock interface files contain duplicate copyright headers (lines 1-4 and 6-9 are identical)

Confidence Score: 4/5

  • Safe to merge after fixing duplicate copyright headers in all mock interface files
  • The implementation is well-architected with comprehensive test coverage and documentation. The only issue is a systematic duplicate copyright header across all 31 new files, which is a simple formatting error that should be fixed before merging. The code quality is high with proper lazy initialization, type hints, and separation of concerns.
  • All mock interface files (31 total) need copyright header deduplication - see comments on source/isaaclab/isaaclab/test/mock_interfaces/__init__.py and source/isaaclab/isaaclab/test/mock_interfaces/assets/__init__.py

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/test/mock_interfaces/init.py Main entry point for mock interfaces, has duplicate copyright headers
source/isaaclab/isaaclab/test/mock_interfaces/assets/mock_articulation.py Core mock articulation implementation with comprehensive state management (1614 lines)
source/isaaclab_physx/isaaclab_physx/test/mock_interfaces/views/mock_articulation_view.py Mock PhysX ArticulationView with proper lazy initialization and tensor management (922 lines)
source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation.py Refactored imports to use TYPE_CHECKING for physx module, improving testability
source/isaaclab_physx/isaaclab_physx/assets/articulation/articulation_data.py Updated to use TYPE_CHECKING and refactored imports for better mock compatibility
source/isaaclab/test/test_mock_interfaces/test_mock_assets.py Comprehensive test coverage for mock assets with shape and state validation (340 lines)
source/isaaclab/test/test_mock_interfaces/test_mock_data_properties.py Exhaustive property and setter tests using parametrization (840 lines)
docs/source/testing/mock_interfaces.rst Comprehensive documentation with examples and usage patterns (470 lines)

Sequence Diagram

sequenceDiagram
    participant Test as Test Code
    participant MockAsset as MockArticulation
    participant MockData as MockArticulationData
    participant MockView as MockArticulationView
    participant Tensor as PyTorch Tensors
    
    Note over Test,Tensor: Initialization Phase
    Test->>MockAsset: MockArticulation(num_instances=4, num_joints=12)
    MockAsset->>MockData: Create MockArticulationData
    MockData->>Tensor: Allocate zero tensors (lazy)
    MockAsset->>MockView: Create MockArticulationView (optional)
    MockView->>Tensor: Initialize state tensors
    MockAsset-->>Test: Return mock asset instance
    
    Note over Test,Tensor: Data Setting Phase
    Test->>MockData: set_mock_data(joint_pos=tensor)
    MockData->>Tensor: Store joint positions
    Test->>MockData: set_mock_data(root_link_pose_w=tensor)
    MockData->>Tensor: Store root pose
    
    Note over Test,Tensor: Data Access Phase
    Test->>MockAsset: robot.data.joint_pos
    MockAsset->>MockData: Access joint_pos property
    alt Data exists
        MockData->>Tensor: Return stored tensor
    else Data not set
        MockData->>Tensor: Return zero tensor with correct shape
    end
    MockData-->>Test: Return tensor (N, J)
    
    Note over Test,Tensor: Patching for Testing
    Test->>Test: with patch_articulation(target, ...)
    Test->>MockAsset: Create mock instance
    Test->>Test: Run code under test
    Test->>MockAsset: Verify mock interactions
    Test->>Test: Exit context (cleanup)
    
    Note over Test,Tensor: PhysX View Integration
    Test->>MockView: get_dof_positions()
    MockView->>Tensor: Return or initialize dof_positions
    MockView-->>Test: Return tensor clone (N, J)
    Test->>MockView: set_dof_positions(tensor, indices)
    MockView->>Tensor: Update internal state

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.

8 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@github-actions github-actions bot added the isaac-mimic Related to Isaac Mimic team label Feb 3, 2026
@kellyguo11 kellyguo11 merged commit 1497af1 into isaac-sim:develop Feb 3, 2026
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team isaac-mimic Related to Isaac Mimic team isaac-sim Related to Isaac Sim team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants