myAGV-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
Open the launch file required for the cartographer build. If the terminal keeps scrolling the output data, the cartographer build file is successfully opened, and the terminal displays the following status:
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
Directional keys:
Keystrokes | Directions |
---|---|
i | forward |
, | Backward |
j | Move left |
l | Move right |
u | Rotate counterclockwise |
o | clockwise rotation |
k | stop |
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.
rosrun map_server map_saver
After running successfully the terminal displays the following:
Here you can see that we have drawn a red circle for the two files generated after saving the map, map.pgm and map.yaml, which will be saved in the home directory by default. Typing cd in the same terminal will bring us to our home directory, and then typing ls will bring us to our home directory where the generated map files have been created.