Differences

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

Link to this comparison view

Both sides previous revision Previous revision
en:ros:subscribepublish [2020/03/20 08:56]
tomykalm
en:ros:subscribepublish [2020/03/20 09:06] (current)
tomykalm
Line 9: Line 9:
 Install the package named //​ros-tutorials//:​ Install the package named //​ros-tutorials//:​
  
-   $ sudo apt-get install ros-kinetic-ros-tutorials+   $ sudo apt-get install ros-kinetic-ros-tutorials
  
 Once the package is successfully installed, the working environment must be recompiled: Once the package is successfully installed, the working environment must be recompiled:
  
-   $ catkin_make #compile the computing environment+   $ catkin_make #compile the computing environment
  
 ===== Roscore ===== ===== Roscore =====
Line 21: Line 21:
 Open a new terminal window (Ctrl + Alt + T) and launch //​roscore//:​ Open a new terminal window (Ctrl + Alt + T) and launch //​roscore//:​
  
-   $ roscore+   $ roscore
 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 ~/​.ros/​log/​9cf88ce4-b14d-11df-8a75-00251148e8cf/​roslaunch-machine_name-13039.log +   ... logging to ~/​.ros/​log/​9cf88ce4-b14d-11df-8a75-00251148e8cf/​roslaunch-machine_name-13039.log 
-   Checking log directory for disk usage. This may take awhile. +   ​Checking log directory for disk usage. This may take awhile. 
-   Press Ctrl-C to interrupt +   ​Press Ctrl-C to interrupt 
-   Done checking log file disk usage. Usage is <1GB. +   ​Done checking log file disk usage. Usage is <1GB. 
-    +   ​ 
-   started roslaunch server http: //​machine_name:​ 33919/ +   ​started roslaunch server http: //​machine_name:​ 33919/ 
-   ros_comm version 1.4.7 +   ​ros_comm version 1.4.7 
-    +   ​ 
-   SUMMARY +   ​SUMMARY 
-   ====== +   ​====== 
-    +   ​ 
-    PARAMETERS +    PARAMETERS 
-    * /​rosversion +    * /​rosversion 
-    * /​rosdistro +    * /​rosdistro 
-    +   ​ 
-   NODES +   ​NODES 
-    +   ​ 
-   auto-starting new master +   ​auto-starting new master 
-   process [master]: started with pid [13054] +   ​process [master]: started with pid [13054] 
-   ROS_MASTER_URI = http: //​machine_name:​11311/​ +   ​ROS_MASTER_URI = http: //​machine_name:​11311/​ 
-    +   ​ 
-   setting /run_id to 9cf88ce4-b14d-11df-8a75-00251148e8cf +   ​setting /run_id to 9cf88ce4-b14d-11df-8a75-00251148e8cf 
-   process [rosout-1]: started with pid [13067] +   ​process [rosout-1]: started with pid [13067] 
-   started core service [/rosout]+   ​started core service [/rosout]
  
 Only one //roscore// can be run at a time. Now ROS nodes can communicate with each other. Only one //roscore// can be run at a time. Now ROS nodes can communicate with each other.
Line 59: Line 59:
 Open a new terminal window (Ctrl + Alt + T) and run a node called //talker// there: Open a new terminal window (Ctrl + Alt + T) and run a node called //talker// there:
  
-   $ rosrun rospy_tutorials talker+   $ rosrun rospy_tutorials talker
 Make sure //roscore// is running, you can't start a node without it. If the node is successfully started, the terminal should appear: Make sure //roscore// is running, you can't start a node without it. If the node is successfully started, the terminal should appear:
  
-   [INFO] [WallTime: 1314931831.774057] hello world 1314931831.77 +   [INFO] [WallTime: 1314931831.774057] hello world 1314931831.77 
-   [INFO] [WallTime: 1314931832.775497] hello world 1314931832.77 +   ​[INFO] [WallTime: 1314931832.775497] hello world 1314931832.77 
-   [INFO] [WallTime: 1314931833.778937] hello world 1314931833.78 +   ​[INFO] [WallTime: 1314931833.778937] hello world 1314931833.78 
-   [INFO] [WallTime: 1314931834.782059] hello world 1314931834.78 +   ​[INFO] [WallTime: 1314931834.782059] hello world 1314931834.78 
-   [INFO] [WallTime: 1314931835.784853] hello world 1314931835.78 +   ​[INFO] [WallTime: 1314931835.784853] hello world 1314931835.78 
-   [INFO] [WallTime: 1314931836.788106] hello world 1314931836.79+   ​[INFO] [WallTime: 1314931836.788106] hello world 1314931836.79
 The publisher goes and publishes messages to ///​chatter//,​ now you need a subscriber who reads those messages. The publisher goes and publishes messages to ///​chatter//,​ now you need a subscriber who reads those messages.
  
