Define custom messages in python package (ROS2)

asked 2020-04-21 07:15:27 -0600

OwlSoul gravatar image

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:

  • Switch to ament_cmake if there are custom messages and services in my package package_name and abolish ament_python completely?
  • Move all messages to separate package package_name_msgs (currently I am doing this)

or

  • Is there a way to actually build messages using ament_python?
  • Any other suggestions are welcome
edit retag flag offensive close merge delete

Comments

2

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).

gvdhoorn gravatar image gvdhoorn  ( 2020-04-21 07:44:02 -0600 )edit
1

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.

joaquingl gravatar image joaquingl  ( 2021-03-04 12:49:01 -0600 )edit

Nope. Never did find the answer after all.

OwlSoul gravatar image OwlSoul  ( 2021-03-05 06:39:00 -0600 )edit
1

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...

joaquingl gravatar image joaquingl  ( 2021-03-09 18:12:50 -0600 )edit
1

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

OwlSoul gravatar image OwlSoul  ( 2021-03-10 05:40:17 -0600 )edit

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

Andromeda gravatar image Andromeda  ( 2021-07-10 14:53:40 -0600 )edit

Did you fix the problem?

Andromeda gravatar image Andromeda  ( 2021-07-14 14:59:47 -0600 )edit

I ended up using ament_cmake for my interfaces package

joaquingl gravatar image joaquingl  ( 2021-07-14 15:37:31 -0600 )edit