Update of August the 23rd 2016: official tutorial is found at ros.org. Please follow the official tutorial for up-to-date instructions.
============================================
It happens during my way to heaven that I have to make some ROS features run flawlessly on a NAO robot. During the installation, there is a lot of "challenges" to overcome. So, I make a note here to keep track of my stupidity. :-)
A bit of background:
- ROS: at the time of the writing, ROS Indigo just came out as the lastest distribution of ROS.
- Ubuntu: Ubuntu 14.04 also came out as the lastest distribution of its kind
- NAO: I'm working with a NAO with naoqi v2.0.2.17 installed. OpenNAO of naoqi is running under Gentoo not-that-up-to-date version (Linux i686 2.6.33.9-rt31-aldebaran-rt)
My mission is to install ROS on NAO to enable the use of some ROS features (such as: 3D object detection).
Installing ROS on NAO is more painful than I thought. A lot of missing libraries and out-of-date software environment slows down the installation.
To put together ROS Indigo and naoqi 2.0.2, I use a virtual-nao that runs OpenNAO to compile ROS packages, then install these compiled packages onto the real NAO. In this tutorial, I describe the steps I took to:
- Get a virtual-nao provided by the company Aldebaran Robotics
- Compile ROS packages on virtual-nao
- Copy compiled files from virtual-nao to real NAO
- And run it :-)
Now that everything is clear, let's get to actions!
Step 1. Get the virtual-nao
Please contact Aldebaran Robotics if you don't have access to their virtual-nao packages. At the time of the writing, I use opennao-virtual-nao-2.0.3
Step 2. Compile NAO ROS packages on the virual-nao
2.1 Prepare the environment
On the terminal of the virtual robot, run the following command:
- sudo bash -c 'echo app-portage/gentoolkit >> /etc/portage/package.keywords'
- sudo bash -c 'echo dev-python/setuptools >> /etc/portage/package.keywords'
- sudo emerge setuptools
- sudo easy_install rosdep rosinstall_generator wstool rosinstall rospkg empy nose catkin_pkg pyyaml netifaces
- sudo rosdep init
- rosdep update
- sudo emerge -u tinyxml cxsparse cholmod poco log4cxx
- hg clone http://www.riverbankcomputing.com/hg/sip && cd sip && python build.py prepare && python configure.py && make && sudo make install
- cd /home/nao && svn checkout http://lz4.googlecode.com/svn/trunk/ lz4 && make && sudo make install
- add #define TIXML_USE_STL as the first line of /usr/include/tinyxml.h
Important notes: During the compilation of NAO ROS packages, if it complains about missing libraries, you should use emerge or pip to install these missing libraries. If not, download the source code of these libraries then compile them and install them onto the machine
2.2. Compile ROS packages for NAO
In the terminal of the virtual-nao, run:
- mkdir -p nao_ros_ws/src && cd nao_ros_ws
- rosinstall_generator nao_robot --rosdistro indigo --deps > nao_ros_indigo.rosinstall
- wstool init src nao_ros_indigo.rosinstall
- cd src && wstool update -j4
- cd .. && rosdep install --from-path src -i -y
- cd src
- git clone https://github.com/ros/roslint
- git clone https://github.com/ros/xacro.git
- cd ..
- src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
Step 3. Copy compiled files onto the real robot
- On your virtual-nao, run:
- cd ork_nao_ros
- tar -cvf install_isolated.tar.gz install_isolated
- scp install_isolated.tar.gz nao@<Your_NAO_IP>:/home/nao/
- Connect by ssh to your real NAO then run the following command
- mkdir nao_ros_ws && mv install_isolated.tar.gz nao_ros_ws
- cd nao_ros_ws && tar -xcf install_isolated.tar.gz
- Open the file /home/nao/nao_ros_ws/install_isolated/lib/python2.7/site-packages/xapparser/__init__.py
- Add two following lines to the file previously opened:
#!/usr/bin/python
# --*-- coding: utf-8 --*--
- On your real NAO, check for required libraries to launch ROS nodes:
- rosversion: if not yet on your NAO, just copy it from the virtual-nao and put it into /usr/bin/ on your NAO
- rospkg: if not et available on your NAO, copy it from virtual-nao (normally, it is found in the folder /usr/lib.python2.7/site-packages/) and put it into .local/lib/python2.7/site-packages/ of your NAO.
- lz4, tinyxml, log4cxx, apr*, poco: if not yet available on your NAO, just copy them from virtual-nao to the real NAO in respective folders.
Step 4. Run the ros packages on NAO
From the terminal ssh-ed with your robot, execute:
- cd /home/nao/nao_ros_ws
- source install_isolated/setup.bash
- roslaunch nao_bringup nao.launch force_python:=true
- roslaunch nao_driver nao_camera.launch
Important note:
Those missing libraries that you needed during compilation of NAO ROS packages on the virtual-nao can be needed on the real NAO (as they have the same OpenNAO architecture) when running ROS, so when NAO complains that some libraries <names> are not available, copy the respective installed libs from your virtual-nao to your real NAO (don't forget to respect the folder structure).
For example, when launching nao_bringup, NAO will complains that it does not have lz4 and tinyxml. To solve this, I copy those files with the name containing "lz4" and "tinyxml" in /usr/lib, /usr/bin/, /usr/include/ of virtual-nao and paste these files to their respective folders on my real NAO (Hint: scp is your best assistance for copying files)