ROS study notes three
ROS command line tool
Commonly used commands:
- rostopic
- rosservice
- rosnode
- snarled
- rosmsg
- rossrv
Take baby turtles as an example
Run roscore
Run the turtlesim node
Pop up baby turtles:
Run the turtle_teleop_key node
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.
A dialog box pops up: the
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
found 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.
rostopic tool
Used to view content related to the topic.
rostopic list
Print out a list of all topics in the system.
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.
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.
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
Here you can display the content attributes of the message just released.
rosservice tool
View content about the service
rosservice list
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.
Also use double-click the Tab key to complete the information.
At this time, two turtles appeared on the screen.
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
Here -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.
We found that the little turtle moved automatically according to the trajectory just now.