Real-time mapping using Gmapping
Press Ctrl+Alt+T on the keyboard to open the first terminal and enter the command:
ros2 launch myagv_odometry myagv_active.launch.py
Press Ctrl+Alt+T on the keyboard to open a second terminal and enter the command:
ros2 launch slam_gmapping slam_gmapping.launch.py
At the same time, an rviz interface will be opened.
Press Ctrl+Alt+T on the keyboard to open the third terminal and enter the command:
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Make sure the terminal is selected by clicking with the mouse so that keyboard control can control myAGV.
Note: To avoid damage to the machine, make sure myAGV does not hit other objects before moving.
---------------------------
Moving around:
u i o
j k l
m , .
For Holonomic mode (strafing), hold down the shift key:
---------------------------
U I O
J K L
M < >
t : up (+z)
b : down (-z)
anything else : stop
q/z : increase/decrease max speeds by 10%
w/x : increase/decrease only linear speed by 10%
e/c : increase/decrease only angular speed by 10%
CTRL-C to quit
currently: speed 0.25 turn 0.5
Buttons | Button Description |
---|---|
i | Move forward |
, | Move backward |
j | Rotate counterclockwise |
l | Rotate clockwise |
u | Turn left and move forward |
o | Turn right and move forward |
k | Stop moving |
m | Turn left and move backward |
. | Turn right and move backward |
I | Move forward |
< | Move backward |
J | Move left |
L | Move right |
U | Move forward at an angle of 45° to the left |
O | Move forward at an angle of 45° to the right |
M | Move backward at an angle of 45° to the left |
> | Move backward at an angle of 45° to the right |
q | Increase linear and angular speed |
z | Reduce linear and angular speed |
w | Increase linear speed |
x | Reduce linear velocity |
e | Increase angular velocity |
c | Reduce angular velocity |
It is recommended that you set the linear velocity to 0.2 and the angular velocity to 0.4 when using keyboard control during gmapping. While building the map, you can observe in the RVIZ space that as myAGV moves, our map is gradually constructed.
After building the map you need, press Ctrl+Alt+T on the keyboard, open the fourth terminal, and enter the command:
ros2 run nav2_map_server map_saver_cli -f ~/map
The -f parameter can be followed by the path and map file name to add a suffix to the map parameter file.
Note: The folder path with the suffix name must be written correctly, otherwise an error will be reported.
ros2 run nav2_map_server map_saver_cli -f ~/myagv_ros2/src/myagv_navigation2/map/map_test
In this way, we will generate map parameter files map_test.yaml and map_test.pgm in the current path. The advantage of adding the suffix is that it is easier to manage the maps you need and avoid overwriting the map files that you have worked hard to build.
After saving, you can view the saved map in the pgm format in the path /home/er/myagv_ros2/src/myagv_navigation2/map.