Can topic be created independent of publisher

asked 2020-06-11 13:38:57 -0500

pagmax gravatar image

I am following ROS tutorials on Publish/Subscribe and the topic chatter is created within the talker.py. My question is for topic to exist, does it need to be in publisher file? Can a topic be created outside and independent of publisher?

edit retag flag offensive close merge delete

Comments

To help construct a useful answer, can you describe why you want to know? You can publish to a topic using the command line or listen to a topic that doesn't exist yet.

achille gravatar image achille  ( 2020-06-11 23:55:51 -0500 )edit

I understand you can publish to a topic using command line but that is exactly what made me think that publisher and topic are kind of independent. Many publishers can publish to same topic including from command line. However, looks like the topic has to be created from at least one of the publisher file. I almost thought if topic does not care whether someone is subscribing to it or publishing to it, why the need for creating a publisher to create topic. I do not have any specific need or any purpose for this. Just trying to get my understanding on topics better.

pagmax gravatar image pagmax  ( 2020-06-12 03:31:59 -0500 )edit

A topic in ROS 1 won't exist until it is registered with the ROS master. Yes they are separate concepts. If you are trying to learn about ROS, the wiki is a great place to start.

achille gravatar image achille  ( 2020-06-12 21:03:50 -0500 )edit

I know ROS wiki is a great place to start and asked this question because I was following ROS wiki (as mentioned in my question too!). It was just not clear to me why a topic would have to be defined in a publisher file first when it is meant to be independent of publisher. I thought there would be a way topic is defined externally and then any publisher can publish to it. No specific reason but it just made more sense to me and wondered if this feature is there. I could no find any discussion on it on ROS wiki or previously asked questions on similar lines.

pagmax gravatar image pagmax  ( 2020-06-12 22:48:55 -0500 )edit