MuJoCo: Difference between revisions

From Alliance Doc
Jump to navigation Jump to search
(fix prompts)
No edit summary
Line 4: Line 4:


<!--T:1-->
<!--T:1-->
'''MuJoCo''' "''stands for Multi-Joint dynamics with Contact. It is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed.''"
''MuJoCo stands for Multi-Joint dynamics with Contact. It is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed.<ref>http://www.mujoco.org/</ref>''


<!--T:4-->
<!--T:4-->
It is frequently used with the associated Python module <code>mujoco_py</code> as an environment for Reinforcement Learning research.
It is frequently used with the associated Python module <code>mujoco_py</code> as an environment for reinforcement learning (RL) research.


<!--T:5-->
<!--T:5-->
Line 14: Line 14:
==Installation== <!--T:6-->
==Installation== <!--T:6-->


=== Base Files === <!--T:2-->
=== Base files === <!--T:2-->


<!--T:7-->
<!--T:7-->
First, the .mujoco folder in your home directory must be set up. MuJoCo '''requires a licence key''' to be placed in
First, the .mujoco folder in your home directory must be set up. MuJoCo '''requires a licence key''' to be placed in
~/.mujoco/mjkey.txt. This key obtained by e-mail after registration.
~/.mujoco/mjkey.txt. This key is obtained by e-mail after registration.


<!--T:8-->
<!--T:8-->
The appropriate (linux) MuJoCo distribution must also be downloaded and unzipped into the ~/.mujoco directory from the Download section of the [https://www.roboti.us/index.html MuJoCo website].
The appropriate (Linux) MuJoCo distribution must also be downloaded and unzipped into the ~/.mujoco directory from the ''Download'' section of the [https://www.roboti.us/index.html MuJoCo website].


<!--T:9-->
<!--T:9-->
Line 34: Line 34:


<!--T:10-->
<!--T:10-->
The python interface to MuJoCo is the <code>mujoco_py</code> module. Getting it to work requires some special steps because library paths need to be patched.
The Python interface to MuJoCo is the <code>mujoco_py</code> module. Getting it to work requires some special steps because library paths need to be patched.


<!--T:11-->
<!--T:11-->
After using <code>module</code> to load the desired python version, you should set up a clean virtualenv:
After using <code>module</code> to load the desired Python version, you should set up a clean virtual environment:


<!--T:12-->
<!--T:12-->
Line 45: Line 45:
|source mujoco_env/bin/activate
|source mujoco_env/bin/activate
}}
}}
Now, install the <code>mujoco_py</code> module:
1. Install the <code>mujoco_py</code> module.
{{Command
{{Command
|prompt=(mujoco_env) [name@server $]
|prompt=(mujoco_env) [name@server $]
Line 52: Line 52:


<!--T:13-->
<!--T:13-->
Now the paths need to be patched with setrpaths.sh. Use the appropriate python version in the commands below if it is not 3.5:
2. Patch the paths with setrpaths.sh. Use the appropriate python version in the commands below if it is not 3.5:


<!--T:14-->
<!--T:14-->
Line 63: Line 63:


<!--T:15-->
<!--T:15-->
Now run the following command:
3. Run the following command:


<!--T:16-->
<!--T:16-->
Line 71: Line 71:


<!--T:17-->
<!--T:17-->
It should have crashed. However, it created the necessary paths to run:
It should have crashed, but the necessary paths will have been reated to run:


<!--T:18-->
<!--T:18-->
Line 79: Line 79:


<!--T:19-->
<!--T:19-->
After that last command, mujoco_py should be ready to use in the virtual environment. If everything installed correctly, the command below should run without any errors:
After that last command, mujoco_py should be ready to use in the virtual environment. If everything is installed correctly, the command below should run without any errors:
{{Command
{{Command
|prompt=(mujoco_env) [name@server $]
|prompt=(mujoco_env) [name@server $]

Revision as of 16:47, 5 June 2018

Other languages:

MuJoCo stands for Multi-Joint dynamics with Contact. It is a physics engine aiming to facilitate research and development in robotics, biomechanics, graphics and animation, and other areas where fast and accurate simulation is needed.[1]

It is frequently used with the associated Python module mujoco_py as an environment for reinforcement learning (RL) research.

Installation

Base files

First, the .mujoco folder in your home directory must be set up. MuJoCo requires a licence key to be placed in ~/.mujoco/mjkey.txt. This key is obtained by e-mail after registration.

The appropriate (Linux) MuJoCo distribution must also be downloaded and unzipped into the ~/.mujoco directory from the Download section of the MuJoCo website.

Your ~/.mujoco folder should now look like this (the version might differ):

Question.png
[name@server ~]$ ls ~/.mujoco
mjkey.txt mjproj150

mujoco_py

The Python interface to MuJoCo is the mujoco_py module. Getting it to work requires some special steps because library paths need to be patched.

After using module to load the desired Python version, you should set up a clean virtual environment:

[name@server ~]$ mkdir mujoco_env
[name@server ~]$ virtualenv mujoco_env
[name@server ~]$ source mujoco_env/bin/activate

1. Install the mujoco_py module.

Question.png
(mujoco_env) [name@server $] pip install mujoco_py

2. Patch the paths with setrpaths.sh. Use the appropriate python version in the commands below if it is not 3.5:

(mujoco_env) [name@server $] setrpaths.sh --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py
(mujoco_env) [name@server $] setrpaths.sh --add_origin --path $HOME/.mujoco


3. Run the following command:

Question.png
(mujoco_env) [name@server $] python -c "import mujoco_py"

It should have crashed, but the necessary paths will have been reated to run:

Question.png
(mujoco_env) [name@server $] setrpaths.sh --path $VIRTUAL_ENV/lib/python3.5/site-packages/mujoco_py

After that last command, mujoco_py should be ready to use in the virtual environment. If everything is installed correctly, the command below should run without any errors:

Question.png
(mujoco_env) [name@server $] python -c "import mujoco_py"