(!) 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 the newest version of the NAO Robot (V4, Intel Atom CPU) with Naoqi > 1.12.xx.

Tested from Ubuntu 12.10 64 bits

Install Nao crosscompilation toolchain

We'll call $TOOLCHAIN the path to the toolchain. For instance ~/nao/linux64-nao-atom-cross-toolchain-1.14.3

Layout

2.1- Create a directory for your cross-compilation artifacts, for instance ~/ros-nao. We'll refer to it as $ROOT

2.2- create $ROOT/ros-deps. We'll install here all ROS dependencies that we need to cross-compile. We'll call this prefix $ROSDEPS

3- Cross-compile external dependencies

3.1- poco:

- download poco-1.4.6 sources from http://pocoproject.org - create a new compile configuration for Nao by copying build/config/Linux to build/config/Nao, and editing the file to point to the Nao crosscompilation tools. Something like:

[...] # # Define Tools # CC = $TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-gcc CXX = $TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-g++ LINK = $(CXX) LIB = $TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ar -cr RANLIB = $TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ranlib SHLIB = $(CXX) -shared -Wl,-soname,$(notdir $@) -o $@ SHLIBLN = $(POCO_BASE)/build/script/shlibln STRIP = $TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-strip DEP = $(POCO_BASE)/build/script/makedepend.gcc SHELL = sh RM = rm -rf CP = cp MKDIR = mkdir -p [...]

- ./configure --prefix=$ROSDEPS --config=Nao --omit=Data,Zip,NetSSL_OpenSSL,Crypto,XML,Util,Data/ODBC,Data/MySQL,Net,CppUnit

- CC=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-gcc CXX=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-g++ LINK=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ld make

- make install

3.2- apr

- download apr-1.4.8 from apache - CC=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-gcc CXX=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-g++ LINK=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ld ./configure --prefix=$ROSDEPS

- make install - apr-util

  • - download apr-util-1.5.2 from apache - CC=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-gcc CXX=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-g++ LINK=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ld ./configure --prefix=$ROSDEPS --with-expat=builtin --with-apr=$ROSDEPS - make install

- log4cxx

  • - download apache-log4cxx-0.10.0, extract, cd to it

    - add '#include <cstring>' in src/main/cpp/inputstreamreader.cpp and src/main/cpp/socketoutputstream.cpp and '#include <cstring>' + '#include <cstdio>' in src/examples/cpp/console.cpp - CC=/home/lemaigna/applis/nao/linux64-nao-atom-cross-toolchain-1.14.3/cross/bin/i686-aldebaran-linux-gnu-gcc CXX=/home/lemaigna/applis/nao/linux64-nao-atom-cross-toolchain-1.14.3/cross/bin/i686-aldebaran-linux-gnu-g++ LINK=/home/lemaigna/applis/nao/linux64-nao-atom-cross-toolchain-1.14.3/cross/bin/i686-aldebaran-linux-gnu-ld ./configure --prefix=$ROSDEPS --with-apr=$ROSDEPS --with-apr-util=$ROSDEPS - cd src/main/cpp && cp .libs/liblog4cxx.a .libs/liblog4cxx.lai - make install

- collada_dom

  • - download collada-dom-2.4.0, extract, cd to it

    - mkdir build && cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DOPT_COLLADA14=OFF -DCMAKE_INSTALL_PREFIX=$ROSDEPS -DCMAKE_CXX_COMPILER=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-g++ -DCMAKE_CXX_FLAGS="--sysroot=$TOOLCHAIN/sysroot" -DCMAKE_C_COMPILER=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-gcc -DCMAKE_LINKER=$TOOLCHAIN/cross/bin/i686-aldebaran-linux-gnu-ld -DBoost_INCLUDE_DIR=$TOOLCHAIN/sysroot/usr/include -DBoost_LIBRARY_DIRS=$TOOLCHAIN/sysroot/usr/lib -DLIBXML2_INCLUDE_DIR=$TOOLCHAIN/sysroot/usr/include/libxml2 -DLIBXML2_LIBRARIES=$TOOLCHAIN/sysroot/usr/lib -DZLIB_INCLUDE_DIR=$TOOLCHAIN/sysroot/usr/include -DZLIB_LIBRARY=$TOOLCHAIN/sysroot/usr/lib - make install

