Skip to content

Instantly share code, notes, and snippets.

@danielsnider
Last active March 12, 2019 11:27
Show Gist options
  • Save danielsnider/e09c56a96b187eec23c482f9400e59a1 to your computer and use it in GitHub Desktop.
Save danielsnider/e09c56a96b187eec23c482f9400e59a1 to your computer and use it in GitHub Desktop.
Instructions to install and run Kindred's SenseAct: A computational framework for developing real-world robot learning tasks

SenseAct Quick Start

This guide has been tested on Ubuntu 16.04.

Install General Dependecies

sudo apt update
sudo apt install python3 python3-dev python3-pip python3-tk cmake libopenmpi-dev zlib1g-dev git

Install MuJuCo Robotics Simulator

The SenseAct learning task in simulation uses a popular physics simulator called MuJoCo. First install the prerequisites for MuJoCo:

sudo apt install patchelf libgl1-mesa-dev libgl1-mesa-glx libglew-dev libosmesa6-dev

Then install MuJoCo according to their install guide.

  1. Sign up for a 30-day free trial on the MuJoCo website or free license if you are a student. The license key will arrive in an email with your username and password.
  2. Download the MuJoCo version 1.50 binaries Linux, OSX, or Windows.
  3. Unzip the downloaded mjpro150 directory into ~/.mujoco/mjpro150, and place your license key (the mjkey.txt file from your email) at ~/.mujoco/mjkey.txt.

Add MuJoCo to your PATH:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dan/.mujoco/mjpro150/bin
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/dan/.mujoco/mjpro150/bin" >> ~/.bashrc

Install SenseAct

Download SenseAct:

git clone https://github.com/kindredresearch/SenseAct
cd SenseAct

(Optionally) Create a python virtual environment:

pip3 install virtualenv
virtualenv venv
source venv/bin/activate

Install SenseAct's python dependencies:

pip3 install -e .
pip3 install baselines==0.1.5

Run SenseAct

For your first learning task, we'll simulate the robotic control of a double inverted pendulum in a MuJuCo simulation.

Enable visualization of the simulated world in MuJoCo:

sed -i 's/is_render=False/is_render=True/g' ./examples/advanced/sim_double_pendulum.py

Start learning:

python3 ./examples/advanced/sim_double_pendulum.py

Hardware Setup

UR Robot Arm

Tested on UR Software v. 3.3.4.310. To control a UR robot arm you will need its IP address and be connected to the same network. You can find the IP address on the teach pendent under network settings.

Once you have the IP address of the arm enter it here:

# SenseAct/examples/advanced/ur5_reacher.py

    # Create UR5 Reacher2D environment
    env = ReacherEnv(
            setup="UR5_default",
            host="192.168.5.20",              <-- Set IP here

Now start learning:

python3 examples/advanced/ur5_reacher.py

If you want to use a pretrained model:

git checkout load_model
python3 examples/advanced/ur5_reacher.py ./examples/advanced/pre_trained_models/ur_reacher_2_trpo.pkl

Create 2 Robot

Connect the Create 2 robot by a USB cable to your computer. Then make the USB connection active:

 sudo chmod a+rw /dev/ttyUSB0

Now start learning:

python3 examples/advanced/create2_docker.py

If you want to use a pretrained model:

git checkout load_model
python3 examples/advanced/create2_docker.py ./examples/advanced/pre_trained_models/create_docker_trpo.pkl

Dynamixel Servo

Dynamixels can be controlled by drivers written using either ctypes by Robotis or pyserial, which can be chosen by passing either True (ctypes) or False (pyserial) as an argument to the use_ctypes_driver parameter of a Dynamixel-based task (e.g., see examples/advanced/dxl_reacher.py). We found the ctypes-based driver to provide substantially more timely and precise communication compared to the pyserial-based one. For additional setup and troubleshooting information regarding Dynamixels, please see DXL Docs.

In order to use the CType-based driver, we need to install gcc and relevant packages for compiling the C libraries:

sudo apt-get install gcc-5 build-essential gcc-multilib g++-multilib

Then run the following script to download and compile the Dynamixel driver C libraries:

sudo bash setup_dxl.sh

Identify the port and make it available to be used. If you are using a USB2AX device:

 sudo chmod a+rw /dev/ttyACM0

If you are using a Robotis USB2Dynamixel device:

 sudo chmod a+rw /dev/ttyUSB0

To connect to the Dynamixel servo, you will need to know the baud rate and device ID. If the last person to use the servo can't tell you, then you can use the Dynamixel Wizard. Unfortunately, the software is supported only on Windows.

Once you know what the baud rate and device ID is, enter it here:

# SenseAct/examples/advanced/dxl_reacher.py

    # Create DXL Reacher1D environment
    env = DxlReacher1DEnv(setup='dxl_gripper_default',
                          idn=1,                 <-- Here
                          baudrate=1000000,      <-- Here
    ...

Now start learning:

python3 examples/advanced/dxl_reacher.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment