ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ROS2 Message generation in python package

asked 2021-10-16 07:41:17 -0600

Darkproduct gravatar image

Hi, I have a python package with multiple nodes and I need to send a message from one node to another. Currently the message type is from std_msgs.msg import Int16MultiArray, but I need to add a header to this message. The message contains the encoder values from 3 wheels and are transferred from the hardware driver node to the odom node. This message should have the frame id base_link and must contain the time. So I need a Int16MultiArrayStamped or I would call it EncoderStamped or something like that.

Now I would like to generate a custom message, but I can't find documentation on how this should work inside a python package. I mean I can just create a new CMake package which just contains the new message type with message generation, but I want this to be self contained, because this belongs to this package.

So my question is: Is it possible to have custom message generation in a python package in ROS2 Foxy?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-10-17 21:58:44 -0600

janindu gravatar image

Short answer : No. You can't generate messages on a ROS2 Foxy python package.

However, since you can still have python nodes on cmake packages, you can define the custom messages on a cmake package and also add your python scripts there, so that you will end up with just one package that contains both the code and the message interface definitions.

Source : Expanding on ROS 2 interfaces

Similar question : Define custom messages in python package (ROS2)t

edit flag offensive delete link more

Question Tools



Asked: 2021-10-16 07:41:17 -0600

Seen: 733 times

Last updated: Oct 17 '21