Sitemap

Member-only story

Create ROS2 pkg for C++ and Python files

2 min readFeb 27, 2021

--

Press enter or click to view image in full size
Photo by Alex Knight on Unsplash

The Robot Operating System (ROS) is a set of software libraries and tools for building robot applications. From drivers to state-of-the-art algorithms, and with powerful developer tools, ROS has what you need for your next robotics project. And it’s all open source.

ROS2 is the next version of ROS which provides more features and deals with limitations from the previous version. ROS2 provides three types of build-depends as ament_cmake, ament_python, and cmake.

Recently I was working on a ROS2 project in which I was using ROS2 python to create the node. In this, I need to create a custom ROS2 msg-type. I searched for the tutorials and documents to create custom msgs in the ros2 pkg with build type ament_python.

But I didn’t find any way to build a custom msg in the python build type pkg.

So, to solve this problem, I created a new pkg in ros2 with build_type ament_cmake to build the custom messages. That’s how I solved the problem.

But that is not all. This is not how it should work. We can need to find a way to build the msgs, c++ files, and even python scripts. Luckily, I found this and will share the process.

  1. Create a ros2 pkg inside your colcon_ws
$ ros2 create pkg my_ros2_pkg --build-type --ament-cmake

--

--

Sachin Kumar
Sachin Kumar

Written by Sachin Kumar

Hi, I am a robotist enthusiast and electronics hobbyist