This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:ros:subscribepublish [2021/03/08 10:23] – [ROS Messages] momala | en:ros:subscribepublish [Unknown date] (current) – external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| ===== Ros Master ===== | ===== Ros Master ===== | ||
| - | Ros Master manages the communication between nodes. Every node registers at startup with the master. The //ros master// node must work. This node can be started with // | + | ROS Master manages the communication between nodes. Every node registers at startup with the master. The //ros master// node must work. This node can be started with // |
| Open a new terminal window (Ctrl + Alt + T) and launch // | Open a new terminal window (Ctrl + Alt + T) and launch // | ||
| Line 22: | Line 22: | ||
| If everything is set up correctly, something should appear on the terminal: | If everything is set up correctly, something should appear on the terminal: | ||
| - | ... logging to / | + | ... logging to / |
| Checking log directory for disk usage. This may take a while. | Checking log directory for disk usage. This may take a while. | ||
| Press Ctrl-C to interrupt | Press Ctrl-C to interrupt | ||
| Line 52: | Line 52: | ||
| ===== ROS Nodes ===== | ===== ROS Nodes ===== | ||
| - | Ros nodes are actually programs that run in your PC. It's a single-purpose and executable program that can be compiled, run, and managed individually. Nodes are like building blocks of your program. Nodes are organized in packages. Each package may include several nodes. Each node should be registered with the ROS master: | + | ROS nodes are actually programs that run on your PC. It's a single-purpose and executable program that can be compiled, run, and managed individually. Nodes are like building blocks of your program. Nodes are organized in packages. Each package may include several nodes. Each node should be registered with the ROS master: |
| {{ : | {{ : | ||
| Line 64: | Line 64: | ||
| ===== ROS Topics ===== | ===== ROS Topics ===== | ||
| - | Nodes communicate with each other through | + | Nodes communicate with each other through |
| {{ : | {{ : | ||
| Line 72: | Line 72: | ||
| Subscribe and print the message inside a topic: | Subscribe and print the message inside a topic: | ||
| $ rostopic echo /topic_name | $ rostopic echo /topic_name | ||
| - | To get the information about a topic such as publisher and subscribers and the type of the message: | + | To get the information about a topic such as a publisher and subscribers and the type of the message: |
| $ rostopic info /topic_name | $ rostopic info /topic_name | ||
| | | ||
| ===== ROS Messages ===== | ===== ROS Messages ===== | ||
| - | Nodes publish messages over topics. Messages define the data structure of the information that flows from one node to the other. It includes | + | Nodes publish messages over topics. Messages define the data structure of the information that flows from one node to the other. It includes simple data structures |
| To see the message structure of a specific type you need to run: | To see the message structure of a specific type you need to run: | ||
| $ rosmsg show message_type | $ rosmsg show message_type | ||
| Line 134: | Line 134: | ||
| | | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| - | | + | |
| | | ||
| - | Make sure roscore, talker and listener work in the background. | + | Make sure roscore, talker, and listener work in the background. |
| We will display all the topics currently in use: | We will display all the topics currently in use: | ||
| Line 150: | Line 150: | ||
| /// | /// | ||
| - | we use the //rostopic info// command to display the necessary information about the topic: | + | We use the //rostopic info// command to display the necessary information about the topic: |
| $ rostopic info/ | $ rostopic info/ | ||
| Line 168: | Line 168: | ||
| | | ||
| min: 0.100s max: 0.100s std dev: 0.00017s window: 10 | min: 0.100s max: 0.100s std dev: 0.00017s window: 10 | ||
| - | We see that the average frequency of messages is about 10 Hz. (Ctrl + C aborts the process) | + | We see that the average frequency of messages is about 10 Hz (Ctrl + C aborts the process). |
| We use //echo// to display messages sent to the topic: | We use //echo// to display messages sent to the topic: | ||
| Line 186: | Line 186: | ||
| $ rostopic pub /chatter std_msgs /String "data: 'hello world'" | $ rostopic pub /chatter std_msgs /String "data: 'hello world'" | ||
| - | | + | |
| While listening to the subject at the same time, we see that the message we sent was published: | While listening to the subject at the same time, we see that the message we sent was published: | ||
| Line 239: | Line 239: | ||
| | | ||
| We can see which computer the node is running on and through which protocol it is connected to the ROS. | We can see which computer the node is running on and through which protocol it is connected to the ROS. | ||
| - | |||
| - | ===== Rqt_graph ===== | ||
| - | |||
| - | ROS also comes with some graphical tools. // | ||
| - | |||
| - | run // | ||
| - | |||
| - | $ rqt_graph | ||
| - | {{ : | ||
| - | |||
| - | When the command is executed, the graphical user interface opens. We see that //talker// publishes messages to /// | ||
| - | |||
| - | Robots with more complex tasks usually have many different nodes working on them that interact with a variety of topics. It is difficult to see the big picture from the command line and this is done using the // | ||
| - | |||
| - | Example of a graph on a more complex robot: | ||
| - | |||
| - | {{ : | ||
| - | |||