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

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 reopen merge delete

### Closed for the following reason duplicate question by lin404 close date 2020-01-27 19:08:15.575704

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 Sorry for the confusion. The existing system already has a topic named cmd_vel which I want to use. While, I was just wondering if I give create_publisher a different name for example cmd_vel_1, it will create a new topic called cmd_vel_1 then do publish() without any problem? Or it will return an error saying there is no cmd_vel_1? --> That's my concern about the difference between create_publisher and get_publisher, since I might not want to create a new topic, instead I prefer it can return the error telling me I am trying to use an inexistent topic.