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

How to make a ROS topic?

asked 2018-03-09 18:08:51 -0500

sdcguy gravatar image

How do I make a ROS topic. I want to make a ROS topic (Either a subscriber or a publisher) which I can either write to or read from. For example: how ROS programs have topics I can subscribe to or publish on. I want to make my own. I just want to be able to send a float32 type message using a ROS command on my topic. Is this possible to do?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-03-09 18:20:48 -0500

Gayan Brahmanage gravatar image

updated 2018-03-10 12:49:20 -0500

Of course. You can do that. First I would reccomend you to follow ROS tutorial. Also, you can use your own message types. Follow ROS message tutorials.

You can create your own topics using ROS messages. Also, you can create different topics using same message type. If you need, you can create your own message type as well.

You always subscribe topics published by a subscriber. Not messages. To do that,

  1. You should create a publisher that publishes topics like chatter.
  2. Then, you should create a subscriber that can subscribe that specific topic that is published by the publisher.

whenever the subscriber receives topics, your callback function in the subscriber node is called. Then you can use those data.

edit flag offensive delete link more


Thanks for the response. The first tutorial you have mentioned is a tutorial to write a publisher, which publishes on the topic "chatter". It is making a call to the advertise function which "notifies anyone that is trying to subscribe to that topic".

sdcguy gravatar image sdcguy  ( 2018-03-09 18:48:38 -0500 )edit

So, should I make a subscriber for that topic? And that is basically me creating my own topic.

sdcguy gravatar image sdcguy  ( 2018-03-09 18:52:08 -0500 )edit

Hi sdcguy, I just updated the answer with a breif explanation. Hope this will help you.

Gayan Brahmanage gravatar image Gayan Brahmanage  ( 2018-03-10 12:50:23 -0500 )edit

Question Tools



Asked: 2018-03-09 18:08:51 -0500

Seen: 12,748 times

Last updated: Mar 10 '18