ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

single subscriber/publisher subscribes/publishes multi topics

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

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

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


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

Seen: 315 times

Last updated: Jul 18 '20