-
Notifications
You must be signed in to change notification settings - Fork 1
Understanding ROS Architecture
In this part of the tutorial, you will understand how the ROS architecture works.
Note: Make sure you are comfortable creating and building ROS packages.
A node is essentially an executable file within a ROS package.
Each node uses a ROS client library to communicate with other nodes.
These client libraries allow for nodes to be written in different languages. ROS currently supports
Nodes can be of one of the following two types:
-
Publisher/Subscriber Nodes: These nodes write data (publish) or read data (subscribe) to a specific channel (called a topic). To learn more see Understanding Publisher/Subscriber Nodes.
-
Service Nodes: These nodes provide a service to other nodes using requests/responses. To learn more see Understanding Service Nodes.
The roscore Node
The roscore node is a special node responsible for managing other nodes. This is always the first node you should run, which you can do using
roscore
Using rosnode
The rosnode tool can be used to display information about the ROS nodes.
We can see which nodes are currently running using
rosnode list
Note: Assuming you haven't run any other nodes, you should see that just rosout is running. This node is always running as it collects and logs nodes' debugging output.
We can get specific information about a node by using
rosnode info <node_name>
Using rosrun
The rosrun tool can be used to run a node within a package (without having to know the package path).
rosrun <package_name> <node_name>
Using roslaunch
The roslaunch tool can be used to run multiple nodes (specified in a launch file) via a single command.
roslaunch <package> <launch_file_name>
A launch file is an XML file defined with a <launch> tag, and contains a list of nodes that should be run.
Launch files are typically stored within the so-called launch directory of each package.
Within a package, we can create a launch directory using
mkdir launch
Note: The directory to store launch files doesn't necessarily have to be named
launch. In fact you don't even need to store them in a directory.
roslaunchautomatically looks into the passed package and detects available launch files. However, this is considered good practice.
Each node to run is specified using a <node> tag.
<node pkg="package_name" name="node_name" type="node_type"/>
Note: In the
<node>tag, thetypefield indicates which node should be launched, while thenamefield is any arbitrary (but unique) string which you can use to refer to that specific node.
Sometimes, it is useful to group nodes together, which can be done using the <group> tag.
<group ns = "group_namespace">
...
</group>
Note: In the
<group>tag, thensfield is any arbitrary (but unique) string which you can use to refer to that group. Nodes within a group must contain unique names.
Using rqt_graph, rqt_console, and rqt_logger_level
The rqt package contains several tools for visualizing and debugging the system.
Note: The rqt package, which is not installed as part of the default set. To install it, run
sudo apt-get install ros-<distribution>-rqt sudo apt-get install ros-<distribution>-rqt-common-plugins
The rqt_graph tool can be used to show a dynamic graph of the communication between nodes in the system.
rosrun rqt_graph rqt_graph
The rqt_console attaches to the ROS logging framework to display output from nodes.
rosrun rqt_console rqt_console
The rqt_logger_level allows us to change the verbosity level (DEBUG, WARN, INFO, and ERROR) of nodes as they run.
rosrun rqt_logger_level rqt_logger_level
You should now have a basic understanding of programming within ROS. However, it should be noted that we have barely scratched the surface on everything ROS has to offer. If you wish to learn more, we have provided a few additional resources below.
If you are looking to learn ROS in-depth from scratch, we suggest reading A Gentle Introduction to ROS by Jason M. O'Kane.
For additional ROS documentation, check out of the official ROS Wiki.
General ROS and Technical Help
- Creating a rospy package
- Model the Robot
- Odometry - General Information
- Odometry - Configuring with ROS
Creating and Using Our Packages