Installing the R2 simulator for ROS Indigo

🕒 4 min read

What is r2?

The r2 robot, which is an acronym for Robonaut 2, is a dexterous humanoid robot created by NASA, with the goal of it aiding humans in space (Robonaut 2 is just an upgrade from its predecessor, the Robonaut). The robot was created to ressemble as close as a human (with a head, hands, fingers, etc), it will be used to expand our ability for construction and discovery.

As the model and simulation files are open sourced NASA JSC Robotics with ROS support, we are able to try out the very robot that is used by the NASA team. (Thanks, NASA JSC Robotics!) Therefore, in this tutorial, we’ll be looking at how do we install the r2 simulator into your computer.


Though the installation guide was pretty well documented (at their Wiki here), the main wiki/guide assumes that one would setup the SSH keys required to clone their repository. Therefore, for this tutorial, the SSH section will be tweak (downloading repositories without the need of creating the SSH keys). (Make adjustments accordingly, as quoted by their wiki.)

For this guide, we would be using Ubuntu 14.04, with ROS Indigo (Desktop version) setup beforehand.


ROS Environment

Create a file named ~/.ros_clean with the following contents:


export CPATH=
export ROS_ROOT=
export ROS_DISTRO=
export ROS_ETC_DIR=
export LUA_PATH=
export LUA_CPATH=

(Not really sure what this part is for, but I think it is used to reset the system parameters to installation default)



Gazebo will be used to simulate the physical world in a virtual environment. For the r2 robot, it is recommended to use it on Gazebo 5. (If you installed the ros-indigo-desktop-full version, it comes with Gazebo2, but we wouldn’t be using it for the r2 robot.)

To install Gazebo 5, run the following commands:

sudo sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/gazebo-latest.list'
wget -O - | sudo apt-key add -
sudo apt-get update
sudo apt-get install ros-indigo-gazebo5-ros-pkgs


r2 Simulation

Gazebo will be used to simulate the physical world in a virtual environment. For the r2 robot, it is recommended to use it on Gazebo 5. (If you installed the ros-indigo-desktop-full version, it comes with Gazebo2, but we wouldn’t be using it for the r2 robot.)


Code Dependencies

A few things packages are required in order for the simulator to compile correctly. Run the following commands:

sudo apt-get install git python-vcstool python-pip
sudo sh -c 'echo "yaml"  > /etc/ros/rosdep/sources.list.d/10-nasa-common.list'
sudo sh -c 'echo "yaml"  > /etc/ros/rosdep/sources.list.d/11-nasa-trusty.list'
sudo sh -c 'echo "yaml" > /etc/ros/rosdep/sources.list.d/12-nasa-indigo-gazebo5.list'
rosdep update



Create a r2_sim workspace in your ~/ directory, and the catkin_initialise the workspace.

mkdir -p ~/r2_sim/src
cd ~/r2_sim/src


Cloning the packages

Their repositories were once located in BitBucket, but they migrated their repositories to GitLab. One disadvantage of GitLab over Github is that you need to set up the SSH keys in order to git clone their repositories. (Though this method is more secure)

As the R2 simulation software checkout is configured to work with SSH keys, one would have to setup the SSH keys with GitLab in order to follow their installation guide. However, in this tutorial, we’ll be working around this requirement through a script that manually downloads the required packages.

[Update: I have uploaded the script into Github to simplify the process, so just git clone the repository here: Follow the instruction as mentioned in the README.]

Open your favourite text editor (gedit, nano, etc.) and paste the following code below. Save it as in the . This bash script will automatically git clone the required packages into the r2_sim directory.

timestamp="$(date "+%Y-%m-%d,%T")"
printf "["${timestamp}"] Loading packages URLn"
if [ -f r2_url.txt ]
    IFS=":" read -ra urlList<r2_url.txt;
    printf "["${timestamp}"] Entering ~/r2_sim/src directory"
    cd ~/r2_sim/src
    if [ $? -eq 0 ]
        declare inst
        printf "["${timestamp}"] Git cloning the relevant r2 packages..."
        for i in "${urlList[@]}" ; do
        inst=$(echo ""$i".git")
        echo "Cloning "$i
        git clone $inst
        if [ $? -ne 0 ]
            timestamp="$(date "+%Y-%m-%d,%T")"
            erT="["${timestamp}"] Failed to clone "$i", skipping..."
            echo -e $erT
        printf "["${timestamp}"] Done!n----------------------------------------------n"
    printf "["${timestamp}"] Failed to enter r2_sim/src directory, quiting...n"
    printf "["${timestamp}"] Failed to find r2_url.txt, quiting...n"

Open a new window in the text editor and paste the following code below. Save it as r2_url.txt. This file will serve as the url package list.


After that, change the permission of the script to executable and run the script. It would start downloading the packages.

chmod +x


Compiling the packages

Change directory to the r2_sim directory and compile the packages.

cd ~/r2_sim
rosdep install -y -i --from-paths src



Can’t compile robot_instance package

robot_instance has a known dependency issue on develop. Please run the following command to fix:

cd ~/r2_sim/src/robot_instance
git checkout 2016_11_7_ar_demo

Log4cpp not found

If you encounter this problem, it can be solved by installing the package mentioned in the error: ros-indigo-Log4cpp.

sudo apt-get install ros-indigo-Log4cpp

Setting up the environment

Create another file named ~/.r2_sim with the following:

source ~/.ros_clean
source /opt/ros/indigo/

if [ -f ~/r2_sim/devel/ ]
    source ~/r2_sim/devel/
    if [ -d ~/r2_sim/src ]
        export ROS_PACKAGE_PATH=~/r2_sim/src:$ROS_PACKAGE_PATH

And source the file each time you want to use the simulation:

source ~/.r2_sim

Optionally, you can automatically configure the simulation environment every time you open a terminal by running the following:

echo "source ~/.r2_sim" >> ~/.bashrc

This will source the ~/.r2_sim file every time you open a new terminal.


Running the demo

To test out whether everything is installed properly, run the following commands:

roslaunch r2_gazebo r2c_upperbody.launch ros_control:=true robodyn:=true

It’ll open up gazebo with the r2 upper body loaded. It would look something like this:

And here’s the rqt_graph:

To test whether the r2 is able to move, run the following 2 commands (it will send some predefined goal points for r2 to move).

rosrun r2_supervisors_control
rosrun r2_supervisors_control



There is no model loaded in Gazebo! What should I do?

For this problem, try restarting the computer. This might be because the packages installed earlier on might not been started,so restarting the computer will allow it to load the necessary packages.



Share your love

Leave a Reply

Your email address will not be published. Required fields are marked *