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:
- Switch to
ament_cmake
if there are custom messages and services in my packagepackage_name
and abolishament_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
Just a comment, but:
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).
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
.Nope. Never did find the answer after all.
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...
Yeah, I just ended up using a separate package for my custom messages, and built them with cmake.
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
Did you fix the problem?
I ended up using
ament_cmake
for my interfaces package