Robotics StackExchange | Archived questions

Define custom messages in python package (ROS2)

Is it possible to define custom messages in python package (using ament_python) in ROS2 (ROS2 Dashing)? The tutorials in the net only show how to build messages using ament_cmake.

Should i just:

or

Asked by OwlSoul on 2020-04-21 07:12:16 UTC

Comments

Just a comment, but:

Move all messages to separate package

this is almost always a good idea, as it separates your API definition from its implementation, which makes communicating with your implementation (ie: your nodes) much easier (as I now don't have to build "everything" just to get access to your messages).

Asked by gvdhoorn on 2020-04-21 07:44:02 UTC

I just published a similar question and found your post. I'm wondering if you ever found a solution? I have all my custom interfaces defined in their own package like you, but can't seem to use them in packages built with ament_python.

Asked by joaquingl on 2021-03-04 13:49:01 UTC

Nope. Never did find the answer after all.

Asked by OwlSoul on 2021-03-05 07:39:00 UTC

Oof, did you just end up using pre-defined messages? or use cmake built packages? Also, I realized that this tutorial with python scripts to test them yields the same error. I'm surprised this isnt addressed...

Asked by joaquingl on 2021-03-09 19:12:50 UTC

Yeah, I just ended up using a separate package for my custom messages, and built them with cmake.

Asked by OwlSoul on 2021-03-10 06:40:17 UTC

From this page: Recall that interfaces can currently only be defined in CMake packages. It is possible, however, to have Python libraries and nodes in CMake packages (using ament_cmake_python), so you could define interfaces and Python nodes together in one package.

It seems that installing ament_cmake_python should help. I have the same problem and I'm looking for a solution

Asked by Andromeda on 2021-07-10 14:53:40 UTC

Did you fix the problem?

Asked by Andromeda on 2021-07-14 14:59:47 UTC

I ended up using ament_cmake for my interfaces package

Asked by joaquingl on 2021-07-14 15:37:31 UTC

Answers