ZagHexa Robot Project Documentation
Nodes: are the process that perform computation. Each ROS node is written using ROS client libraries such as roscpp and rospy.
In a robot, there will be many nodes to perform different kinds of tasks.
Using the ROS communication methods, it can communicate with each other and exchange data.
One of the aims of ROS nodes is to build simple processes rather than a large process with all functionality.
Being a simple structure, ROS nodes are easy to debug too.
One node can communicate with other nodes using ROS Topics, Services, and Parameters.
A robot might contain many nodes, for example, one node processes camera images, one node handles serial data from the robot, and so on.
Using nodes can make the system fault tolerant. Even if a node crashes, an entire robot system can still work.
Nodes also reduce the complexity and increase debug-ability compared to monolithic codes because each node is handling only a single function.
All running nodes should have a name assigned to identify them from the rest of the system.
For example, /camera_node could be a name of a node that is broadcasting camera images.
There is a rosbash tool to introspect ROS nodes. The rosnode command can be used to get information about a ROS node. Here are the usages of rosnode:
$rosnode info [node_name] : This will print the information about the node.
$rosnode kill [node_name] : This will kill a running node.
$rosnode list : This will list the running nodes
$rosnode ping : This will check the connectivity of a node
$ rosnode machine [machine_name] : This will list the nodes running on a particular machine or a list of machines.
$ rosnode cleanup : This will purge the registration of unreachable nodes.
Master : The ROS Master provides name registration and lookup to the rest of the nodes.
Nodes will not be able to find each other, exchange messages, or invoke services without a ROS Master.
In a distributed system, we should run the master on one computer, and other remote nodes can find each other by communicating with this master.
When any node starts in the ROS system, it will start looking for ROS Master and register the name of the node in it.
So ROS Master has the details of all nodes currently running on the ROS system. When any details of the nodes change, it will generate a call-back and update with the latest details.
These node details are useful for connecting with each node.
When a node starts publishing a topic, the node will give the details of the topic such as name and data type to ROS Master.
ROS Master will check whether any other nodes are subscribed to the same topic.
If any nodes are subscribed to the same topic, ROS Master will share the node details of the publisher to the subscriber node.
After getting the node details, these two nodes will interconnect using the TCPROS protocol, which is based on TCP/IP sockets.
After connecting to the two nodes, ROS Master has no role in controlling them.
We might be able to stop either the publisher node or the subscriber node according to our wish. If we stop any nodes, it will check with ROS Master once again.
The following is a command to start ROS Master and the ROS parameter server :
$ roscore