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.
- OS: Ubuntu 20.04 LTS
- ROS: Noetic Ninjemys
- Build: GCC 9+, CMake 3.15+
- Optinal: catkin tools
- Prepare catkin workspace:
mkdir -p workspace/src && cd src
catkin config --init --extend /opt/ros/noetic
- 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)
- Build (forcing CMake to run, no cache):
catkin build --force-cmake
- Source your workspace:
source devel/setup.bash
Now, you're ready to get going!
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]
C++ tests can be written in two ways:
- GoogleTest library (integrated into ROS).
- Catch2 v3 framework (external dependency).
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).
roslaunch catkin_template example.launch [ns:=<your-namespace>] [remap_to:=<your-remapping>]
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>]
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>'"
rosrun catkin_template cpp_cfg_server
Check reconfiguration server using RQT:
rosrun rqt_reconfigure rqt_reconfigure