Edit on GitHub

SLAM

NOTE:

  • This instructions were tested on Ubuntu 18.04 and ROS2 Dashing Diademata.
  • Make sure to run the ROS2 Bringup instructions before running the instructions below.

CAUTION: Place the robot on a level surface, and ensure that it can not fall off an table or desk during a test.

Cartographer

SLAM (Simultaneous Localization And Mapping) is a technique of drawing a map by estimating its current location in an arbitrary space: it is a well-known feature of its predecessors of TurtleBot.

Watch the video and see how accurate TurtleBot3 draws a map.

The contents in e-Manual may differ from contents of a provided video in e-Manaul as e-Manual is updated on a regular basis.

Run SLAM Nodes

[TurtleBot3]

  1. Open a terminal on Turtlebot3.

  2. bring up basic packages to start its applications .

    $ export TURTLEBOT3_MODEL=${TB3_MODEL}
    $ ros2 launch turtlebot3_bringup robot.launch.py
    

    NOTE: Specify ${TB3_MODEL}: burger, waffle, waffle_pi before excuting the command. Set the permanent export setting by following Export TURTLEBOT3_MODEL instruction.

[Remote PC]

  1. Open a new terminal on Remote PC

  2. Launch the SLAM file.

    $ ros2 launch turtlebot3_cartographer cartographer.launch.py
    

Run Teleoperation Node

In order to achieve a high level accuracy for A mapping, you need to repeat SLAM several times manually in a given place. Use the following package (Teleoperation Node) for a manual operation.
Refer to a picture of the mapping process, which shows how the robot draws a map using SLAM.

[Remote PC]

  1. Open a terminal on Remote PC

  2. Run Teleoperation Node.
    $ export TURTLEBOT3_MODEL=${TB3_MODEL}
    $ ros2 run turtlebot3_teleop teleop_keyboard
    

    NOTE: Specify ${TB3_MODEL}: burger, waffle, waffle_pi before excuting the command. Set the permanent export setting by following Export TURTLEBOT3_MODEL instruction.

  3. Use the controller.

       Control Your TurtleBot3!
       ---------------------------
       Moving around:
               w
          a    s    d
               x
    
       w/x : increase/decrease linear velocity
       a/d : increase/decrease angular velocity
       space key, s : force stop
    
       CTRL-C to quit
    

Tuning Guide

Reference : Cartographer ROS

TIP: In Cartographer configuration files, every distance is defined in meters.

options

MAP_BUILDER.use_trajectory_builder_2d

TRAJECTORY_BUILDER_2D.min_range

TRAJECTORY_BUILDER_2D.max_range

TRAJECTORY_BUILDER_2D.missing_data_ray_length

TRAJECTORY_BUILDER_2D.use_imu_data

TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching

TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians

POSE_GRAPH.optimize_every_n_nodes

POSE_GRAPH.constraint_builder.min_score

POSE_GRAPH.constraint_builder.global_localization_min_score

NOTE: Constraints can be visualized in RViz, it is very handy to tune global SLAM. One can also toggle POSE_GRAPH.constraint_builder.log_matches to get regular reports of the constraints builder formatted as histograms.

Save the Map

Use map_saver node to save a drawn map by SLAM.
The map is drawn by collected data of the robot: odometry, tf and scan information of sensors, which you can monitor using RViz.
The name of the map files is map.pgm and map.yaml as a default, which are saved in a directory where map_saver is running.

Related Document:

[Remote PC]

  1. Open a new terminal on Remote PC

  2. Run map_saver node

$ ros2 run nav2_map_server map_saver -f ~/map

Map

Occupancy Grid Map (OGM) is a two-dimensional space, commonly used in ROS community. The space is composed of data of a saved map file, Save the Map.
The White cells represent free space, black celss represents ocupied space, and gray represents unknown space.

Occupancy Grid Map (OGM)

The figure shows the result of creating a large map using TurtleBot3.

The time for creating a map requires 55 minutes: the estimation of a travel distance is 351 m.

Reference