ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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:
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.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".