当前位置:网站首页>ROS learning_ Basics

ROS learning_ Basics

2022-07-06 06:51:00 Leslie x Xu

ROS Command line tools use

One 、 Common commands

  • roscore : start-up ros
  • rosrun :rosrun [package_name] [node_name] Call node The parameters are function package name and node name
  • rosnode :rosnode list List the currently running nodes
  • rqt_graph : Visualize the currently running nodes
  • rostopic : Operate the topic
    • rostopic pub : Post topic news
    • rostopic type : View message types
  • rosservice : Operate the service
    • rosservice call: Publish service request
  • rosparam
  • rosmsg : Get the details of the message
  • rossrv

Two 、 Example : Turtle simulation

  1. start-up ROS Master:$roscore

  2. Start the turtle Simulator :$rosrun turtlesim turtlesim_node

  3. Start the turtle control node :$rosrun turtlesim turtle_teleop_key
    Be careful : These three commands are executed on three terminals respectively .

  4. function
     Insert picture description here

3、 ... and 、 Post topic news

Release the news Keep the turtle moving .

  1. First check the message type
~$ rostopic type /turtle1/cmd_vel 
geometry_msgs/Twist

~$ 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
  1. Write parameters
~$ rostopic pub -r 10 /turtle1/cmd_vel geometry_msgs/Twist " linear: x: 1.0 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.0 "

Be careful : Parameter alignment

  1. function
     Insert picture description here

Four 、 Publish service request

Publish service request , Add a new turtle .

  1. View request information
~$ rosservice info /spawn
Node: /turtlesim
URI: rosrpc://ros2go:39063
Type: turtlesim/Spawn
Args: x y theta name

  1. Release request
~$ rosservice call /spawn " x: 5.0 y: 5.0 theta: 0.0 name: 'turtle2' "
name: "turtle2"

  1. function
     Insert picture description here

5、 ... and 、 The difference between topic and service

  1. topic of conversation (Topic)
  • Asynchronous communication mechanism between nodes
  • Use Release / subscribe Model
  • Topic data : news (Message) File format .msg
     Insert picture description here
  1. service (Service)
  • Synchronous communication mechanism between nodes
  • Use client / The server (C/S) Model
  • data : File format .srv
     Insert picture description here
原网站

版权声明
本文为[Leslie x Xu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060642582643.html