Skip to content

Mapping with R1 in ROS2

Stefano Rosa edited this page Oct 21, 2022 · 5 revisions

Setup

  • Start the robot normally with yarprobotinterface.
  • Start robotstatepublisher from yarpmanager and baseControl2/Joystick control
  • Start ros2 navigation from yarpmanager and rviz. (Optional, only for navigating while mapping)
  • Change the rviz laser topic to /laser.

Start the mapping

  • On the robot's computer run the configured launch file with: ros2 launch /home/user1/tour-guide-robot/app/navigation2/launch/mapping.launch.py
  • The mapping has started and you should see the map be created in rviz. It updates the visualization every 5s by default.
  • You can now either tele-operate with the joystick or give a goal to the robot from rviz which should also dynamically avoid obstacles.

Saving the map

  • To save the map run: ros2 run nav2_map_server map_saver_cli -f YOUR_DIRECTORY
  • For example: ros2 run nav2_map_server map_saver_cli -f /home/user1/test_map
  • The saving will create two files: a pgm and a yaml. The yaml points to the pgm so be sure when changing directory to edit the yaml.
  • Alternatively, load the SlamToolboxPlugin panel inside rviz (menu->panels->add new panel) and use "Save map" to save a pgm+yaml map and "Serialize map" to save a pose graph (.data + .posegraph files)

Tips for mapping

  • The biggest source of error while mapping on R1 is the odometry. To try and minimize the error avoid rotations. Try to move straight for as long as possible and instead of differential turns, try to spin on the spot. Long straight paths are ideal.
  • To maximize matching, its ideal when exploring a new area to always have a reference of the previous area in the lidar. That means that instead of making a corner in a new area, try to look at the previous area walls while you enter the new.
  • It is important to "close loops" as often as possible by revisiting previously visited areas, that can be recognized by the SLAM algorithm.