Skip to content

Software Setup

Stephanie Hughes edited this page Jun 22, 2021 · 40 revisions

Install each of the following (in-order) to set up the required software needed to generate the Mujoco simulation.

Python (version 3.6+)

  • Download python (at least version 3.6 or higher) from: https://www.python.org/downloads/

Pytorch (version 1.2.0)

Pycharm (recommended but not essential)

Contains helpful editing, testing, and version control functions that can make code development more straight-forward

Mujoco (version 1.50)

(Note: the python package of this version works for python 3++)

  1. Obtain a license key by filling out your information under the MuJoCo Personal License: 1 year section, and select Student for the license type. A license key from Mujoco should be sent to your email once your license request has been processed. This license will last for one year and is free for student use. Your license key will be sent as an attachment, called mjkey.txt.
  2. Once you have obtained your license key (mjkey.txt), download Mujoco version 1.50, referred to as Mjpro150, from the Mujoco Downloads page. Please download the appropriate Mjpro150 type based on your machine (win64, linux, osx).
  3. Within your home directory, create a folder called .mujoco (Example: c:/Users/<user_name>/.mujoco)
  4. Extract the contents of the downloaded Mjpro150.zip folder and place mjpro150/ (NOT mjpro150_linux or mjpro150_win64)within your new .mujoco directory. You should now have: <home_directory_path>/.mujoco/mjpro150/
  5. Place a copy of your Mujoco license key (mjkey.txt) within <home_directory_path>/.mujoco/ and <home_directory_path>/.mujoco/mjpro150/bin/
  6. Follow the rest of the installation instructions below based on your system type (Windows, Linux).

Setting Mujoco environment variables on Windows

To start, your <home_directory_path>/.mujoco/ should contain the mjpro150 folder and a copy of the mjkey.txt.

Now, we would like to add these paths to our environment variables: How to set a path variable on a Windows machine

Set the path variables to be (replace <user_name> to be your user profile name):

set MUJOCO_PY_MJKEY_PATH=C:\Users\<user_name>\.mujoco\mjkey.txt

set MUJOCO_PY_MUJOCO_PATH=C:\Users\<user_name>\.mujoco\mjpro150\bin

set PATH=C:\Users\<user_name>\.mujoco\mjpro150\bin;%PATH%

Your path variables should now be set, allowing mujoco_py (installed in the next step) to find the location of your Mujoco distribution.

Setting Mujoco environment variables on Linux

To start, your ~/.mujoco/ directory should contain the mjpro150 folder and a copy of the mjkey.txt

  1. Use your text editor to open ~/.bashrc, for example in terminal at home directory, type subl ~/.bashrc
  2. Copy the following command at the end of the code (change to your computer name)
    • export LD_LIBRARY_PATH="/home/<graspinglab>/.mujoco/mjpro150/bin:$LD_LIBRARY_PATH"
    • export MUJOCO_PY_MJKEY_PATH="/home/<graspinglab>/.mujoco/mjkey.txt"
    • export MUJOCO_PY_MJPRO_PATH="/home/<graspinglab>/.mujoco/mjpro150"
  3. Open up a terminal and use this command: source ~/.bashrc

Your path variables should now be set, allowing mujoco_py (installed in the next step) to find the location of your Mujoco distribution.

Mujoco-py (version 1.50)

Python package developed by OpenAI

Do not try pip install mujoco-py. It will not work.

  1. Download the source code from here: https://github.com/openai/mujoco-py/releases/tag/1.50.1.0

  2. Untar / unzip the package

  3. cd mujoco-py-1.50.1.0

  4. pip install -e. Or pip install --user -e. (if you are denied for not having permission) Or pip3 (if your pip is python 2).

Now you can use mujoco with python by… import mujoco_py

Get started with the KinovaGrasping repo

After you have installed all required software, clone this repository to your local machine:

git clone [email protected]:OSUrobotics/KinovaGrasping.git

Open a terminal on your local machine, and change your directory to the location of the repo:

cd <local_machine_repo_path>/KinovaGrasping/

You will start out on the master branch (Run git branch to see the branches on your local machine). This is the main version of the code that has been reviewed by those in the lab. Development is done using the devel branch, so you should first switch over to devel before making changes to the code (see below).

Switching to a local version of a remote branch:

First, to get the current branches, run: git fetch

To make a local version of a remote branch on your local machine, run: git checkout -b <branch_name> origin/<branch_name>. This results in a local branch <branch_name> (with remote-tracking upstream to origin/<branch_name>).

In our case, we can start by switching to the devel branch through: git checkout -b devel origin/devel. Run git branch to see that we have now switched to a local version of the devel branch.

To make a local version of a feature branch, use the same command as above with the name of the feature branch. (git checkout -b <feature_branch> origin/<feature_branch>)

After the software is installed and the repo is cloned on your local machine:

To check that the Mujoco simulation is working, run python simple_rendering.py, found within KinovaGrasping/gym-kinova-gripper/. This should show a rendering of the hand and object.

To learn how to generate experiments, please see How to run the code and experiments.

Clone this wiki locally