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.tomlfor the current MuJoCo version (look for+mj-X.Y.Zin the package version). Then find the matchingmujoco-X.Y.Z/directory at the repository root.
- Run the chosen example (replace
X.Y.Zand<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.