Overview
MockRobot is a standalone testing class that provides the same interface as real robots without requiring any simulation dependencies. Unlike SimRobot with backend="mock", MockRobot can be instantiated directly with custom dimensions.
When to use MockRobot:
- Unit testing robot control code
- CI/CD pipelines without heavy dependencies
- Quick prototyping without config files
- Testing custom state/action dimensions
Installation
MockRobot requires only PyTorch - no simulation backends needed:rfx-sdk package:
Basic Usage
Create a mock robot with custom dimensions:Parallel Environments
MockRobot supports multiple parallel environments:Unit Testing Example
Fromrfx/tests/test_robot_v2.py:20-40:
Physics Model
MockRobot implements a simple spring-damper physics model (fromrfx/python/rfx/sim/mock.py:53-65):
Episode Management
MockRobot tracks episode termination:Partial Environment Reset
Reset specific environments without affecting others:Integration with deploy()
Use MockRobot with thedeploy() function for testing:
MockRobot vs SimRobot with Mock Backend
Two ways to use mock simulation:- MockRobot (Direct)
- SimRobot (Config-based)
- No config file needed
- Custom dimensions
- Minimal imports
Testing Without Hardware
MockRobot enables testing control code without hardware access. Fromrfx/examples/deploy_real.py:80-101:
--mock for testing:
CI/CD Integration
MockRobot is perfect for continuous integration:Reward and Done Signals
MockRobot provides basic reward and termination signals:Multi-Robot Testing
Test heterogeneous robot systems:Custom Configuration
All MockRobot parameters:Common Patterns
Test with MockRobot, deploy with real hardware
Test with MockRobot, deploy with real hardware
Validate policy shape compatibility
Validate policy shape compatibility
Benchmark control loop latency
Benchmark control loop latency
API Reference
Constructor
Methods
| Method | Returns | Description |
|---|---|---|
observe() | dict[str, Tensor] | Get current state observation |
act(action) | None | Apply action and step physics |
reset(env_ids=None) | dict[str, Tensor] | Reset environments and return obs |
get_reward() | Tensor | Get current reward signal |
get_done() | Tensor | Get episode termination flags |
Properties
| Property | Type | Description |
|---|---|---|
num_envs | int | Number of parallel environments |
state_dim | int | Active state dimension |
action_dim | int | Active action dimension |
max_state_dim | int | Padded state dimension |
max_action_dim | int | Padded action dimension |
device | str | Device placement (“cpu” or “cuda”) |
Next Steps
Simulation Overview
Learn about full simulation backends
Backend Details
Compare Genesis, MuJoCo MJX, and Mock
