(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

ROS Fuerte Cross-Compiling and Installation for the NAO V4

Description: This tutorial is a step by step guide to build, install and run ROS natively onto the Intel Atom CPU of the latest NAO robot.

Keywords: Nao, Cross-compile

Tutorial Level: INTERMEDIATE

NOTE: This tutorial assumes the use of ROS fuerte, Ubuntu 10.04, the newest version of the NAO Robot (V4, Intel Atom CPU) with Naoqi > 1.12.xx.

Spanish version of this tutorial

Introduction

This tutorial provides a step by step guide to build, install and run the latest version of ROS (fuerte) embedded onto the new NAO robot V4, which has an Intel Atom CPU. A cross-compilation is performed using the toolchain supplied by Aldebaran. This procedure has been tested on Naoqi versions > 1.12.xx and it has been only supported by ubuntu 10.04. This has been tested in several NAO robots and different computers, using both virtual machines (vmware) as native linux. Still, we believe that it should be tested on more machines and robots.

This ROS Installation is located in "/home/nao". Then it is copied to the same path in the NAO robot to maintain links and paths for the ROS environment variables. Installation is done in that path to avoid using root permissions and considering that the robot has this path as default user folder.

This tutorial is based on nao/Tutorials/Cross-Compiling

Requirements

$ sudo apt-get install python-rosinstall
$ rosinstall --catkin ~/ros-underlay http://ros.org/rosinstalls/fuerte-ros-base.rosinstall

If an actonlib error appears, see actionlib-error

  • Download this script paths-nao-ctc.sh to setup paths, environment variables, and directories. Or create a text file with the content shown below and save it as a .sh script. For example "paths-nao-ctc.sh". If necessary, modify paths or directories' name as needed.

# set some environment variables and generates directories 
export TARGETDIR=/home/nao/ros-nao #ROS-NAO root path 
export ROS_FUERTE_DIR=$TARGETDIR/ros/fuerte #ROS fuerte installation path 
export ROS_STACKS_DIR=$ROS_FUERTE_DIR/stacks #ROS fuerte stacks installation path 
export CTC_DIR=/home/nao/nao-atom-cross-toolchain-1.12.5.3_2012-06-03 # Directory where Aldebaran's cross-compilation toolchain (CTC) was uncompressed 
export CTC_USR_DIR=$CTC_DIR/sysroot/usr # Set here your CTC user path 
export ROS_BOOST_ROOT="${CTC_DIR}/sysroot/usr"  # Set here your CTC boost root path 
export ROS_BOOST_VERSION="1.45.0"      # Set here your CTC boost version 
export BOOST_ROOT="${CTC_DIR}/sysroot/usr"   # Global boost root path 
export LD_LIBRARY_PATH= # To clear this ROS environment variable 
mkdir -p $TARGETDIR 
mkdir  -p $ROS_FUERTE_DIR 
mkdir  -p $ROS_STACKS_DIR 
mkdir -p $TARGETDIR/lib 
mkdir -p $TARGETDIR/python 
echo Paths and Directories generated ...

Recommendations and preliminary steps

In order to make the installation of basic libraries and tools required by ROS easier, in those cases where this tutorial is made in a newly formatted computer for example. It is recommended follow the basic installation of ROS-Comm (Bare Bones) as it is indicated in fuerte/Installation/Ubuntu, just up to step 1.4. This will install libraries, software, and tools required by ROS such as python, git, cmake, among others.

To include NAO's toolchain within ROS build toolchain:

$ echo "include(\"$CTC_DIR/toolchain-atom.cmake\")" >>  ~/ros-underlay/ros/core/rosbuild/rostoolchain.cmake

This is equivalent to opening the file "~/ros-underlay/ros/core/rosbuild/rostoolchain.cmake" and include at bottom the NAO toolchain path.

Perform the patch (step 4.5) from nao/Tutorials/Cross-Compiling. To perform that, open this file "~/ros-underlay/ros/core/rosbuild/private.cmake" and find lines 181 and 221 that show:

find_file(_file_name ${file} ${PROJECT_SOURCE_DIR} /)

Replacing it by:

find_file(_file_name ${file} ${PROJECT_SOURCE_DIR} / NO_CMAKE_FIND_ROOT_PATH)

Since NAO's toolchain does not contains "log4cxx.so" nor "aprutil*.so" libraries, these should be copied:

$ cp /usr/lib/liblog4cxx*.so* $CTC_USR_DIR/lib/
$ cp -r /usr/include/log4cxx $CTC_USR_DIR/include/
$ cp /usr/lib/libapr*.so* /$CTC_USR_DIR/lib/

Compiling ROS Base from source

Generate the project using cmake:

$ cd ~/ros-underlay
$ mkdir build
$ cd build
$ cmake .. -DCMAKE_INSTALL_PREFIX=$ROS_FUERTE_DIR
$ make -j8
$ make install

If linking errors appear (typically with boost), open the project using cmake-gui, delete cache, configure, and find the ROS toolchain file in "~/ros-underlay/ros/core/rosbuild/rostoolchain.cmake". Before generating it, DO NOT FORGET set the installation path in the tab "CMAKE-INTSALL-PREFIX = /home/nao/ros-nao/ros/fuerte" or your preferred installation path.

If the above method does not work, replace the nao toolchain include ​​in step 3.1, with:

include(\"$CTC_DIR/cross-config.cmake\")

For testing the current installation:

$ cd $ROS_FUERTE_DIR
$ . setup.sh
$ which roscore

The terminal should indicate the roscore executable path.

ROS_FUERTE_DIR/bin/roscore

To download, build and generate packages in the future, it is recommended to enable, download and install some tools. Follow fuerte/Installation/Ubuntu/Source from step 1.3 (Build Higher-level/tools) to 1.7.ii (Install core library dependencies).

Creating a workspace

It is useful to create a workspace. ROS fuerte includes a tool to do that easily (based on fuerte/Installation/Overlays).

$ rosws init $TARGETDIR/workspace_nao $ROS_FUERTE_DIR
$ cd $TARGETDIR/workspace_nao
$ mkdir $TARGETDIR/workspace_nao/sandbox 
$ source $TARGETDIR/workspace_nao/setup.bash
$ rosws set $TARGETDIR/workspace_nao/sandbox

It is convenient to specify a path to download and install stacks:

$ rosws set $ROS_STACKS_DIR
$ source $TARGETDIR/workspace_nao/setup.bash

If an error like "already exists" is shown, this is because stack path has already been added by default during ROS installation. If an error about ".rosinstall" ocurred, just delete it and try again.

$ rm $ROS_STACKS_DIR/.rosinstall

Check the working path running the following command:

$ roscd

It should show:

TARGETDIR/workspace_nao

Also, when echo the ROS packages environment variable, added paths with rosws should appear and share default stack directories too.

$ echo $ROS_PACKAGE_PATH
/home/nao/ros-nao/workspace_nao/sandbox:/home/nao/ros-nao/ros/fuerte/stacks:/home/nao/ros-nao/ros/fuerte/share:/home/nao/ros-nao/ros/fuerte/share/ros

It is convenient if the ROS environment variables are automatically added to your bash session every time a new shell is launched, which you can do with the command below:

$ echo "source /home/nao/ros-nao/workspace_nao/setup.bash" >> ~/.bashrc
$ . ~/.bashrc

If you have modified the installation path or the workspace name, you should change the "setup.bash" path as appropriate.

Copying some files, scripts and missing libraries

It is necessary to copy some files, scripts and libraries that are missing on the NAO. These files are needed for launching ROS on the NAO's CPU.

$ cp -r /usr/lib/python2.6/dist-packages/yaml $TARGETDIR/python/
$ cp -r -L /usr/lib/pymodules/python2.6/rospkg* $TARGETDIR/python/
$ cp /usr/lib/liblog4cxx*.so* $TARGETDIR/lib/
$ cp /usr/lib/libapr*.so* $TARGETDIR/lib/
$ cp -r $CTC_USR_DIR/lib/libboost* $TARGETDIR/lib/
$ cp -L /usr/lib/python2.6/dist-packages/pkg_resources.py $TARGETDIR/python/ 

Setting some environment variables

It is necessary to specify to ROS the path where files, scripts and libraries were added in the previous step. This should be done by exporting the environment variables shown below, or running this script setupPaths_NaoROS.sh, modifying paths as appropriate to your installation.

export LD_LIBRARY_PATH=/home/nao/ros-nao/lib:$LD_LIBRARY_PATH 
export PYTHONPATH=$PYTHONPATH:/home/nao/ros-nao/python
source /home/nao/ros-nao/workspace_nao/setup.bash

These commands or script must be run on each terminal where some ROS task will be run. We recommend adding commands to your ~ /.bashrc in order to make easy the ROS start up when we are working on a desktop computer.

Installing and running ROS onto NAO's CPU

To install ROS in the NAO, just copy the installation root folder to the robot via ssh:

$ export NAOIP=192.168.xx.xxx
$ rsync -rv $TARGETDIR nao@$NAOIP:/home/nao

"NAOIP=192.168.xx.xxx" is your NAO's IP adress. Remember that $TARGETDIR necessarily must match the installation path indicated in the robot (/home/nao/ in this case).

For testing the installation on the NAO:

$ ssh nao@NAOIP
$ cd $TARGETDIR
$ . ./setupPaths_NaoROS.sh
$ roscore

Replace $TARGETDIR by your "setupPaths_NaoROS.sh" script path.

Final considerations and future work

Naoqi 1.12.xx uses python 2.6, version found by default in Ubuntu 10.04. In order to carry out this tutorial on later versions of Ubuntu, python 2.6 (sudo apt-get install python2.6) could be installed and tell cmake to use that version. This procedure has not been tested properly, if someone do that and share it, it would be a great to complement to this page. Also if you have other contributions or comments that may enrich this tutorial, these are welcome.

In the robotics lab. at the University of Chile, we are currently using this installation of ROS for the NAO robot within activities of our robotic soccer team that participates in the RoboCup SPL. Up to date we have integrated Aldebaran's NAO motion and recently we achieve to encapsulate the B-Human walk too, which is much faster. We are working on a ROS platform for integrating different motion, cognition and self localization modules. Modules that could be developed by us or by other research groups. This, by using integration, compilation, debug and inter-process communications ROS tools. We want to upload to the ROS community a version of our stack soon, once obtained the relevant permits and after carried out ​​appropriate stability testing of the code.


Thanks to (Daniel Maier) by all the previous work and to Markus Bader from (The Austrian-Kangaroos SPL Team) for their valuable contributions.

U. Chile Robotics Team Department of Electric Engineering - Advanced Mining Technology Center / Universidad de Chile.

Author: Leonardo Leottau Forero

e-mail: dleottau@ing.uchile.cl

Wiki: nao/Installation/Cross-Compiling_NAO-V4 (last edited 2014-10-03 09:33:46 by VincentRabaud)