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

Revision history [back]

click to hide/show revision 1
initial version

You cannot publish multiple different types of messages to the same topic. The ROS middleware does not support that. Each type will need its own topic.

You have two options:

  1. if there is no correlation between your Float32 and your Int32 values (ie: they just happen to be published by the same program, but do not share any relationship), you could do what you are doing now: just create two separate publishers and use those.
  2. if it makes sense for all three values to be published as a single message, you could create a new custom message containing three fields (two of type int32, one of type float32). Then create a publisher that publishes your custom message type instead of the Int32 or Float32 you have now. See the Creating a ROS msg and srv tutorial for how to do that.

Note that I'd only recommend using option 2 if this makes sense for your data flows. Don't put things together just because it allows you to "avoid two advertise lines".