Installing ROS Indigo onto NAO or Pepper or Romeo with help of virtual-nao

This tutorial is evidently for advanced users, since it requires a rather solid understanding about cmake, cross-compiling and Linux. We will cross compile ROS on a Gentoo x32_86 architecture virtual machine, copy them on your robot or extract those components as a toolchain package in order to compile with qibuild.

Main steps of this tutorial:

  • Get a virtual-nao and cross-toolchain provided by Aldebaran Robotics (SoftBank)

  • Compile ROS packages on virtual-nao
  • Copy compiled files from virtual-nao to real NAO
  • Extract as a toolchain package
  • Locally enhance your toolchain with ROS
  • Deploy your qibuild application inclusive ROS

Now that everything is clear, let's get to actions!

Get the virtual-nao and the toolchain

Please contact Aldebaran Robotics if you don't have access to their software resources. Otherwise download them from https://community.aldebaran.com/. At the time of the writing, I use opennao-vm-2.1.0.19.

You can connect to that VM using your local terminal as explained on https://community.aldebaran-robotics.com/doc/2-1/dev/tools/vm-setup.html. Just ssh using:

$ ssh nao@localhost -p2222

This depends on how you configured your Virtual Machine. Personally, configuring the VM with a bridged network may ease the understanding since the VM will receive a IP just like a normal machine inside your network.

Compile ROS packages on the virual-nao

First of all, let's create our workspace.

We will create 2 separate workspaces, one for our catkin packages and the second one for external dependencies.

$ mkdir -p my_workspace/src
$ mkdir -p my_workspace/external
$ cd my_workspace

Prepare the external dependencies

There are quite some external packages, which have to be installed:

The idea here is to install them all in a single install folder such as my_workspace/ros_toolchain_install. Later we will install also our ROS catkin packages inside this folder, so that we can simply compress one single folder which contains all we need. Extract the packages above inside your external workspace and install them in my_workspace/ros_toolchain_install.

For example apache-log4cxx via autotools:

$ cd apache-log4cxx
$ ./configure --prefix=~/my_workspace/ros_toolchain_install
$ make 
$ make install

For example apr-1.5.1 via cmake:

$ cd apr-1.5.1
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=~/my_workspace/ros_toolchain_install ..
$ make
$ make install

You might run into problems compiling tinyxml. In case, follow the steps below: Then add #define TIXML_USE_STL as the first line of /usr/include/tinyxml.h

$ touch ~/temp && echo '#define TIXML_USE_STL' | cat - ~/my_workspace/ros_toolchain_install/include/tinyxml.h > ~/temp && sudo mv ~/temp ~/my_workspace/ros_toolchain_install/tinyxml.h

Some packages are not available to install from emerge, we will need to download the code source and install them by ourselves, following the below instructions:

It looks though, but it's not as bad as it looks :-)

Compile robot-specific ROS packages

So now that we have all dependencies, we can easily compile our catkin workspaces In the terminal of the virtual-nao, run the following commands to download the source code of necessary packages.

In case of using Nao robot:

$ rosinstall_generator roscpp roscpp_core std_msgs rospy sensor_msgs nao_meshes nao_robot --rosdistro indigo --deps > nao_ros_indigo.rosinstall
$ wstool init src nao_ros_indigo.rosinstall -j8
$ rosdep install --from-path src -i -y
$ cd src
$ rm -rf diagnostics/self_test diagnostics/test_diagnostic_aggregator
$ cd ..

In case of using Pepper robot:

$ rosinstall_generator roscpp roscpp_core std_msgs rospy sensor_msgs pepper_meshes pepper_robot --rosdistro indigo --deps > nao_ros_indigo.rosinstall
$ wstool init src nao_ros_indigo.rosinstall -j8
$ rosdep install --from-path src -i -y
$ cd src
$ rm -rf diagnostics/self_test diagnostics/test_diagnostic_aggregator diagnostics/diagnostic_aggregator
$ rm -rf pepper_robot/pepper_bringup
$ cd ..

Compile the code source by running:

$ src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=OFF -DCMAKE_INSTALL_PREFIX=~/my_workspace/ros_toolchain_install -j4 

This will most likely crash the first time, since it cannot find the libraries and includes of our previously installed external dependencies. However, we have now a setup.bash file inside our ros_toolchain_install folder. Source this and run it again.

