ROS runs the little turtle

1米/秒往前走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0}}'
原地打转
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: 0, y: 0, z: 0}, angular: {x: 0, y: 0, z: 6.28}}'
1米/秒往后走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{linear: {x: -1, y: 0, z: 0}, angular: {x: 0, y: 0, z: 0}}'

1. Start ros

roscore

    
    
     
     
  • 1

2. Start the little turtle

To open a terminal separately, you can use the command ctrl+shift+t to open a new terminal in the same window. input the command:

rosrun turtlesim turtlesim_node

    
    
     
     
  • 1

A small turtle window will appear:
insert image description here

The format of the rosrun command is: rosrun [package name] [node name]. turtlesim is a function package, and turtlesim_node is a node in the function package.

3. Keyboard control

And this time open a new terminal to run another node

rosrun turtlesim turtle_teleop_key

    
    
     
     
  • 1

The movement of the turtle is controlled by the four arrows of the keyboard.
Note that the cursor must be placed on this terminal for the turtle to move.
insert image description here

4. Command control

1/秒往前走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
       
       linear: {
       
       x: 1, y: 0, z: 0}, angular: {
       
       x: 0, y: 0, z: 0}}'
原地打转
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
       
       linear: {
       
       x: 0, y: 0, z: 0}, angular: {
       
       x: 0, y: 0, z: 6.28}}'
1/秒往后走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
       
       linear: {
       
       x: -1, y: 0, z: 0}, angular: {
       
       x: 0, y: 0, z: 0}}'

    
    
     
     
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

insert image description here

</article>

1. Start ros

roscore

    
    
  
  
  • 1

2. Start the little turtle

To open a terminal separately, you can use the command ctrl+shift+t to open a new terminal in the same window. input the command:

rosrun turtlesim turtlesim_node

    
    
  
  
  • 1

A small turtle window will appear:
insert image description here

The format of the rosrun command is: rosrun [package name] [node name]. turtlesim is a function package, and turtlesim_node is a node in the function package.

3. Keyboard control

And this time open a new terminal to run another node

rosrun turtlesim turtle_teleop_key

    
    
  
  
  • 1

The movement of the turtle is controlled by the four arrows of the keyboard.
Note that the cursor must be placed on this terminal for the turtle to move.
insert image description here

4. Command control

1/秒往前走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
    
    linear: {
    
    x: 1, y: 0, z: 0}, angular: {
    
    x: 0, y: 0, z: 0}}'
原地打转
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
    
    linear: {
    
    x: 0, y: 0, z: 0}, angular: {
    
    x: 0, y: 0, z: 6.28}}'
1/秒往后走
rostopic pub -r 10 /cmd_vel geometry_msgs/Twist '{
    
    linear: {
    
    x: -1, y: 0, z: 0}, angular: {
    
    x: 0, y: 0, z: 0}}'

    
    
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

insert image description here

Guess you like

Origin blog.csdn.net/luoganttcc/article/details/131084964