3- Cross-compile ROS

3.1- wstool init src -j8 http://packages.ros.org/web/rosinstall/generate/raw/groovy/robot

3.2- Edit rostoolchain.cmake:

3.3- Fix issues:

-> replace tinyxml_LIBRARIES by TINYXML_LIBRARIES in rospack's CMakeLists

-> add log4cxx dependency to pluginlib CMakeLists. You can replace it with that:

cmake_minimum_required(VERSION 2.8.3) project(pluginlib)

find_package(catkin REQUIRED COMPONENTS class_loader rospack rosconsole roslib) find_package(Boost REQUIRED COMPONENTS filesystem system)

find_package(Log4cxx QUIET) if(NOT LOG4CXX_LIBRARIES)

  • # backup plan, hope it is in the system path find_library(LOG4CXX_LIBRARIES log4cxx) find_library(APR_LIBRARIES apr-1) find_library(APU_LIBRARIES aprutil-1) find_library(EXPAT_LIBRARIES expat)

endif() if(NOT LOG4CXX_LIBRARIES)

  • message(FATAL_ERROR "Couldn't find log4cxx library")

endif()

catkin_python_setup()

catkin_package(

  • INCLUDE_DIRS include LIBRARIES tinyxml CATKIN_DEPENDS class_loader rosconsole roslib DEPENDS Boost

)

-> add rospack to catkin components ("find_package(catkin REQUIRED ...") in nodelet and diagnostic_aggregator -> log4cxx dependency also missing in nodelets, diagnostic_aggregator, tf, topic_tools, rosbag -> library flags for apr, apr-util and expat missing in rosout

include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${LOG4CXX_INCLUDE_DIRS})

add_executable(plugin_tool src/plugin_tool.cpp) target_link_libraries(plugin_tool ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CXX_LIBRARIES} ${APR_LIBRARIES} ${APU_LIBRARIES} ${EXPAT_LIBRARIES} tinyxml)

install(TARGETS plugin_tool

  • RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

install(DIRECTORY include/pluginlib/

  • DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

install(FILES share/pluginlib/typed_class_loader_template.cpp

  • DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION})

if(CATKIN_ENABLE_TESTING)

  • add_library(test_plugins EXCLUDE_FROM_ALL SHARED test/test_plugins.cpp) catkin_add_gtest(${PROJECT_NAME}_utest test/utest.cpp) target_link_libraries(${PROJECT_NAME}_utest tinyxml ${catkin_LIBRARIES} ${Boost_LIBRARIES}) add_dependencies(${PROJECT_NAME}_utest test_plugins)

endif()

3.4- Remove collada_urdf (rm -rf src/collada_urdf): it requires assimp, and should be of much use on the robot. 3.4- Compilation:

./src/catkin/bin/catkin_make_isolated --install --cmake-args -DCMAKE_TOOLCHAIN_FILE=/home/lemaigna/src/rosnao/rostoolchain.cmake

Encountered errors:

- /home/lemaigna/src/rosnao/devel_isolated/rospack/lib/librospack.so: undefined reference to `TiXmlDocument::LoadFile(char const*, TiXmlEncoding)' -> replace tinyxml_LIBRARIES by TINYXML_LIBRARIES in rospack's CMakeLists

- undefined "memmove"/"memcopy" when compiling log4cxx: add #include <cstring> in failing files }}}

Wiki: nao/Installation/Cross-Compiling_Catkin (last edited 2014-10-03 09:35:51 by VincentRabaud)