Catkin Packages#

What you will need

  • New ROS DTProject as described here

What you will get

  • Learn how to create a new catkin package inside a DTProject

ROS uses the catkin build system to organize and build its software. IIf unfamiliar with catkin, follow the official tutorials.

In a nutshell, catkin organizes entire projects in the so-called catkin workspaces, which are directories containing software modules called catkin packages. Each module can include executables (e.g., binaries, script files) known as ROS nodes. Nodes interact with one another using two of the most common communication patterns, called publish-subscribe and request-reply.

ROS implements the publish-subscribe pattern using ROS Publishers and ROS Subscribers, and the request-reply pattern using ROS Services.

Catkin workspace#

The packages/ directory at the root of a DTProject serves as the catkin workspace.

Create a new Catkin package#

Open a terminal at the root of the DTProject my-ros-project. Catkin packages are directories inside the directory packages/ of my-ros-project. Create a new package directory:

mkdir -p ./packages/my_package

A Catkin package (also known as a ROS package) requires two files: package.xml and CMakeLists.txt.

  1. Create packages/my_package/package.xml with the following content:

<package>
  <name>my_package</name>
  <version>0.0.1</version>
  <description>
  My first Catkin package in Duckietown.
  </description>
  <maintainer email="[email protected]">YOUR_FULL_NAME</maintainer>
  <license>None</license>

  <buildtool_depend>catkin</buildtool_depend>
</package>

Replace YOUR_FULL_NAME and [email protected] accordingly.

  1. Create packages/my_package/CMakeLists.txt with the content:

cmake_minimum_required(VERSION 2.8.3)
project(my_package)

find_package(catkin REQUIRED COMPONENTS
  rospy
)

catkin_package()

We now have a Catkin package inside a Catkin workspace in a ROS-capable DTProject. We can now proceed to add ROS nodes.