Installing ROS Indigo onto NAO with help of virtual-nao
To put together ROS Indigo and naoqi-sdk 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 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!
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
Compile NAO ROS packages on the virual-nao
First of all, let's create our workspace.
mkdir -p my_workspace/src mkdir -p my_workspace/external cd my_workspace
Prepare the environment
On the terminal of the virtual robot, run the following commands:
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 tinyxml cxsparse cholmod poco log4cxx gtest
Because of the way emerge works, you actually need to call the emerge command twice to get the packages to install. If required, you will also need to follow the instructions to add the argument --autounmask-write to emerge and run sudo etc-update in between. Be sure to merge in the suggested config changes.
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:
Install SIP
cd external hg clone http://www.riverbankcomputing.com/hg/sip cd sip python build.py prepare python configure.py make sudo make install cd ../..
Install lz4
cd external svn checkout http://lz4.googlecode.com/svn/trunk/ lz4 cd lz4/ make sudo make install cd ../..
Install console_bridge
cd external git clone --depth 5 git://github.com/ros/console_bridge.git cd console_bridge cmake . make sudo make install cd ../..
Install urdfdom-headers
cd external git clone --depth 5 https://github.com/ros/urdfdom_headers.git urdfdom-headers cd urdfdom-headers cmake . -DCMAKE_INSTALL_PREFIX=/usr make sudo make install cd ../..
Install urdfdom
cd external git clone --depth 5 https://github.com/ros/urdfdom.git urdfdom cd urdfdom cmake . -DCMAKE_INSTALL_PREFIX=/usr make sudo make install cd ../..
Then add #define TIXML_USE_STL as the first line of /usr/include/tinyxml.h
touch ~/temp && echo '#define TIXML_USE_STL' | cat - /usr/include/tinyxml.h > ~/temp && sudo mv ~/temp /usr/include/tinyxml.h
Compile ROS packages for NAO
In the terminal of the virtual-nao, run the following commands to download the source code of necessary packages:
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 ..
Compile the code source by running:
src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
It will take awhile to compile all the packages, maybe long enough to finish a coffee
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.
Prepare dependencies:
cp /usr/lib/liblog4cxx* install_isolated/lib/ cp -r /usr/include/log4cxx install_isolated/include/ cp /usr/lib/libapr* install_isolated/lib/ cp -r /usr/include/apr* install_isolated/include/ cp /usr/lib/libtinyxml* install_isolated/lib/ cp /usr/lib/libPoco* install_isolated/lib/ cp -r /usr/include/Poco* install_isolated/include/ cp -r /usr/lib/liburdfdom* install_isolated/lib/ cp -r /usr/include/urdf* install_isolated/include/ cp -r /usr/lib/libcxsparse* install_isolated/lib/ cp -r /usr/lib/libcholmod* install_isolated/lib/ cp -r /usr/include/cholmod* install_isolated/include/ cp -r /usr/lib/liblz4* install_isolated/lib/ cp -r /usr/include/lz4* install_isolated/include/ cp -r /usr/local/lib/libconsole_bridge* install_isolated/lib/ cp -r /usr/local/include/console_bridge* install_isolated/include/ cp -r /usr/lib/python2.7/site-packages/* install_isolated/lib/python2.7/site-packages/ cp /usr/bin/rosversion install_isolated/bin/
Cleaning to send on robot:
rm -rf install_clean cp -r install_isolated install_clean rm -f `find install_clean/lib/python2.7/site-packages/ -name "*.pyc"` `find install_clean/lib/python2.7/site-packages/ -name "*.pyo"` rm -rf install_clean/include/ rm -f `find install_clean/ -name "*.cmake"` rm -f `find install_clean/ -name "package.xml"` rm -f `find install_clean/ -name "*.in"` rm -rf `find install_clean/ -type d -empty`
On your virtual-nao, copy everything onto your robot:
cd install_clean tar czvf ../install_ros.tar.gz . cd .. scp install_ros.tar.gz nao@<Your_NAO_IP>:/home/nao/
Connect by ssh to your real NAO then run the following commands:
ssh nao@<Your_NAO_IP> mkdir ros_install_folder cd ros_install_folder tar xzvf ../install_ros.tar.gz
Run the ros packages on NAO
From the terminal ssh-ed with your robot, execute:
cd ros_install_folder source setup.bash export ROS_MASTER_URI=http://<your NAO's IP>:11311 export ROS_IP=<your NAO's IP> roslaunch nao_bringup nao.launch force_python:=true
A generic way :
cd ros_install_folder source setup.bash export ROS_IP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'` export ROS_MASTER_URI=http://$ROS_IP:11311 roslaunch nao_bringup nao.launch force_python:=true
In another terminal ssh-ed with your robot, execute following commands to make your robot say "Hello":
cd ros_install_folder source setup.bash export ROS_MASTER_URI=http://<your NAO's IP>:11311 export ROS_IP=<your NAO's IP> rostopic pub /speech std_msgs/String hello
A generic way :
cd ros_install_folder source setup.bash export ROS_IP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'` export ROS_MASTER_URI=http://$ROS_IP:11311 rostopic pub /speech std_msgs/String hello
Have fun exploring!
Important note:
- 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.
- In case you want to compile your ros package with naoqiSDK-c++, you can get the naoqiSDK for cross compiling from Aldebaran website, then copy the folder libnaoqi-sysroot onto your virtual-nao, and set it to AL_DIR. After the AL_DIR setting, you should be able to compile your package with naoqiSDK successfully.
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) to run 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).