Skip to content
Esteve Fernandez edited this page Apr 27, 2015 · 52 revisions

ROS 2 examples

(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 -
$ sudo apt-get update

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 -
$ sudo apt-get update

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 GCC, G++ CMake, Python3 EmPy package (custom packages which don't collide) and setuptools:

$ sudo apt-get update
$ sudo apt-get install build-essential cmake python-empy python3-empy python3-setuptools # python-empy and python3-empy from packages.ros.org
$ sudo apt-get install cppcheck

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

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.

And two packages from here: https://github.com/osrf/rticonnextdds-messaging/releases/tag/ubuntu%2Ftrusty%2F5.1.0-3

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

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

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
Clone this wiki locally