Skip to content

Software Setup

Stephanie Hughes edited this page Jul 20, 2021 · 40 revisions

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

If you have never used git before, follow the GitHub Quickstart instructions to get a quick overview on how git version control works with GitHub. This includes a great cheatsheet for git commands.

To continue to the next steps, please make sure you have the latest version of git installed from the Git Downloads page.

Table of Contents:

  1. Software installation
  2. Getting started with the KinovaGrasping repo
  3. Common issues + Fixes

Software installation

Follow the instructions below OR checkout this tutorial with helpful code examples: Mujoco and gym setup. Follow along for part 1 and 2 (part 3 is not needed for our work).

Python (version 3.6+)

Miniconda (or Anaconda)

Conda allows us to create a python environment with the needed packages for this project. Follow the installation instructions based on your system type. It is recommended to install Miniconda (Anaconda requires much more space)

1. Download and install Miniconda: Full Miniconda installation instructions

If getting setup on the server:

Miniconda Linux installers: Linux installers

  • Download the Linux version locally (Miniconda3-latest-Linux-x86_64.sh) then copy it over to your location on the server
  • Example: scp Miniconda3-latest-Linux-x86_64.sh /nfs/stak/users/<your_onid_username>/
  • Then, within your area on the server, continue with the installation instructions: Linux installation instructions
  • Next up would be to run bash Miniconda3-latest-Linux-x86_64.sh to install Miniconda

Continue to follow the installation instructions for your machine until installation is complete (either locally or on the server).

2. Create a Conda environment How to create a conda environment.

For this project, we will be creating a Python 3.6 (or above) environment.

Replace <env_name> with your desired environment name: conda create -n <env_name> python=3.6

3. Activate your Conda environment.

You can activate your conda environment by: conda activate <env_name>, or deactivate your environment by: conda activate <env_name>

Once you have successfully installed Miniconda and have activated your Python environment, continue with the rest of the installation instructions within your Conda Python environment.

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 git@github.com:OSUrobotics/KinovaGrasping.git

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

cd <machine_repo_path>/KinovaGrasping/

Now that you are within the repo, we will want to install the required packages. change directories to cd <local_machine_repo_path>/KinovaGrasping/gym-kinova-gripper and run: python setup.py install. With all required packages installed, you are now able to start working with the code base.

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