$ source ~/my_workspace/ros_toolchain_install/setup.bash

It will take awhile to compile all the packages, maybe long enough to finish a coffee :-)

Once the compilation is done, a simple way of checking that your compilation runs successfully is by sourcing the setup.bash in your install folder and run a roscore.

$ source ~/my_workspace/ros_toolchain_install/setup.bash
$ roscore

Your roscore should launch correctly. In case it fails, go back and verify that you have all dependencies correctly installed and sourced.

Copy compiled files onto the real robot

So, the compilation finished without errors. That's a great news! Now we can move on to the awesome step: putting ROS onto your robot.

If you already compiled all your ROS applications directly on the virtual-nao you can simply copy the install folder on your robot.

$ scp -r ~/my_workspace/ros_toolchain_install nao@<your_robot_ip>:/home/nao/ros

And then simply run your ROS application on your robot

$ ssh nao@<your_robot_ip>
$ source /home/nao/ros/setup.bash
$ roscore
$ roslaunch my_app my_launch.launch

Extract ROS as a qibuild package

Alternatively to catkin, you can use Aldebaran tools such as qibuild and qitoolchains to compile and deploy your application. If you already setup with such an environment and you want to compile your ROS application with qibuild, we have to add our ROS install folder as a new qitoolchain package. To do so, we have to declare it as such and finally add it to our 32-bit qitoolchain.

$ echo "<package name=\"ros\" version=\"0.1\" />" >> ~/my_workspace/ros_toolchain_install/package.xml

In order to let qibuild find all our ROS components directly, we have to write a cmake-config file. Open up your favorite texteditor and add the following content to the file ~/my_workspace/ros_toolchain_install/share/ros/ros-config.cmake

message("configuring ROS libraries")
clean(ROS)

find_package(qibuild)
set(_root "${CMAKE_CURRENT_LIST_DIR}/../..")
get_filename_component(_root ${_root} ABSOLUTE)

file (GLOB LIBS ABSOLUTE ${_root} ${_root}/lib/*.so)
set(ROS_LIBRARIES
  ${LIBS}
  CACHE INTERNAL "" FORCE
)

set(ROS_INCLUDE_DIRS
${_root}/include
CACHE INTERNAL "" FORCE
)

qi_persistent_set(ROS_DEPENDS 
BOOST_THREAD;
BOOST_SIGNALS;
BOOST_REGEX;
BOOST_DATE_TIME;
BOOST_FILESYSTEM;
BOOST_UNIT_TEST_FRAMEWORK;
BOOST_PROGRAM_OPTIONS;
BZIP2;
PYTHON;
CURL;
TINYXML;
OPENCV2_CORE;
OPENCV2_IMGPROC;
OPENCV2_HIGHGUI;
OPENCV2_CALIB3D
)

export_lib(ROS)

Without going too much into details here, we basically declare the usual two cmake variables _LIBRARIES and _INCLUDE_DIRS. We find all libraries inside our ros_toolchain_install/lib folder and all header files in our ros_toolchain_install/include folder.

After this, we can zip our folder

$ cd ~/my_workspace/ros_toolchain_install
$ zip -r ros_toolchain_install.zip ./* .catkin

We copy it to our workstation where we have qibuild installed. Then we finally add it to our qitoolchains. We assume here, your cross-compiled robot toolchain is called linux32.

$ scp ros_toolchain_install.zip <user>@<my_workstation>
$ qitoolchain add-package -c linux32 ros_toolchain_install.zip

ROS is now in your toolchain as every other component and can be used inside your CMakeLists.txt

qi_use_lib( ROS )

Have fun exploring!

Important note:

  • During the compilation of ROS packages, if it complains about missing libraries, you should download the source code of these libraries then compile them and install them onto the machine.
  • Those missing libraries that you needed during compilation of ROS packages on the virtual-nao can be needed on the real robot (as they have the same OpenNAO architecture) to run ROS, so when your robot complains that some libraries <names> are not available, copy the respective installed libs from your virtual-nao to your real robot (don't forget to respect the folder structure).

Wiki: nao/Tutorials/Installation/compileFromVirtualNao (last edited 2016-08-01 11:43:42 by NataliaLyubova)