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

single subscriber/publisher subscribes/publishes multi topics

asked 2020-07-17 05:32:52 -0500

zivy gravatar image

Hi guys,

I have noticed that the description of DDS, subscriber/publisher could have multiple readers/writers, which means one subscriber/publisher can sub/pub different topics. But in the ROS2 demo,

publisher_ = this->create_publisher<std_msgs::msg::string>("topic", 10);

publisher_ can only publish messages to "/topic".

Is it possible for publisher_ to publish messages to both "/topic" and "/topic2"? Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-18 18:59:35 -0500

Orhan gravatar image

No, let's say the other topic's type is Float64. You will have to create another publisher object like this:

publisher2_ = this->create_publisher<std_msgs::msg::Float64>("topic2", 10);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-07-17 05:32:52 -0500

Seen: 585 times

Last updated: Jul 18 '20