Line 74: Line 74:
 Open a new terminal window (Ctrl + Alt + T) and execute a subscriber named //​listener//:​ Open a new terminal window (Ctrl + Alt + T) and execute a subscriber named //​listener//:​
  
-   $ rosrun rospy_tutorials listener+   $ rosrun rospy_tutorials listener
 When messages sent by //talker// appear on the terminal, the node started successfully,​ ordered the ///​chatter//,​ and the nodes now communicate successfully through ROS: When messages sent by //talker// appear on the terminal, the node started successfully,​ ordered the ///​chatter//,​ and the nodes now communicate successfully through ROS:
  
-   [INFO] [WallTime: 1314931969.258941]/​listener_17657_1314931968795I heard hello world 1314931969.26 +   [INFO] [WallTime: 1314931969.258941]/​listener_17657_1314931968795I heard hello world 1314931969.26 
-   [INFO] [WallTime: 1314931970.262246]/​listener_17657_1314931968795I heard hello world 1314931970.26 +   ​[INFO] [WallTime: 1314931970.262246]/​listener_17657_1314931968795I heard hello world 1314931970.26 
-   [INFO] [WallTime: 1314931971.266348]/​listener_17657_1314931968795I heard hello world 1314931971.26 +   ​[INFO] [WallTime: 1314931971.266348]/​listener_17657_1314931968795I heard hello world 1314931971.26 
-   [INFO] [WallTime: 1314931972.270429]/​listener_17657_1314931968795I heard hello world 1314931972.27 +   ​[INFO] [WallTime: 1314931972.270429]/​listener_17657_1314931968795I heard hello world 1314931972.27 
-   [INFO] [WallTime: 1314931973.274382]/​listener_17657_1314931968795I heard hello world 1314931973.27 +   ​[INFO] [WallTime: 1314931973.274382]/​listener_17657_1314931968795I heard hello world 1314931973.27 
-   [INFO] [WallTime: 1314931974.277694]/​listener_17657_1314931968795I heard hello world 1314931974.28 +   ​[INFO] [WallTime: 1314931974.277694]/​listener_17657_1314931968795I heard hello world 1314931974.28 
-   [INFO] [WallTime: 1314931975.283708]/​listener_17657_1314931968795I heard hello world 1314931975.28+   ​[INFO] [WallTime: 1314931975.283708]/​listener_17657_1314931968795I heard hello world 1314931975.28
 ROS-based robots usually have a large number of nodes, each with its own specific function. Nodes can be located on different computers and communicate through different protocols. But now we're getting to know the tools that come with ROS, which allow us to track and manage nodes and topics. ROS-based robots usually have a large number of nodes, each with its own specific function. Nodes can be located on different computers and communicate through different protocols. But now we're getting to know the tools that come with ROS, which allow us to track and manage nodes and topics.
  
Line 94: Line 94:
 Entering the //​rostopic//​ command shows all the ways you can use it: Entering the //​rostopic//​ command shows all the ways you can use it:
  
-   $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, 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:
  
-   $rostopic list +   $rostopic list 
-   /chatter +   ​/chatter 
-   /rosout +   ​/rosout 
-   /rosout_agg+   ​/rosout_agg
 ///​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 
