Skip to content

PhD-Thesis-2024/catkin-project-template

Repository files navigation

Catkin project template

ROS Noetic Ninjemys

Overview

Template of catkin package for C++ and Python projects in ROS (Robot Operating System).

This project includes basic examples of pub/sub, custom messages and services, and dynamic reconfigure.

It provides standard ROS project structure and build/test pipeline using GitHub workflows.

Start your journey by clicking Use this template.

Requirements

  • OS: Ubuntu 20.04 LTS
  • ROS: Noetic Ninjemys
  • Build: GCC 9+, CMake 3.15+
  • Optinal: catkin tools

Instructions

  1. Prepare catkin workspace:
mkdir -p workspace/src && cd src
catkin config --init --extend /opt/ros/noetic
  1. Optinally, configure your workspace (CMake args, parallel jobs, etc.):
catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release -DCATKIN_ENABLE_TESTING=ON
catkin config --jobs $(nproc)
  1. Build (forcing CMake to run, no cache):
catkin build --force-cmake
  1. Source your workspace:
source devel/setup.bash

Now, you're ready to get going!

Tests

Before continuing any further, make sure CATKIN_ENABLE_TESTING CMake variable is ON (it is by default).

You can run all catkin-integrated tests (unittest, GoogleTest) using this command:

catkin test -t [run_tests]

Catch2 (C++)

C++ tests can be written in two ways:

It's really tricky to setup Catch2 with catkin. That's why we need to run tests manually:

cd build/catkin_template
ctest [-V]

This runs all the specified tests (unittest, nosetests, GoogleTest, Catch2).

Usage

1. Launch file

roslaunch catkin_template example.launch [ns:=<your-namespace>] [remap_to:=<your-remapping>]

2. Publisher/subscriber

Run ROS publisher (publishes Message.msg to /message by default):

rosrun catkin_template cpp_publisher [message:=<topic-remapping>]

Run ROS subscriber (subscribes to /message by default):

rosrun catkin_template cpp_subscriber [message:=<topic-remapping>]

3. Service

Run ROS service server (uses Service.srv, endpoint = /service):

rosrun catkin_template cpp_service_server [service:=<endpoint-remapping>]

Call service /service:

rosservice call /service "request: '<data>'"

4. Dynamic reconfigure

rosrun catkin_template cpp_cfg_server

Check reconfiguration server using RQT:

rosrun rqt_reconfigure rqt_reconfigure