ROS2 Basics in 5 Days Humble (Python) - Interfaces (msg,srv,action)

Hi everyone

I’ve got a doubt. When I see the explanation to how to create my own interface, either in msg, srv or action.

One of the steps requiere change the CMakeList.txt , but when I create a python pkg doens’t have a CMakeList.txt.

Am I lose something?

Hi @Voltedge ,

In ROS2, if you build a package with build-type set to ament_python, you will only see package.xml and setup.py files. On the other hand, if you build a package with build-type as ament_cmake then you will have CMakeLists.txt and package.xml file.

Your package dependencies will show up directly in the package.xml file of both build-types. But in case of ament_cmake you would do the corresponding changes in a CMakeLists.txt file.

Do you remember the following steps that you do in ament_python package in the setup.py file?:

  1. import os and glob
  2. Add the path to launch folder to data_files
  3. Add the executable under entry_points console_scripts list

You do the above same thing in CMakeLists.txt file in case of a ament_cmake package, which are:

  1. add_executable(…) and ament_target_dependencies(…)
  2. Add the executable name to install(…)
  3. Add location of launch directory to install(…)

So, that is why the build-types with python and c++ are different, but in a similar way.
I hope you now understood the differences and the similarities!

Why is the packaging method this way?
Well, if you need to know this answer, then you must ask the ROS2 creators at Open Robotics!
My answer would be - to adapt to the design changes suitable for ROS Client Library in ROS2 and for a better and streamlined approach to making ROS2 packages.

Let me know if you are still unclear.

Regards,
Girish

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.