Visual Servoing Platform  version 3.5.0 under development (2022-02-15)
Tutorial: Cross-compilation for NAOqi OS from Ubuntu host

This tutorial summarizes how to cross-compile ViSP from source using NAOqi atom cross toolchain provided by SoftBank Robotics for Nao, Romeo or Pepper robots. The aim of this cross-compilation is then to use the cross-build resulting ViSP libraries on these robots.

This tutorial was tested on an Ubuntu 14.04 LTS host computer with:

  • Cross Toolchain 2.3.1 Linux 64 (ctc-linux32-atom-2.3.1.23) on Romeo robot
  • Cross Toolchain 2.4.3 Linux 64 (ctc-linux64-atom-2.4.3.28) on Pepper robot

Install cross toolchain

Download the cross-toolchain that is compatible with your robot from https://developer.softbankrobotics.com/. Depending on the robot the version of the cross toolchain might change.

In this tutorial we will illustrate how to build ViSP for Pepper with ctc-linux64-atom-2.4.3.28 cross toolchain.

Create a workspace that contains the cross toolchain:

$ mkdir $HOME/softbank

and unzip the toolchain:

$ cd $HOME/softbank
$ unzip ctc-linux64-atom-2.4.3.28.zip

Get ViSP source code

Cross-compilation capabilities are fully supported since ViSP 3.0.1 release.

Create first a workspace dedicated to ViSP:

$ mkdir $HOME/soft

There are different ways to get ViSP source code in this workspace:

  • You can download a ViSP sources daily snapshot. Once downloaded, uncompress the file using
    $ tar xvzf visp-snapshot-yyyy-mm-dd.tar.gz --directory $HOME/soft
    
  • Or you get the cutting-edge ViSP from GitHub repository using the following command
    $ cd $HOME/soft
    $ git clone https://github.com/lagadic/visp.git
    
  • Or you can download the latest release (should be at least 3.0.1) as a zip or a tarball. Once downloaded, uncompress the file using either
    $ tar xvzf visp-x.y.z.tar.gz --directory $HOME/soft
    
    or
    $ unzip visp-x.y.z.zip -d $HOME/soft
    

We suppose now that ViSP source is in a directory denoted <source_dir>, for example $HOME/soft/visp

Cross-compiling ViSP from source

  • Create first a directory denoted <binary_dir> where you want to cross-compile ViSP. This directory will contain generated Makefiles, object files, and output libraries and binaries that could be later used on the Raspberry Pi.
    $ mkdir $HOME/soft/visp-build-ctc-linux64-atom-2.4.3.28
    
  • Enter <binary_dir> and configure the build:
    $ cd $HOME/soft/visp-build-ctc-linux64-atom-2.4.3.28
    $ cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/softbank/ctc-linux64-atom-2.4.3.28/toolchain.cmake ../visp
    
    Note
    To speed up the cross-compilation build step, you can turn off the build of the demos, examples, tests and tutorials using the following command:
    $ cmake -DCMAKE_TOOLCHAIN_FILE=$HOME/softbank/ctc-linux64-atom-2.4.3.28/toolchain.cmake ../visp -DBUILD_DEMOS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_TUTORIALS=OFF -DQI_WITH_TESTS=OFF
    
  • At this step, the following third-parties should be found: OpenCV, v4l2, libjpeg, libpng, pthread, zbar. This could be checked in ViSP-third-party.txt file where the you should find something similar to:
    $ more ViSP-third-party.txt
      OpenCV                      : yes
      Video For Linux Two         : yes
      libjpeg                     : yes
      libpng                      : yes
      pthread                     : yes
      zbar                        : yes
    
    Note
    zbar third-party is available with Cross Toolchain 2.3.1 Linux 64 (ctc-linux32-atom-2.3.1.23). This library is not present in Cross Toolchain 2.4.3 Linux 64 (ctc-linux64-atom-2.4.3.28).
  • Cross-compile ViSP
    $ make -j4 install
    

The resulting installation is available in $HOME/soft/visp-build-ctc-linux64-atom-2.4.3.28.

Install ViSP on NAOqi OS

The result of the cross-compilation could then be installed on Nao, Romeo or Pepper robot running NAOqi OS.

  • Copy the cross-build installation to Nao, Romeo or Pepper target:
    $ tar cvzf install.tar.gz install
    $ scp -r install.tar.gz nao@<your_robot_ip>:
    
  • Install ViSP: First move the libraries that were cross-build to a more friend location like $HOME/visp.
    $ ssh nao@<your_robot_ip>
    nao~ $ tar xvzf ~/install.tar.gz
    nao~ $ mv install visp
    nao~ $ rm ~/install.tar.gz
    
  • Add to LD_LIBRARY_PATH environment var the path to ViSP libraries:
    nao~ $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/visp/lib
    

Next tutorial

You are now ready to see the next Tutorial: How to create an application that uses ViSP on NAOqi OS that explains how to use ViSP as a 3rd party to build your own project on NAOqi OS for Nao, Romeo or Pepper robots.