Skip to content
gerkey edited this page Aug 7, 2015 · 52 revisions

ROS 2 examples

You should use one of the following operating systems:

  • Ubuntu Trusty 14.04
  • OS X Yosemite 10.10
  • Windows 8.1 with Visual Studio 14.0 2015

For Windows see: https://github.com/ros2/examples/wiki/Windows-Development-Setup

How to setup the development environment?

First make sure you have the ROS apt repositories added to your system, if not:

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
wget https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -O - | sudo apt-key add -

Also get the osrf (gazebo) debian repository:

sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-latest.list'
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -

Install GCC, G++ CMake, Python3 EmPy package (custom packages which don't collide) and setuptools:

sudo apt-get update
sudo apt-get install git wget
sudo apt-get install build-essential cmake python-empy python3-empy python3-setuptools python3-nose # python-empy and python3-empy from packages.ros.org
sudo apt-get install cppcheck libopencv-dev

The setuptools version shipped with Ubuntu Trusty is not recent enough - we require at least version 8.2 (see https://bitbucket.org/pypa/setuptools/pull-request/85/):

sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install -U setuptools

Then if you don't already have it, get Dirk's vcstool:

sudo apt-get install python3-vcstool

Create a workspace and clone all repos:

mkdir -p ~/ros2_ws/src
cd ~/ros2_ws
wget https://raw.githubusercontent.com/ros2/examples/master/ros2.repos
vcs import ~/ros2_ws/src < ros2.repos

Install one or more DDS implementations

RTI Connext

Add the following line to your .bashrc file:

export RTI_LICENSE_FILE=path/to/rti_license.dat

You also need a Java runtime installed to run the RTI code generator:

sudo apt-get install openjdk-7-jre

Choose one of the following options for RTI Connext.

Debian packages built by OSRF

These packages are not public due to pending license questions. Download the three Debian packages of the latest release from https://github.com/osrf/rticonnextdds-src/releases and install them using dpkg -i.

Note, if you have trouble wget'ing those .deb files, remember you have to be logged in because it is a private repo for now.

Also add to your .bashrc export NDDSHOME=/usr

Official binary packages from RTI

Install the packages provided by RTI - the Ubuntu 12.04 packages seem to work for us with Ubuntu 14.04. Source the rti_set_bash_5.1.0 file to set the NDDSHOME environment variable.

PrismTech OpenSplice

Add the following line to you .bashrc file:

export PTECH_LICENSE_FILE=path/to/prismtech.lic

Choose one of the following options for PrismTech OpenSplice.

Debian packages built by OSRF
sudo apt-get update
sudo apt-get install libopensplice64  # from packages.osrfoundation.org
Official binary packages from PrismTech

Install the packages provided by OpenSplice (we currently use 6.4.1p2). Source the release.com file to set the OSPL_HOME environment variable.

Build the prototype using the bootstrap script from ament_tools

cd ~/ros2_ws/
src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install

Note: if you are having trouble compiling all examples and this is preventing you from completing a successful build, you can usine AMENT_IGNORE is that same manner as CATKIN_IGNORE to ignore the subtree or remove the folder from the workspace. Take for instance: you would like to avoid installing the large opencv library. Well then simply $ touch AMENT_IGNORE file in the cam2image demo directory to leave it out of the build process.

Optionally build all packages in isolation:

src/ament/ament_tools/scripts/ament.py build --build-tests --symlink-install --isolated

Afterwards source the local_setup.* from the install / install_isolated folder.

Integration with Sublime Text 3

You might want to use the sublime package to integrate with the ament build system: https://github.com/ament/sublime-ament

Troubleshooting

OS X

Missing include with CLT 10.10.3

If you upgrade to CLT 10.10.3, you might get this error:

[100%] Building CXX object CMakeFiles/rmw_connext_cpp.dir/src/functions.cpp.o
In file included from /Users/william/ros2/src/ros2/rmw_connext/rmw_connext_cpp/src/functions.cpp:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iostream:38:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/ios:216:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/__locale:15:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/string:439:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/algorithm:628:
In file included from /Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/memory:604:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/iterator:341:10: fatal error: '__debug' file not found
#include <__debug>
         ^
1 error generated.
make[2]: *** [CMakeFiles/rmw_connext_cpp.dir/src/functions.cpp.o] Error 1
make[1]: *** [CMakeFiles/rmw_connext_cpp.dir/all] Error 2
make: *** [all] Error 2

I found this SO solution to work (http://stackoverflow.com/a/29576048/671658):

$ echo '#define _LIBCPP_ASSERT(x, m) ((void)0)' | sudo tee -a /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug > /dev/null

It can be undone with:

$ sudo rm /Library/Developer/CommandLineTools/usr/include/c++/v1/__debug

Missing symbol when opencv (and therefore libjpeg, libtiff, and libpng) are installed with Homebrew

If you have opencv installed you might get this:

dyld: Symbol not found: __cg_jpeg_resync_to_restart
  Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
  Expected in: /usr/local/lib/libJPEG.dylib
 in /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
/bin/sh: line 1: 25274 Trace/BPT trap: 5       /usr/local/bin/cmake

If so, to build you'll have to do this:

$ brew unlink libpng libtiff libjpeg

But this will break opencv, so you'll also need to update it to continue working:

$ sudo install_name_tool -change /usr/local/lib/libjpeg.8.dylib /usr/local/opt/jpeg/lib/libjpeg.8.dylib /usr/local/lib/libopencv_highgui.2.4.dylib
$ sudo install_name_tool -change /usr/local/lib/libpng16.16.dylib /usr/local/Cellar/libpng/1.6.17/lib/libpng16.16.dylib /usr/local/lib/libopencv_highgui.2.4.dylib
$ sudo install_name_tool -change /usr/local/lib/libtiff.5.dylib /usr/local/Cellar/libtiff/4.0.4/lib/libtiff.5.dylib /usr/local/lib/libopencv_highgui.2.4.dylib
$ sudo install_name_tool -change /usr/local/lib/libjpeg.8.dylib /usr/local/opt/jpeg/lib/libjpeg.8.dylib /usr/local/Cellar/libtiff/4.0.4/lib/libtiff.5.dylib

The first command is necessary to avoid things built against the system libjpeg (etc.) from getting the version in /usr/local/lib. The others are updating things built by Homebrew so that they can find the version of libjpeg (etc.) without having them in /usr/local/lib.

Clone this wiki locally