Skip to content

SLAM Map building

Hint

The operating environment and software and hardware configurations are as follows:

  • OriginBot Pro
  • PC:Ubuntu (≥22.04) + ROS2 (≥humble)

Start the chassis and lidar

After successfully connecting to OriginBot through SSH, enter the following command in the terminal to start the robot chassis and lidar:

ros2 launch originbot_bringup originbot.launch.py use_lidar:=true use_imu:=true

image-20220822151007681

Hint

Since the chassis will automatically record odom data after startup, you need to restart the chassis each time before running the SLAM function, otherwise the TF tree transformation may fail.

Start SLAM

Connect to OriginBot via SSH and enter the following command in the terminal to start the cartographer mapping algorithm:

ros2 launch originbot_navigation cartographer.launch.py
2x_image

If the program is running properly, the terminal should display a screen similar to the following:

ture_image

Upper computer visual display

In order to view the complete SLAM process, start the upper computer visualization software on the PC under the same network:

ros2 launch originbot_viz display_slam.launch.py

You can see the map that has been created at this point.

image-20220928220241108

Hint

Make sure that the originbot_desktop code repository has been downloaded and compiled on the PC. If it is inconvenient to use the originbot_desktop code repository, you can also use "ros2 run rviz2 rviz2" to start Rivz2 separately, and manually add display plug-ins such as map, tf, laserscan, etc. to achieve similar results.

Keyboard control mapping

In order for the robot to establish a complete picture of its surroundings, we also need to start a keyboard control node:

ros2 run teleop_twist_keyboard teleop_twist_keyboard
Hint

The keyboard control node can be run on the PC or OriginBot.

Now, we can click the up, down, left, and right keys on the keyboard in the keyboard-controlled terminal to control the robot to explore the unknown environment. The full picture of the map will gradually appear in Rviz.

e646ac75c6

Save the map

After the map is built, you can use the following command to save the map:

ros2 run nav2_map_server map_saver_cli -f my_map --ros-args -p save_map_timeout:=10000
Info

The above command will save the map to the current path of the terminal. Before using it for subsequent navigation, it needs to be copied to the originbot_navigation function package.

图片1