1. roscore
roscore is used to start the ros master, which is the first command to run before running the ros system
2. rosrun
rosrun is an instruction used to run a node in a function package. It has two parameters. The first parameter is the function package name, and the second parameter is the node name.
Example: emulating a turtle
, typerosrun turtlesim turtlesim_node
in one terminal, type in another terminalrosrun turtlesim turtle_teleop_key
3.rosnode
rosnode, an instruction used to display node-related information
- rosnode list is used to list all nodes in the system
- rosnode info *, view the specific information of the node, such as which topics are being published, the services provided, and other information
4. rostopic
- rostopic list, output a list of all topics in the current system
- rostopic pub [topic name + tab completion], display the published content
Example: Controlling the movement of a turtle by publishing a topic (rostopic pub)
Input code:rostopic pub -r 10 /turtle1/cmd_vel+两次tab补全
By modifying the linear speed and angular angle, the movement of the turtle can be controlled. Among them, -r 10 is the frequency of topic publication, which is published ten times per second.
5. rosservice
- roservice list can display a list of all services in the ros system (all servers are the turtle emulators above)
- rosservice call [service name + tab completion] release request
Example: Spawn two turtles (/spawn in the service list is a request to spawn a turtle)
Input code:rosservice call /spawn+两次tab补全
where x and y are the coordinates of the new turtle (the lower left corner of the emulator is the origin)
6. rosbag
Record all topic data in the current system and reproduce it next time.
Example: Preserving the movement of baby turtles
- Input command:
rosbag record -a -O cmd_record
where record means to record, -a means to record all data, -o means to save the data as a compressed package, and finally the name of the saved file- Back to the key terminal, use the keyboard arrow keys to control the little turtle to move
- Use
ctrl+C
interrupt rosbag record after exercise
Example: Reproduce the movement of a baby turtle
- Close the previously opened terminal, reopen a terminal, and run
roscore
- Open a new terminal and start the emulation of the little turtle:
rosrun turtlesim turtlesim_node
(There is no need to start keyboard input here)- Open a new terminal to reproduce the action of the little turtle:
rosbag play cmd_record.bag
The learning content in this article comes from the
official forum of Guyueju: https://www.guyuehome.com/
learning video: https://www.bilibili.com/video/BV1zt411G7Vn