Getting Started with MuJoCo
A Blog to get started with the MuJoCo Environment
MuJoCo
MuJoCo stands for Multi-Joint dynamics with Contact. It is a general purpose physics engine that aims to facilitate research and development in robotics, biomechanics, graphics and animation, machine learning, and other areas that demand fast and accurate simulation of articulated structures interacting with their environment. Initially developed by Roboti LLC, it was acquired and made freely available by DeepMind in October 2021, with the goal of making MuJoCo an open-source project.
MuJoCo is a physics engine that aims to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed.
MuJoCo offers a unique combination of speed, accuracy and modeling power, yet it is not merely a better simulator. Instead it is the first full-featured simulator designed from the ground up for the purpose of model-based optimization, and in particular optimization through contacts.
MuJoCo makes it possible to scale up computationally-intensive techniques such optimal control, physically-consistent state estimation, system identification and automated mechanism design, and apply them to complex dynamical systems in contact-rich behaviors. It also has more traditional applications such as testing and validation of control schemes before deployment on physical robots, interactive scientific visualization, virtual environments, animation and gaming.
The Documentation for MuJoCo is available here
Installation
Let us now follow the following steps to setup MuJoCo on our Linux System
-
Install anaconda Download
sudo chmod +x Anaconda3-2021.11-Linux-x86_64.sh ./Anaconda3-2021.11-Linux-x86_64.sh
-
install git
sudo apt install git
-
install the mujoco library
- Download the Mujoco library from here
- create a hidden folder :
mkdir /home/username/.mujoco
- extract the library to the .mujoco folder
- include these lines in .bashrc file:
export LD_LIBRARY_PATH=/home/tayal/.mujoco/mujoco210/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia export PATH="$LD_LIBRARY_PATH:$PATH" export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
-
source .bashrc
- Test that the library is installed by going into:
cd ~/.mujoco/mujoco210/bin ./simulate ../model/humanoid.xml
- Install mujoco-py:
conda create --name mujoco_py python=3.8 conda activate mujoco_py sudo apt update sudo apt-get install patchelf sudo apt-get install python3-dev build-essential libssl-dev libffi-dev libxml2-dev sudo apt-get install libxslt1-dev zlib1g-dev libglew1.5 libglew-dev python3-pip git clone https://github.com/openai/mujoco-py cd mujoco-py pip install -r requirements.txt pip install -r requirements.dev.txt pip3 install -e . --no-cache
-
reboot your machine
- run these commands
conda activate mujoco_py sudo apt install libosmesa6-dev libgl1-mesa-glx libglfw3 sudo ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1 /usr/lib/x86_64-linux-gnu/libGL.so pip3 install -U 'mujoco-py<2.2,>=2.1' cd examples python3 setting_state.py