Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:ros:subscribepublish [2021/03/08 10:10] momalaen: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 //roscore//.+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 //roscore//.
  
 Open a new terminal window (Ctrl + Alt + T) and launch //roscore//: Open a new terminal window (Ctrl + Alt + T) and launch //roscore//:
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 /home/mohsen/.ros/log/83e74152-7a80-11eb-b6ad-ccaf78b12fc1/roslaunch-laptop-22969.log+  ... logging to /home/mohsen/.ros/log/83e74152-7a80-11eb/roslaunch-laptop-22969.log
   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:
  
 {{ :en:ros:screenshot_from_2021-03-08_10-43-56.png |}} {{ :en:ros:screenshot_from_2021-03-08_10-43-56.png |}}
Line 64: Line 64:
  
 ===== ROS Topics ===== ===== ROS Topics =====
-Nodes communicate with each other through ros topics. One node can publish and subscribes to topics. Actually, topics are a stream of messages. The figure below shows how a topic transfer message between two nodes while one is publishing and the other is subscribing to the topic.+Nodes communicate with each other through ROS topics. One node can publish and subscribes to topics. Actually, topics are a stream of messages. The figure below shows how a topic transfer message between two nodes while one is publishing and the other is subscribing to the topic.
  
 {{ :en:ros:screenshot_from_2021-03-08_11-03-36.png |}} {{ :en:ros:screenshot_from_2021-03-08_11-03-36.png |}}
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 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 the simple data structure such as integers, floats, booleans, string, etc. They are defined in the *.msg file. you can see the message type inside a topic by running //rostopic info /topic_name// +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 such as integers, floats, booleans, string, etc. They are defined in the *.msg file. You can see the message type inside a topic by running //rostopic info /topic_name//
 +To see the message structure of a specific type you need to run: 
 +  $ rosmsg show message_type 
 +for example : 
 +  $ rosmsg show geometry_msgs/Twist 
 +  geometry_msgs/Vector3 linear 
 +    float64 x 
 +    float64 y 
 +    float64 z 
 +  geometry_msgs/Vector3 angular 
 +    float64 x 
 +    float64 y 
 +    float64 z
 ===== Sample Publisher and Subscriber ===== ===== Sample Publisher and Subscriber =====
 Above you installed a package called //ros-tutorials//. This package contains two nodes. The first node is called //talker//, which publishes the text "hello world" into the ///chatter// topic. Above you installed a package called //ros-tutorials//. This package contains two nodes. The first node is called //talker//, which publishes the text "hello world" into the ///chatter// topic.
Line 123: Line 134:
  
    $rostopic    $rostopic
-   rostopic bw display bandwidth used by topic+   rostopic BW display bandwidth used by topic
    rostopic echo print messages to screen    rostopic echo print messages to screen
-   rostopic hz display publishing rate of topic+   rostopic Hz display publishing rate of topic
    rostopic list print information about active topics    rostopic list print information about active topics
-   rostopic pub publish data to topic+   rostopic pub publish data to topic
    rostopic type print topic type    rostopic type print topic type
-Make sure roscore, talker and listener work in the background.+Make sure roscore, talkerand listener work in the background.
  
 We will display all the topics currently in use: We will display all the topics currently in use:
Line 139: Line 150:
 ///chatter// is the topic through which //talker// and //listener// interact. ///chatter// is the topic through which //talker// and //listener// interact.
  
-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/chatter    $ rostopic info/chatter
Line 157: Line 168:
    average rate: 10.005    average rate: 10.005
    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 175: Line 186:
  
    $ rostopic pub /chatter std_msgs /String "data: 'hello world'"    $ rostopic pub /chatter std_msgs /String "data: 'hello world'"
-   publishing and latching message. Press ctrl-C to terminate+   publishing and latching messages. Press "Ctrl + Cto terminate
 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 228: Line 239:
        * transport: TCPROS        * transport: TCPROS
 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. //Rqt_graph// graphically shows which nodes communicate with each other. It is also possible to filter nodes and topics differently. //rqt_graph// allows you to save the graph in //pdf// format. 
- 
-run //rqt_graph//: 
- 
-   $ rqt_graph 
-{{ :et:ros:rqt_graph.png |}} 
- 
-When the command is executed, the graphical user interface opens. We see that //talker// publishes messages to ///chatter// and //listener// listens to them. 
- 
-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 //rqt_graph// program. 
- 
-Example of a graph on a more complex robot: 
- 
-{{ :et:ros:rqtslam.png?700 |}} 
- 
  
  
en/ros/subscribepublish.1615198211.txt.gz · Last modified: 2021/03/08 10:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0