Skip to content

Installation using Virtual Machine

rqg0717 edited this page Aug 31, 2016 · 35 revisions

Overview

To install ROS Indigo on Nao, we need to cross compile ROS required system dependencies on a Gentoo x32_86 architecture virtual machine, and then copy them on to our real Nao robot. Since no compiler is available on the robot itself, we have to prepare binary packages on a virtual-nao.

Installation

1. Setting up the virtual-nao

Note: For both real Nao and virtual-nao the main user is nao, and like any GNU/Linux system, there is a super-user root. By default, passwords are usernames. Therefore, changing user to root using the su command will request the password root . e.g.

$ ssh nao@192.168.1.2
login: nao
password: nao
nao [0] ~ $ su
password: root
root@nao [0] ~ $
  • Create directories "/home/opt/portage" and "/home/opt/tmp".
  • Edit "/usr/share/portage/config/make.globals" and replace "/usr/portage" with "/home/opt/portage", replace "/var/tmp" with "/home/opt/tmp".
nano /usr/share/portage/config/make.globals
  • Move non-critical /usr subdirectories to /opt e.g.
mkdir -p /home/opt/usr
cp -a /usr/share /home/opt/usr/share
rm -rf /usr/share
ln -sf /home/opt/usr/share /usr/share
  • Upgrade CMake to cmake-3.0.0 or up. Download and build CMake from source here
wget https://cmake.org/files/v3.6/cmake-3.6.1.tar.gz
tar xzvf cmake-3.6.1.tar.gz
cd cmake-3.6.1
./bootstrap --prefix=/usr
make
make install

2. Preparing the external dependencies on the virtual-nao

Create a folder for the external dependencies and ROS packages, e.g /home/nao/ros_toolchain_install. Later we can simply copy one single folder onto the real Nao.

  • Install apr-1.5.2.
wget ftp://apache.mirrors.tds.net/pub/apache.org//apr/apr-1.5.2.tar.gz
tar xzvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/home/nao/ros_toolchain_install
make
make install
  • Install apr-util-1.5.4.
cd ../apr-util-1.5.4
./configure --prefix=/home/nao/ros_toolchain_install --with-apr=/home/nao/ros_toolchain_install
make
make install
  • Install apache-log4cxx-0.10.0.
wget http://mirror.cc.columbia.edu/pub/software/apache/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz
tar xzvf apache-log4cxx-0.10.0.tar.gz
cd ../apache-log4cxx-0.10.0

./configure --prefix=/home/nao/ros_toolchain_install --with-apr=/home/nao/ros_toolchain_install --with-apr-util=/home/nao/ros_toolchain_install

make && make install

Note: The first time you install log4cxx, you must modify the following source code:

  1. nano src/main/cpp/inputstreamreader.cpp and add #include <string.h> e.g.
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/inputstreamreader.h>
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/bytebuffer.h>
//add the following line
#include <string.h>

this will fix inputstreamreader.cpp:66: error: 'memmove' was not declared in this scope make[3]: *** [inputstreamreader.lo] error 1

  1. nano src/main/cpp/socketoutputstream.cpp and add #include <string.h> e.g.
#include <log4cxx/logstring.h>
#include <log4cxx/helpers/socketoutputstream.h>
#include <log4cxx/helpers/socket.h>
#include <log4cxx/helpers/bytebuffer.h>
//add the following line
#include <string.h>

this will fix socketoutputstream.cpp:52: error: 'memcpy' was not declared in this scope

  1. nano src/examples/cpp/console.cpp and add #include <string.h>, #include <stdio.h>.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//add the above lines
#include <log4cxx/logger.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/simplelayout.h>
#include <log4cxx/logmanager.h>
#include <iostream>
#include <locale.h>

this will fix: console.cpp: In function 'int main(int, char**)': console.cpp:58: error:'puts' no declaration

  • Install bzip2 1.0.6.
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
make -n install PREFIX=/home/nao/ros_toolchain_install
  • Install console_bridge.

Note: If you do not want to upgrade GCC to 4.7 or up, the first time you install console_bridge, you must modify CMakeLists.txt file as follows:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")

