| name | run-example |
| description | Compile and run one of the example programs. Use this when asked to run an example or demo. |
Running an Example
Compile and run one of the example programs.
-
List available examples by exploring the examples/ directory. The example name is the file stem (e.g., basic.rs -> basic).
-
Check Cargo.toml for the current MuJoCo version (look for +mj-X.Y.Z in the package version). Then find the matching mujoco-X.Y.Z/ directory at the repository root.
-
Run the chosen example (replace X.Y.Z and <EXAMPLE_NAME>):
export MUJOCO_DYNAMIC_LINK_DIR=$(realpath mujoco-X.Y.Z/lib) && export LD_LIBRARY_PATH=$(realpath mujoco-X.Y.Z/lib/) && cargo run --example <EXAMPLE_NAME>
- Check the terminal output for errors.
[!NOTE]
- Most examples open a GUI window and require a display + OpenGL.
- Some examples may require specific Cargo features - read the example source file to check.
- To run in release mode add
--release.