ROS study notes 6- understand the subject

This article comes from: http://wiki.ros.org/ROS/Tutorials/UnderstandingTopics

  1. ROS relating to
    assume turtlesim node is already running, opens a new terminal, the keyboard command to run using the following control node
    $ rosrun turtlesim turtle_teleop_key
    

    The terminal window pops up as follows:

     

     It represents read input from the keyboard to control the movement of turtles.
    Selected to focus the window, you can use the arrow keys on the keyboard to move the hatchlings.

     Next we analyze in this behind what happened.

  2. Understanding ROS theme (Topic)
    has two nodes above: turtlesim and turtle_teleop_key, they communicate via ROS theme. Which, turtle_teleop_key will release information to the keyboard clicks the message, turtlesim node to receive information by subscribing to the keyboard clicks topic.
    1.  Use rqt_graph
      ROS provides a visual tool, rqt_graph to view the ROS system to run something. The tool is part of rqt_graph package, we can install the packages by the following command.
      $ sudo apt-get install ros-<distro>-rqt
      $ sudo apt-get install ros-<distro>-rqt-common-plugins
      

      Which, distro is ROS release, this tutorial use kinetic version.
      Then run the new terminal:

      $ Rosrun rqt_graph rqt_graph
      

       The following interface will appear:

       

       If the mouse is placed / turtle1 / cmd_vel on the interface of two elliptical color will vary as follows:

       

       Which turns red theme (Topics), blue and green nodes (Nodes), which released the nodes for the blue theme, green theme for the subscription node.

    2. rostopic
      ROS provides rostopic command to view the topic-related information.
      rostopic some subcommands may be used rostopic -h view, as follows:

       

    3.  

       rostopic echo
      which, rostopic echo command to print a topic messages. The syntax is as follows:

      rostopic echo [topical]
      

      Before we look at, for example, with rqt_graph to a theme: / turtle1 / cmd_vel, we can use the following command to view the topic in the news:

       

       As shown above, the operation

      rostopic echo /turtle1/cmd_vel
      

       After that, the keyboard focus to the node selected in the window, click on the arrow keys, you can print out the contents of the message that topic.
      Now if we run rqt_graph, is shown below:

       

       You can see more than one node to subscribe / turtle1 / cmd_vel theme, the node is the rostopic echo node.

    4. List rostopic
      rostopic List command lists the current subscription or publish topics, used as follows:

       

      If the -v option to the current subscription and publish complete information on the topics are listed.

       

       

    5. rostopic type
      before the node to communicate by subscribing and publishing topics, and send and receive data requires the same type of message, content and form of communication is a message (Message).
      These types of messages can be viewed by rostopic type command, which usage is:
      rostopic type [topic]
      

      For example, we can see the message type / turtle1 / cmd_vel in:

      The theme of the message type: geometry_msgs / Twist.
      You can use the following command to view the message type data members:

      spy@spy-pc:~$ 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
      

       Message type can be seen that the structure comprises two types of vectors Vector3, respectively, and angular velocities.

    6. Pub rostopic
      rostopic Pub commands can be issued a direct message ros topic. This command is used as follows:
      rostopic pub [topic] [msg_type] [args]
      

      E.g:

      rostopic pub -1 /turtle1/cmd_vel geometry_msgs/Twist -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]'
      

       This command indicates the type of published geometry_msgs / Twist messages to / turtle1 / cmd_vel subject matter, the message parameters: '[2.0, 0.0, 0.0]' '[0.0, 0.0, 1.8]' represents a forward speed of 2.0, the angular velocity 1.8 -1 is released only once the message.
      This group using YAML syntax, for more information on this syntax, refer to the YAML the Command Line Documentation .

      Two dashes - expressed, the latter are parameters, not an option, in order to prevent the parser error containing symbols example parameters, such as the indiscriminate, the parser may be resolved by the options.
      In this command, a small turtle mobile interface is shown below:

       

       As can be seen, the small turtles moved about 1/4 of an arc segment.

      In order to make small turtle continues to move, we need to continue to post the message, the need for continuous dissemination of information frequency parameter, this parameter can use the -r option is specified, for example, use the following statement:
      rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
      

      We can let the turtle continuous circular motion:

       

       

       Then use rqt_graph view the topics:

       

       You can see more than one node to publish / turtle1 / cmd_vel theme to / turtlesim nodes.

    7. Visual message data
      1.  Hz rostopic
        rostopic Hz frequency command to view the release of a theme, such as:
        rostopic hz /turtle1/pose
        subscribed to [/turtle1/pose]
        average rate: 62.485
        	min: 0.004s max: 0.028s std dev: 0.00250s window: 63
        average rate: 62.495
        	min: 0.004s max: 0.028s std dev: 0.00180s window: 125
        average rate: 62.489
        	min: 0.004s max: 0.028s std dev: 0.00149s window: 188
        average rate: 62.495
        	min: 0.002s max: 0.029s std dev: 0.00181s window: 250
        average rate: 62.500
        	min: 0.002s max: 0.029s std dev: 0.00175s window: 313
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00190s window: 375
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00176s window: 438
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00166s window: 501
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00165s window: 563
        average rate: 62.502
        	min: 0.002s max: 0.029s std dev: 0.00175s window: 626
        average rate: 62.498
        	min: 0.002s max: 0.029s std dev: 0.00178s window: 688
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00171s window: 751
        average rate: 62.498
        	min: 0.002s max: 0.029s std dev: 0.00165s window: 813
        average rate: 62.501
        	min: 0.002s max: 0.029s std dev: 0.00159s window: 876
        average rate: 62.500
        	min: 0.002s max: 0.029s std dev: 0.00158s window: 938
        average rate: 62.499
        	min: 0.002s max: 0.029s std dev: 0.00153s window: 1001
        average rate: 62.499
        	min: 0.002s max: 0.029s std dev: 0.00149s window: 1064
        average rate: 62.500
        	min: 0.002s max: 0.029s std dev: 0.00147s window: 1126
        average rate: 62.499
        	min: 0.001s max: 0.032s std dev: 0.00161s window: 1189
        average rate: 62.499
        	min: 0.001s max: 0.032s std dev: 0.00162s window: 1251
        average rate: 62.499
        	min: 0.001s max: 0.032s std dev: 0.00159s window: 1314
        average rate: 62.501
        	min: 0.001s max: 0.032s std dev: 0.00155s window: 1376
        average rate: 62.500
        	min: 0.001s max: 0.032s std dev: 0.00152s window: 1439
        average rate: 62.500
        	min: 0.001s max: 0.032s std dev: 0.00149s window: 1501
        average rate: 62.500
        	min: 0.001s max: 0.032s std dev: 0.00147s window: 1564
        average rate: 62.500
        	min: 0.001s max: 0.032s std dev: 0.00145s window: 1627
        average rate: 62.499
        	min: 0.001s max: 0.032s std dev: 0.00142s window: 1689
        average rate: 62.500
        	min: 0.001s max: 0.032s std dev: 0.00140s window: 1752
        average rate: 62.444
        	min: 0.001s max: 0.041s std dev: 0.00155s window: 1813
        

        As can be seen, turtlesim node released / turtle1 / pose relating to a frequency of about 62Hz, and gives the statistical characteristics, maximum, and minimum variance.

      2. rqt_plot
        This command will plot data message:
        rosrun rqt_plot rqt_plot
        

         Rqt_plot interface will pop up, and then enter the name of the topic Topic behind the text box interface, such as input: / turtle1 / pose data message is then displayed / turtle1 / pose topic curve.

         

         


          

Guess you like

Origin www.cnblogs.com/spyplus/p/11518480.html