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 word about the 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 ORK on NAO to enable the 3D vision recognition. ORK is Object Recognition Kitchen, originally developed at Willow Garage and then maintained by open source community. I work directly with Vincent Rabaud, one of the main maintainer of ORK, and ROS (yeah, he's one important guy!).
Installing NAO ROS packages and ORK ROS packages on NAO is more painful than I thought. A lot of missing libraries and out-of-date software environment slows down the installation.
Below are steps I took to put together ORK, NAO ROS package and naoqi 2.0.2.
- Get a virtual-nao provided by the company Aldebaran Robotics
- Compile NAO ROS packages and ORK on the virtual-nao
- Copy compiled files from virtual-nao to real NAO
- And run it :-)
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
2. Compile NAO ROS package and ORK 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 gtest log4cxx
- dev-python/sip (hg clone http://www.riverbankcomputing.com/hg/sip && cd sip && python build.py && python configure.py && make && sudo make install)
- lz4 (svn checkout http://lz4.googlecode.com/svn/trunk/ lz4 && make && sudo make install)
- nano /usr/include/tinyxml.h
- add #define TIXML_USE_STL as the first line of tinyxml.h
for ORK:
- sudo emerge -u lz4 ogre ghull ogre
- assimp (git clone git://github.com/assimp/assimp.git) then make and install as instructed
- cd /home/nao
- git clone https://github.com/joelburget/assimp
- cd assimp/include
- su
- cp * /usr/include/
Important notes:
- During the compilation of NAO ROS packages and ORK 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. Install NAO ROS packages
In the terminal of the virtual-nao:
- mkdir -p nao_ros_ws/src
- 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
- git clone https://github.com/hris2003/nao_camera
- cd ..
- src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
2.3. Install ORK packages
Setting up the compilation environment:
In the terminal of the virtual-nao
- cd ~/worktree
- mkdir src
- rosinstall_generator object_recognition_core object_recognition_ros --rosdistro indigo deps > ork_indigo.rosinstall
- wstool init src ork_indigo.rosinstall
- cd src && wstool update -j4
- cd .. && rosdep install --from-path src -i -y
- cd src
- rm -fr pcl_*
- rm -fr conversion_pcl
- rm -fr rviz
- nano ecto_image_pipeline/CMakeLists.txt then delete the line 8: find_package(PCL REQUIRED) then Ctrl+o, y, then Ctrl+x
- nano object_recognition_ros/CMakeLists.txt then delete the all the "rviz" words
- nano object_recognition_ros/src/CMakeLists.txt then comment out the line 4: add_subdirectory(rviz_plugin) then Ctrl+o, y, then Ctrl+x
- src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release
Important notes: While compiling, if some package complains for not finding Boost, just go to the cmake file that causes the error, change the respective line to something like Boost <your boost version value, like 1.55>
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 --*--
For ORK:
- On your computer, run:
- cd ~ && mkdir ork_nao_ros && cd ork_nao_ros
- mkdir ork && cd ork
- scp -r -P 2222 nao@localhost:/home/nao/worktree/install_isolated .
- cd .. && mkdir nao_ros cd nao_ros
- scp -r -P 2222 nao@localhost:/home/nao/nao_ros_ws/install_isolated .
- cd ../..
- tar -cvf ork_nao_ros.tar.gz ork_nao_ros
- scp ork_nao_ros.tar.gz nao@<YOUR_NAO_IP>:.
- Connect by ssh to your real NAO then run the following command
- tar -xcf ork_nao_ros.tar.gz
- source ork_nao_ros/ork/install_isolated/setup.bash
- source ork_nao_ros/nao_ros/install_isolated/setup.bash
- 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: if not yet available on your NAO, just copy them from virtual-nao to the real NAO in respective folders.
From the terminal ssh-ed with your robot, execute ROS NAO service:
- cd /home/nao/nao_ros_ws
- source install_isolated/setup.bash
- export ROS_MASTER_URI=http://<your_NAO_IP>:11311
- export ROS_IP=<your_NAO_IP>
- roslaunch nao_camera python.launch
From your remote machine, you need to declare the ROS master information and configure couchDB to enable remote access to ORK database, as explained below:
Declare ROS_MASTER_URI and ROS_IP as previously done on your NAO. Then run:
- rosrun rviz rviz (for the sake of the visualization, configuration as follows: http://wg-perception.github.io/tabletop/index.html#tabletop)
- rosrun rqt_reconfigure rqt_reconfigure
- then change the camera to depth_camera, and don't forget to check the "use ROS time" option
Configure couchDB for remote access:
- edit /etc/couchdb/local.ini and /etc/couchdb/default.ini to have: [httpd] port = 5984 bind_address = 0.0.0.0
- then restart couchdb service by: sudo service couchdb restart
For ORK, on your NAO, run:
- Edit the configuration file for ORK_tabletop:
- You can find the config file in the folder nao_camera downloaded in the step 2.2
- Copy that file onto your NAO, then open to edit the file
- At the end of the file, where it defines config information of couchDB, modify the root ip to your remote couchDB
- rosrun object_recognition_core detection -c <config_file>
Now you should be able to see, on your rviz interface, the tables and objects which are detected by ORK. Just make sure that you have uploaded some objects to your remote couchDB. For example, information of a coke can can be added easily if you follow instruction in ork_tutorials.
Enjoy the viewing! :-)
Important note:
Those missing libraries that you needed during compilation of NAO ROS packages and ORK 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 of nao_ros_ws/install_isolated on my real NAO (Hint: scp is your best assistance)
Heaven, here I come!