ROS study notes three (use of ROS command line tools)

ROS command line tool

Commonly used commands:

  • rostopic
  • rosservice
  • rosnode
  • snarled
  • rosmsg
  • rossrv

Take baby turtles as an example

Run roscore

Insert picture description here

Run the turtlesim node

Insert picture description herePop up baby turtles:
Insert picture description here

Run the turtle_teleop_key node

Insert picture description here
carry out.

rqt_graph instruction

The tools at the beginning of rqt are all visualization tools based on qt.
rqt_graph is a tool used to display system calculation graphs.
Insert picture description here
A dialog box pops up: the
Insert picture description here
oval represents the currently running node, turtlesim is the simulator node, teleop_turtle is the keyboard control node, and the two nodes communicate through the topic turtle1/cmd_vel to transmit turtle speed information.

rosnode tool

Commands used to display all node information in the system

rosnode list

This command lists the nodes running in the system: it is
Insert picture description herefound that the node information displayed is different from the previous one, but an extra rosout is added. This node is the topic started by default when roscore is enabled in the ros environment, and is used to collect each of the ros Do not care about the log information of the node.

rosnode info

View the information of a specific node.
Insert picture description here

rostopic tool

Used to view content related to the topic.

rostopic list

Print out a list of all topics in the system.
Insert picture description here

rostopic pub

Publish data to a certain topic. The above /turtle1/cmd_vel topic is the communication topic between the keyboard control node and the emulator node. We can publish data to this topic through rostopic pub to control the turtles.
Insert picture description here
Double-click the Tab key to perform automatic completion. After the instruction is issued, the turtle does advance at a linear speed of 1m/s, but the turtle will automatically stop after a period of time, because such a message will only be published once, and you can add it after the pub The parameter specifies how often the message is published.
Insert picture description here
This time it was discovered that the little turtle did keep moving at a linear speed of 1m/s until it hit the wall.
You can use Ctrl+C to terminate the current task at any time during the process.

rosmsg tool

Can be used to view the content of the relevant message.

rosmsg show

Insert picture description hereHere you can display the content attributes of the message just released.

rosservice tool

View content about the service

rosservice list

Insert picture description here
Print a list of services in the current system.

rosservice call

Post a request to call the service.
We see that /spawn is a service related to spawning turtles, which can be used to spawn two turtles at the same time.
Insert picture description hereAlso use double-click the Tab key to complete the information.
At this time, two turtles appeared on the screen.
Insert picture description here

rosbag tools

Topic recording tool, which records and saves the current topic data in the system, which can be reproduced later, and can be used for the reproduction of drone flight data.

rosbag record

Insert picture description hereHere -a means to record the data of all topics, -O means to compress the data into a file package named as the subsequent parameter.
After running, the topic being monitored will be displayed.
At this time, we control the little turtle through the keyboard, and Ctrl+C ends the current task after a period of time. All topic data published during this time will be recorded.

rosbag play

This command can reproduce the data packets just stored. We close all previous terminals, reopen roscore, run turtlesim_node, and no longer run the keyboard controller. Use this command to reproduce the topic data just now.
Insert picture description hereWe found that the little turtle moved automatically according to the trajectory just now.

Guess you like

Origin blog.csdn.net/weixin_44911075/article/details/114121703