Skip to content

SLAM Map building


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

  • OriginBot robot(Navigation Version)
  • PC:Ubuntu (≥20.04) + ROS2 (≥Foxy)

Start the chassis and lidar

After SSH is connected to OriginBot, enter the following command in the terminal to start the robot chassis and lidar:

$ ros2 launch originbot_bringup use_lidar:=true use_imu:=true
$ ros2 launch originbot_bringup use_lidar:=true



Since the chassis automatically records odom data after starting, the chassis needs to be restarted before running the SLAM function each time, 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

$ ros2 launch originbot_navigation

This function has been enabled on NodeHub. For details, see:Cartographer Lidar SLAM

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


Visualized display of the upper computer

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

$ ros2 launch originbot_viz

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



Make sure that you have downloaded and compiled the originbot_desktop code repository on the PC side. If it is not convenient to use 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, and laserscan, which can also achieve a similar effect.

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

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

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


Save the map

Once the map is complete, you can use the following commands to save the map:

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

The above command will save the map to the current path of the terminal, and it needs to be copied to the originbot_navigation function package before subsequent navigation use.