ROS Topic, Publisher, Subscriber and Code Editors

Introduction

In the ROS ecosystem, the communication between the publisher, who produces the information or the data and the subscriber, who receives the data from the publisher needs the medium and that is known as Topic. It is known as the format of the message between the publisher and subscriber.

Topic allows the communication from 1:N, N:1 and N:N between publisher and subscriber.

Message Communication

The communication in the ROS is done between the master node and the other nodes linked to the master node.

Then comes the subscriber node connecting to the master node to have the communication by declaring itself as the subscriber.

Then the publisher node attaches to the master node saying, that it is the publisher. The master node will have all the information related to the publisher and the subscriber and will act as a administrator.

After this, the subscriber node sends the request to the publisher node for the connection, when the publisher sends the response both of them will be connected based on the TCP/IP protocol known as TCPROS in ROS.

Now, the publisher can send the message to subscriber using the topic and have the message transmission to the threshold frequency limit. 

For example, the teleop_key node will send the messages to the simulation subscriber node to move the turtle accordingly. The roscore will be the master node and monitors the actions of the publisher and the subscriber. 

Steps to determine the Publisher in the ROS Topics

  • Initially, determine the name for the topic to publish
  • Specify the type of messages that topic will publish
  • Determine the frequency of topic publication
  • Determine the publisher object with parameters
  • Ensure to publish the topic messages at the selected frequency
  • Steps to determine the Subscriber in the ROS TOpics
  • Determine the name for the topic to listen
  • Mention the type of the messages to be received.
  • Determine the callback function that will be executed when the new message is received on the topic.
  • Listen to the topic messages
  • Ensure to listen forever 

ROS Nodes running in the sublime text editor

Initially, the files, or the folders that has to be run or to coded has to be opened through folder in sublime text or by dragging the folder into text editor.

 After complete code, the command prompt has to eb opened and the roscore has to be run to run the master node, then the other nodes programmed has to be run.

ROS Nodes running using the Visual Studio Code Editor

Similarly, in the VS Code editor, the execution of the nodes or the programs can be done, but it has the integrated terminal to run the code easily.

Spread knowledge

Leave a Comment

Your email address will not be published. Required fields are marked *