-   Type: std_msgs/​String +   ​Type: std_msgs/​String 
-    +   ​ 
-   Publishers:​ +   ​Publishers:​ 
-    * /​talker_12621_1542817185271 (http://​rage-HP-EliteBook:​45495/​) +    * /​talker_12621_1542817185271 (http://​rage-HP-EliteBook:​45495/​) 
-    +   ​ 
-   Subscribers:​ +   ​Subscribers:​ 
-    * /​listener_12836_1542817212996 (http://​rage-HP-EliteBook:​34711/​)+    * /​listener_12836_1542817212996 (http://​rage-HP-EliteBook:​34711/​)
 You will see which nodes have subscribed to the topic and which ones are publishing to the topic, as well as the message type, which is //​std_msgs/​String//​. You will see which nodes have subscribed to the topic and which ones are publishing to the topic, as well as the message type, which is //​std_msgs/​String//​.
  
-we use //rostopic hz// to see the frequency of messages:+We use //rostopic hz// to see the frequency of messages:
  
-   $ rostopic hz/​chatter +   $ rostopic hz/​chatter 
-   subscribed to [/​chatter] +   ​subscribed to [/​chatter] 
-   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:
  
-   $ rostopic echo /chatter +   $ rostopic echo /chatter 
-   date: "hello world 1542817743.91"​ +   ​date: "hello world 1542817743.91"​ 
-   --- +   ​--- 
-   date: "hello world 1542817744.01"​ +   ​date: "hello world 1542817744.01"​ 
-   --- +   ​--- 
-   date: "hello world 1542817744.11"​ +   ​date: "hello world 1542817744.11"​ 
-   --- +   ​--- 
-   date: "hello world 1542817744.21"​ +   ​date: "hello world 1542817744.21"​ 
-   --- +   ​--- 
-   date: "hello world 1542817744.31"​ +   ​date: "hello world 1542817744.31"​ 
-   ---+   ​---
 We use //pub// to post a message to: We use //pub// to post a message to:
  
-   $ 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 message. Press ctrl-C to 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:
  
-   date: "hello world 1542817787.91"​ +   date: "hello world 1542817787.91"​ 
-   --- +   ​--- 
-   date: "hello world 1542817788.01"​ +   ​date: "hello world 1542817788.01"​ 
-   --- +   ​--- 
-   date: "hello world 1542817788.11"​ +   ​date: "hello world 1542817788.11"​ 
-   --- +   ​--- 
-   data: "hello world"​ +   ​data: "hello world"​ 
-   --- +   ​--- 
-   date: "hello world 1542817788.21"​ +   ​date: "hello world 1542817788.21"​ 
-   --- +   ​--- 
-   date: "hello world 1542817788.31"​ +   ​date: "hello world 1542817788.31"​ 
-   --- +   ​--- 
-   date: "hello world 1542817788.41"​+   ​date: "hello world 1542817788.41"​
  
 ====== Rqt_graph ====== ====== Rqt_graph ======
Line 170: Line 170:
 run //​rqt_graph//:​ run //​rqt_graph//:​
  
-   $ rqt_graph+   $ rqt_graph
 {{:​et:​ros:​rqt_graph.png|}} {{:​et:​ros:​rqt_graph.png|}}
  
Line 185: Line 185:
 We use //rosnode list// to display all currently running nodes. We use //rosnode list// to display all currently running nodes.
  
-   $ rosnode list +   $ rosnode list 
-   /​listener_12836_1542817212996 +   ​/​listener_12836_1542817212996 
-   /rosout +   ​/rosout 
-   /​talker_12621_1542817185271+   ​/​talker_12621_1542817185271
 We use //rosnode info// to display the necessary information about the node: We use //rosnode info// to display the necessary information about the node:
  
-   $ rosnode info /​talker_12621_1542817185271 +   $ rosnode info /​talker_12621_1542817185271 
-   -------------------------------------------------- ------------------------------ +   ​-------------------------------------------------- ------------------------------ 
-   Node [/​talker_12621_1542817185271] +   ​Node [/​talker_12621_1542817185271] 
-   Publications:​ +   ​Publications:​ 
-    * /chatter [std_msgs /String] +    * /chatter [std_msgs /String] 
-    * /rosout [rosgraph_msgs /Log] +    * /rosout [rosgraph_msgs /Log] 
-    +   ​ 
-   Subscriptions:​ None +   ​Subscriptions:​ None 
-    +   ​ 
-   Services: +   ​Services: 
-     * /​talker_12621_1542817185271/​get_loggers +     * /​talker_12621_1542817185271/​get_loggers 
-    * /​talker_12621_1542817185271/​set_logger_level +    * /​talker_12621_1542817185271/​set_logger_level 
-    +   ​ 
-    +   ​ 
-   contacting node http://​rage-HP-EliteBook:​45495/​... +   ​contacting node http://​rage-HP-EliteBook:​45495/​... 
-   Hold: 12,621 +   ​Hold: 12,621 
-   Connections:​ +   ​Connections:​ 
-    * topic: /chatter +    * topic: /chatter 
-       * to: /​listener_12836_1542817212996 +       * to: /​listener_12836_1542817212996 
-       * direction: outbound +       * direction: outbound 
-       * transport: TCPROS +       * transport: TCPROS 
-    * topic: /rosout +    * topic: /rosout 
-       * to: /rosout +       * to: /rosout 
-       * direction: outbound +       * direction: outbound 
-       * 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.
en/ros/subscribepublish.txt · Last modified: 2020/03/20 09:06 by tomykalm
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