Skip to main content
Version: ROS 2 Jazzy

Localization

Localization is a method of tracking the robot's location within an existing map. It is generally done using laser scan data from a 2D LIDAR, and the robot's odometry. For this demo we are using the Nav2 package launch localization.

See the sample robot.yaml for configuration details.

tip

Make sure you have installed the simulator before starting this tutorial. Take a look at the installation guide for details.

Launching Localization

note

When using the simulation, it is important to add use_sim_time:=true to the Nav2, SLAM, and Localization launch files. When using a physical robot, either omit use_sim_time or set it to false.

1. Start the simulation and Nav2 by following steps 1-3 of the Nav2 startup

2. Open a terminal and run

ros2 launch clearpath_nav2_demos localization.launch.py use_sim_time:=true

The default map used by localization.launch.py is a map of the simulated warehouse world. If you are using a custom map, pass it in with the map launch argument:

ros2 launch clearpath_nav2_demos localization.launch.py use_sim_time:=true map:=/path/to/my/map.yaml

3. Start Rviz and set the robot's initial pose estimate by following steps 5-6 of the Nav2 startup

4. Give the robot a navigation goal using the Nav2 Goal tool.