myAGV 2023-gmapping real-time map building
1. Open the SLAM laser scan launch file
After opening the car, open the console terminal (shortcut Ctrl+Alt+T),and enter the following command in the command line:
cd myagv_ros
roslaunch myagv_odometry myagv_active.launch
Note: Before opening the launch file, please place the car at a suitable starting point in the environment where you need to build the map, because opening the launch file will open the IMU sensor and odometer of the car, and moving the car artificially will cause distortion of the car build.
Open the launch file required for the carriage SLAM laser scan, if it shows
Now YDLIDAR is scanning ......
Then the car lidar file is opened successfully and the status is displayed in the terminal as follows:
2. Open the gmapping build launch file
Open a new console terminal again and enter the following command at the command line.
cd myagv_ros
roslaunch myagv_navigation myagv_slam_laser.launch
3.Open the keyboard control file
Open a new console terminal and in the terminal command line type.
cd myagv_ros
roslaunch myagv_teleop myagv_teleop.launch
Key | Direction |
---|---|
i | Forward |
, | Backward |
j | Move Left |
l | Move Right |
u | Rotate Counterclockwise |
o | Rotate Clockwise |
k | Stop |
m | Rotate Clockwise Backward |
. | Rotate Counterclockwise Backward |
q | Increase Linear and Angular Velocity |
z | Decrease Linear and Angular Velocity |
w | Increase Linear Velocity |
x | Decrease Linear Velocity |
e | Increase Angular Velocity |
c | Decrease Angular Velocity |
4.Start building a map
Now the car can start to move under the control of the keyboard, control the car around the space where you want to build the map. At the same time, you can see our map in the Rviz space will follow the car's movement and build the map a little bit. Note: When using the keyboard to operate the car, make sure that the terminal running the myagv_teleop.launch file is the currently selected window, otherwise the keyboard control program will not recognize the keyboard keys.
5.Save the constructed map
Open another new console terminal and enter the following command on the command line to save the completed map from the car scan.
cd ~/myagv_ros/src/myagv_navigation/map
rosrun map_server map_saver
After a successful run, two default map parameter files will be generated in the current path (~/myagv_ros/src/myagv_navigation/map): "map.pgm" and "map.yaml".
Alternatively, you can use the "rosrun map_server map_saver" command with the "-f" parameter to specify the path and file name. Here's an example:
rosrun map_server map_saver -f /home/er/myagv_ros/src/myagv_navigation/map/map_505