Note: This tutorial assumes that you have completed the previous tutorials: creating a ROS package.

Building a ROS Package

Description: This tutorial covers using rosmake to build a package, and rosdep to install system dependencies.

Tutorial Level: BEGINNER

Next Tutorial: Understanding ROS Nodes

System Dependencies

ROS packages sometimes require external libraries and tools that must be provided by the operating system. These required libraries and tools are commonly referred to as system dependencies. In some cases these system dependencies are not installed by default. ROS provides a simple tool, rosdep, that is used to download and install system dependencies.

ROS packages must declare that they need these system dependencies in the package manifest. Let's look at the manifest for the turtlesim package:

$ roscd turtlesim
$ cat manifest.xml
  • <package>
    
    ...
    ...
        <rosdep name="wxwidgets"/>
    
    </package>

As you can see turtlesim needs wxwidgets.

rosdep

rosdep is a tool you can use to install system dependencies required by ROS packages.

Usage:

rosdep install [package]

Download and install the system dependencies for turtlesim:

$ rosdep install turtlesim

If you installed using binaries you will see:

  • All required rosdeps installed successfully

Otherwise you will see the output of installing the dependencies of turtlesim:

  • set -o errexit
    set -o verbose
    
    
    if [ ! -f /opt/ros/lib/libboost_date_time-gcc42-mt*-1_37.a ] ; then
      mkdir -p ~/ros/ros-deps
      cd ~/ros/ros-deps
      wget --tries=10 http://pr.willowgarage.com/downloads/boost_1_37_0.tar.gz
      tar xzf boost_1_37_0.tar.gz
      cd boost_1_37_0
      ./configure --prefix=/opt/ros
      make
      sudo make install
    fi
    
    
    if [ ! -f /opt/ros/lib/liblog4cxx.so.10 ] ; then
      mkdir -p ~/ros/ros-deps
      cd ~/ros/ros-deps
      wget --tries=10 http://pr.willowgarage.com/downloads/apache-log4cxx-0.10.0-wg_patched.tar.gz
      tar xzf apache-log4cxx-0.10.0-wg_patched.tar.gz
      cd apache-log4cxx-0.10.0
      ./configure --prefix=/opt/ros
      make
      sudo make install
    fi
    
    if [ ! -f /opt/ros/lib/libboost_date_time-gcc42-mt*-1_37.a ] ; then
      mkdir -p ~/ros/ros-deps
      cd ~/ros/ros-deps
      wget --tries=10 http://pr.willowgarage.com/downloads/boost_1_37_0.tar.gz
      tar xzf boost_1_37_0.tar.gz
      cd boost_1_37_0
      ./configure --prefix=/opt/ros
      make
      sudo make install
    fi
    
    
    if [ ! -f /opt/ros/lib/liblog4cxx.so.10 ] ; then
      mkdir -p ~/ros/ros-deps
      cd ~/ros/ros-deps
      wget --tries=10 http://pr.willowgarage.com/downloads/apache-log4cxx-0.10.0-wg_patched.tar.gz
      tar xzf apache-log4cxx-0.10.0-wg_patched.tar.gz
      cd apache-log4cxx-0.10.0
      ./configure --prefix=/opt/ros
      make
      sudo make install
    fi

rosdep runs the bash script above and exits when complete.

Building Packages

Once all the system dependencies are installed, we can build our package that we just created.

Using rosmake

rosmake is just like the make command, but it does some special ROS magic. When you type rosmake beginner_tutorials, it builds the beginner_tutorials package, plus every package that it depends on, in the correct order. Since we listed rospy, roscpp, and std_msgs as dependencies when creating our ROS package, these packages (and their dependiencies, and so on) will be built by rosmake as well.

Usage:

rosmake [package]

Try:

$ rosmake beginner_tutorials

This previous command may take a while to finish. As it is running you should see some output like:

  • [ rosmake ] No package specified.  Building ['beginner_tutorials']
    [ rosmake ] Logging to directory
    [ rosmake ] /home/dbking/.ros/rosmake_output-2009-09-22-03-17-14
    [ rosmake ] [ 0 of 18  Completed ]
    [rosmake-0] >>> genmsg_cpp >>> [ make ]
    [rosmake-0] <<< genmsg_cpp <<< [PASS] [ 0.39 seconds ]
    [ rosmake ] [ 1 of 18  Completed ]
    [rosmake-0] >>> roslib >>> [ make ]
    ...
    ...
    ...
    [ rosmake ] [ 17 of 18  Completed ]
    [rosmake-0] >>> beginner_tutorials >>> [ make ]
    [rosmake-0] <<< beginner_tutorials <<< [PASS] [ 0.79 seconds ]

rosmake multiple packages

We can also use rosmake to build multiple packages at once.

Usage:

rosmake [package1] [package2] [package3]

So now let's build some packages that we'll need later in the next tutorials:

$ rosdep install rxtools
$ rosmake roscpp_tutorials rospy_tutorials rxtools

Review

Lets just list some of the commands we've used so far:

  • rosdep = ros+dep(endencies) : a tool to install package dependencies
  • rosmake = ros+make : makes (compiles) a ROS package

Now that you have built your ROS package let's more talk about ROS Nodes.

Wiki: ROS/Tutorials/BuildingPackages (last edited 2011-09-01 16:52:29 by DereckWonnacott)