changed to

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -Wextra")

and then

git clone https://github.com/ros/console_bridge.git
cd console_bridge
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install

You would need to do the similar modification for other dependencies. Upgrading GCC might be a good way to prevent that; however, Gentoo GCC upgrading would be a pain in xxx. You can find Gentoo GCC Upgrade Guide here. The official way to do upgrading basically involves re-compiling your entire system twice, so good luck with it : )

  • Install curl 7.43.
wget http://curl.haxx.se/download/curl-7.43.0.tar.gz
tar xzvf curl-7.43.0.tar.gz
cd curl-7.43.0
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install
  • Install Expat-2.1.0.
wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
tar xzvf expat-2.1.0.tar.gz
cd expat-2.1.0
./configure --prefix=/home/nao/ros_toolchain_install
make
make install
  • Install lz4.
wget https://github.com/Cyan4973/lz4/archive/r131.tar.gz
tar xzvf r131.tar.gz
cd lz4-r131
make
make -n install PREFIX=/home/nao/ros_toolchain_install

You may need to run make && make install twice afterward. Do not know why for now...

  • Install tinyxml.

Before compile add #define TIXML_USE_STL as the first line in tinyxml.h, and then modify xmltest.cpp and move #include "tinyxml.h" to the first line.

wget https://sourceforge.net/projects/tinyxml/files/tinyxml/2.6.2/tinyxml_2_6_2.tar.gz
tar xzvf tinyxml_2_6_2.tar.gz
cd tinyxml
make

TinyXML does not install a FindTinyXML.cmake file on its own, instead a custom one must be provided, please refer to How to use TinyXML.

  • Install netifaces.
wget https://pypi.python.org/packages/source/n/netifaces/netifaces-0.10.4.tar.gz#md5=36da76e2cfadd24cc7510c2c0012eb1e
tar xzvf netifaces-0.10.4.tar.gz
cd netifaces-0.10.4
python setup.py install --prefix=/home/nao/ros_toolchain_install
  • Install poco 1.6.1.
wget http://pocoproject.org/releases/poco-1.6.1/poco-1.6.1.tar.gz
tar xzvf poco-1.6.1.tar.gz
cd poco-1.6.1
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install
  • Install sip.
wget https://sourceforge.net/projects/pyqt/files/sip/sip-4.18.1/sip-4.18.1.tar.gz
tar xzvf sip-4.18.1.tar.gz
cd sip-4.18.1
python configure.py --destdir /home/nao/ros_toolchain_install
make
make install
  • Install urdfdom_headers and urdfdom.
git clone https://github.com/ros/urdfdom_headers.git
cd urdfdom_headers
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install

git clone https://github.com/ros/urdfdom
cd urdfdom
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install
  • Install yaml-cpp.
wget https://github.com/jbeder/yaml-cpp/archive/release-0.3.0.tar.gz
tar xzvf release-0.3.0.tar.gz
cd yaml-cpp-release-0.3.0
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install
  • Install zlib.
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
cmake -DCMAKE_INSTALL_PREFIX=/home/nao/ros_toolchain_install
make
make install

3. Compile robot-specific ROS packages

Please refer to Compile from VirtualNao. Please note that currently only ROS Indigo is supported, so we do not need to install or update it on the real Nao. All we need to do here is to update the nao_robot to the latest version for the real Nao. The latest version of nao_robot is 0.5.14.

$ pip install -U catkin_pkg rosdep rosinstall_generator wstool rosinstall empy
$ rosinstall_generator nao_robot --rosdistro indigo --deps > nao_ros_indigo.rosinstall
$ wstool init src nao_ros_indigo.rosinstall -j8
$ cd src
$ rm -rf diagnostics/self_test diagnostics/test_diagnostic_aggregator

Compile the source code.

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

If you encountered any dependencies missing error, please go back to Preparing the External Dependencies and install the dependencies again. If the worst comes to the worst, please use pip not emerge. Emerge sucks period.

4. Copying compiled files onto the real Nao

Using WinSCP or ssh, copy and replace the existed folders on the real Nao.