Contents
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.
Installation
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:
#!/bin/bash export CMAKE_PREFIX_PATH= export CPATH= export ROS_ROOT= export ROS_DISTRO= export ROS_WORKSPACE= export ROS_PACKAGE_PATH= export ROS_ETC_DIR= export PKG_CONFIG_PATH= export PYTHONPATH= export ROSLISP_PACKAGE_DIRECTORIES= export LUA_PATH= export LUA_CPATH= export GAZEBO_MODEL_PATH= export GAZEBO_RESOURCE_PATH= export LD_LIBRARY_PATH= export ROS_TEST_RESULTS_DIR= export RTT_COMPONENT_PATH=
(Not really sure what this part is for, but I think it is used to reset the system parameters to installation default)
Gazebo
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 http://packages.osrfoundation.org/gazebo/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/gazebo-latest.list' wget http://packages.osrfoundation.org/gazebo.key -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 https://gitlab.com/nasa-jsc-robotics/nasa_common_rosdep/raw/master/nasa-common.yaml" > /etc/ros/rosdep/sources.list.d/10-nasa-common.list' sudo sh -c 'echo "yaml https://gitlab.com/nasa-jsc-robotics/nasa_common_rosdep/raw/master/nasa-trusty.yaml" > /etc/ros/rosdep/sources.list.d/11-nasa-trusty.list' sudo sh -c 'echo "yaml https://gitlab.com/nasa-jsc-robotics/nasa_common_rosdep/raw/master/nasa-indigo-gazebo5.yaml" > /etc/ros/rosdep/sources.list.d/12-nasa-indigo-gazebo5.list' rosdep update
Workspace
Create a r2_sim workspace in your ~/ directory, and the catkin_initialise the workspace.
mkdir -p ~/r2_sim/src cd ~/r2_sim/src catkin_init_workspace
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: https://github.com/1487quantum/ros-r2-pkg-cloner.git. 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 getPkg.sh in the . This bash script will automatically git clone the required packages into the r2_sim directory.
#!/bin/bash timestamp="$(date "+%Y-%m-%d,%T")" printf "["${timestamp}"] Loading packages URLn" if [ -f r2_url.txt ] then IFS=":" read -ra urlList<r2_url.txt; printf "["${timestamp}"] Entering ~/r2_sim/src directory" cd ~/r2_sim/src if [ $? -eq 0 ] then declare inst printf "["${timestamp}"] Git cloning the relevant r2 packages..." for i in "${urlList[@]}" ; do inst=$(echo "https://gitlab.com/nasa-jsc-robotics/"$i".git") echo "Cloning "$i git clone $inst if [ $? -ne 0 ] then timestamp="$(date "+%Y-%m-%d,%T")" erT="["${timestamp}"] Failed to clone "$i", skipping..." echo -e $erT fi done printf "["${timestamp}"] Done!n----------------------------------------------n" else printf "["${timestamp}"] Failed to enter r2_sim/src directory, quiting...n" fi else printf "["${timestamp}"] Failed to find r2_url.txt, quiting...n" fi
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.
fsm_utils:hayai:iss_taskboard_gazebo:nasa_common_cmake:nasa_common_logging:r2_description:r2_gazebo:r2_gazebo_gripper:r2_gazebo_interface:r2_moveit_config:r2_msgs:r2_supervisors_control:r2_upperbody_moveit_config:robodyn_controllers:robodyn_mechanisms:robodyn_ros:robodyn_utilities:robot_instance
After that, change the permission of the script to executable and run the script. It would start downloading the packages.
chmod +x getPkg.sh ./getPkg.sh
Compiling the packages
Change directory to the r2_sim directory and compile the packages.
cd ~/r2_sim rosdep install -y -i --from-paths src catkin_make
TroubleshootingCan’t compile robot_instance packagerobot_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 foundIf 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:
#!/bin/bash source ~/.ros_clean source /opt/ros/indigo/setup.sh if [ -f ~/r2_sim/devel/setup.sh ] then source ~/r2_sim/devel/setup.sh else if [ -d ~/r2_sim/src ] then export ROS_PACKAGE_PATH=~/r2_sim/src:$ROS_PACKAGE_PATH fi fi
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 r2_ready_pose.py rosrun r2_supervisors_control r2_test.py
Troubleshooting
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.
References
- NASA Robonaut 2, https://robonaut.jsc.nasa.gov/R2/
- R2 gazebo simulation, https://gitlab.com/nasa-jsc-robotics/robonaut2/wikis/R2%20Gazebo%20Simulation