[ROS2][rclpy][Publisher] publish a msg to an existing topic

asked 2020-01-16 02:23:58 -0600

lin404 gravatar image

updated 2020-01-16 17:54:21 -0600

I know I can do below to publish msgs to a publisher.

pub = node.create_publisher(msg_type, topic)
pub.publish(some data)

My question is: Do I have to create_publisher first to get the target topic? There is no way to call an existing topic, something like get_publisher()? Or create_publisher is just kind of calling a topic when it is already existing?

edit retag flag offensive close merge delete

Comments

What would you consider the semantic difference between create_publisher(...) and get_publisher(...) that you are asking about? And can you also edit your question to clarify what you mean by "get the target topic" and "call an existing topic"?

tfoote gravatar imagetfoote ( 2020-01-16 19:14:37 -0600 )edit