467
edits
Changes
MuJoCo
,→Add code samples for Menagerie
Download models and example files from the official MuJoCo website or repository. Detailed documentation and setup instructions accompany each model. Users are encouraged to experiment, modify XML files, and share their findings with the community.
By leveraging the MuJoCo Menagerie, researchers and engineers can accelerate their work, explore new possibilities, and contribute to the MuJoCo ecosystem.
=== Getting Started ===
To install the Menagerie, simply clone the repository in the directory of your choice:
<syntaxhighlight lang="bash">
git clone https://github.com/google-deepmind/mujoco_menagerie.git
</syntaxhighlight>
The easiest way to interactively explore a model is to load it in the simulate binary which ships with every MuJoCo distribution. Just drag and drop the <code>scene.xml</code> file into the simulate window. Alternatively, you can use the command line to launch simulate and directly pass in the path to the XML.
Outside of interactive simulation, you can load a model exactly as you would with any other XML file in MuJoCo. Here’s how you do it with the C/C++ API:
<syntaxhighlight lang="c">
#include <mujoco.h>
mjModel* model = mj_loadXML("unitree_a1/a1.xml", nullptr, nullptr, 0);
mjData* data = mj_makeData(model);
mj_step(model, data);
</syntaxhighlight>
And here’s how you do it with Python:
<syntaxhighlight lang="python">
import mujoco
model = mujoco.MjModel.from_xml_path("unitree_a1/a1.xml")
data = mujoco.MjData(model)
mujoco.mj_step(model, data)
</syntaxhighlight>
By leveraging the MuJoCo Menagerie, researchers and engineers can accelerate their work, explore new possibilities, and contribute to the MuJoCo ecosystem.