๐ Example Programs#
Tip
For models and code, see the MotrixSim Docs repository.
Before running the examples, please refer to ๐ ๏ธ Environment Setup to complete the environment setup.
We provide a series of example programs to help you master the use of MotrixSim from scratch.
On all platforms (Linux, Windows, MacOS), you can run any example of interest with:
uv run examples/{category}/{example_name}.py
Note
Special note for MacOS (aarch64-apple-darwin) platform:
If the example uses ๐จ Renderer, use:
uv run mxpython examples/{category}/{example_name}.py
If the example does not use
RenderApp(physics simulation only), useuv runwhich is consistent with other platforms
Most examples requiring visual rendering (such as robotic arm control, robot locomotion, etc.) use RenderApp and need uv run mxpython.
Getting Started#
Preview |
File |
Description |
|---|---|---|
|
Create an empty scene, equivalent to a Hello World example. |
|
|
A ball falls under gravity, demonstrating how to create a |
|
|
Load an MJCF model from a string, demonstrating how to create a scene directly from an XML string. |
|
|
Simulation of a block rolling down a slope. |
Physics#
Preview |
File |
Description |
|---|---|---|
|
Retrieve and configure |
|
|
Usage of |
|
|
Usage of |
|
|
Usage of |
|
|
Usage of |
|
|
Configure simulator parameters using |
|
|
Usage of |
|
|
Scene demonstrating friction configuration. |
|
|
Usage of geometry-related APIs, showing how to access and query geometry position, velocity, and other information. |
|
|
Usage of height field APIs, demonstrating how to access terrain height data and perform statistical analysis. |
|
|
Combine multiple MSD models, demonstrating how to use the |
|
|
A robotic arm with adhesion actuator. |
|
|
External force and torque application example, demonstrating how to use |
Control#
Preview |
File |
Description |
|---|---|---|
|
Control a cart using the keyboard; demonstrates keyboard event handling. Use W to move forward, S to move backward. Turning: A to turn left, D to turn right. |
|
|
Move a ball by clicking on the ground with the mouse; demonstrates mouse event handling. |
|
|
Demonstrates how to use the built-in IK module in MotrixSim for inverse kinematics solving. |
|
|
A robotic arm composed of simple geometries and |
|
|
The Stanford robotic arm uses a sequence of movement commands to pick and place a ball. |
|
|
Random motion of the Go1 quadruped robot, demonstrating how to integrate a neural network and use |
|
|
Go2 quadruped keyboard control example: arrow keys and WASD control walking and turning. Use |
|
|
G1 humanoid keyboard control example: arrow keys and WASD control walking and turning. Use |
|
|
G1 humanoid motion-tracking playback example. It loads the bundled reference motion and ONNX actor for single-environment playback. Use |
|
|
G1 humanoid keyboard control example in an indoor parlour scene: arrow keys and WASD control walking and turning. Use |
|
|
RM65 cabinet-opening policy example using an ONNX policy. Demo video. Press |
|
|
Shadow Hand cube reorientation policy example using an ONNX policy. Demo video. Press |
|
|
Operational Space Control (OSC) interactive example, demonstrating how to use |
|
|
Go1 quadruped multi-task policy example, supporting walking, handstand, footstand, and getup recovery mode switching. WASD to move, U for handstand, I for footstand, O for recovery, P to reset. |
Parallel Simulation#
Preview |
File |
Description |
|---|---|---|
|
Multi-environment parallel simulation. |
Randomization#
Preview |
File |
Description |
|---|---|---|
|
Randomize rigid body mass from 0.1 kg to 500 kg across 16 parallel instances, demonstrating how mass affects falling dynamics. |
|
|
Randomize per-geom friction coefficients from 0.01 to 2.0, demonstrating the transition from sliding to static grip on a 30ยฐ ramp. |
|
|
Randomize joint armature (virtual rotor inertia), showing how armature affects the natural frequency of a torsion-spring-driven arm. |
|
|
Randomize joint frictionloss (Coulomb dry friction) from 0 to 200 Nยทm, demonstrating how friction can freeze a pendulum at different angles. |
|
|
Randomize center of mass position within the cylinder cross-section, showing how COM offset affects rolling behavior. |
|
|
Randomize position actuator PD gains in a 4ร4 grid with kp (10โ120 Nยทm/rad) varying by row and kd (1โ20 Nยทmยทs/rad) by column, visualizing PD servo dynamics. |
|
|
Randomize collision and visual sizes of five geometry types (sphere, capsule, box, cylinder, ellipsoid), showing how size affects settling height and contact behavior. |
|
|
Randomize gravity direction by assigning each of 16 parallel instances a different gravity vector inside a transparent box, demonstrating per-instance gravity override with |
Viewer#
Preview |
File |
Description |
|---|---|---|
|
Camera control API usage, showing how to enable/disable system and scene cameras, and get camera poses. |
|
|
Camera viewport widgets displaying different camera feeds with interactive controls for switching cameras, resizing, and repositioning viewports. |
|
|
Usage of custom UI elements, demonstrating how to add buttons and switches for interaction. |
|
|
Usage of the 3D gizmo drawing system, demonstrating how to draw spheres, cubes, capsules, arrows, grids, and other visualization helpers. |
|
|
Image widget system usage, demonstrating how to display and interactively manipulate multiple image panels. |
|
|
Rendering settings configuration example, demonstrating how to use |
|
|
Selective rendering control in batch rendering, showing how to dynamically control visibility of specific scenes in multi-environment parallel simulation. Press A/D keys to toggle partial scene visibility, Q/E keys for all scenes. |
|
|
Light sharing optimization between environments, demonstrating how to share lights in parallel simulation to improve performance. Use |
|
|
Screen Space Global Illumination (SSGI) rendering example, demonstrating how to use |
|
|
Headless rendering example, demonstrating how to use |
Benchmark#
Preview |
File |
Description |
|---|---|---|
|
Physical simulation of a gyroscope. |
|
|
Gyroscope in a zero-gravity environment, demonstrating conservation of angular momentum. |
|
|
Physical simulation of Newtonโs cradle. |
|
|
Grasping and shaking test for the Franka Panda robotic arm, demonstrating how the arm grasps objects and maintains stability. Supports |



















































