Localization
- How does the Robot “know” where it is?
- How does it determine it’s “pose”?
- Relative to a coordinate system
- Could be GPS coordinates
- But more likely coordinate of a given map
Localizing the Robot on a map
- Key package is called
AMCL
- Adaptive Monte Carlo Localization
- It’s a deep theoretical area covered in Probabilistic Robotics by Sebsastian Thrun, et al
How it works at a high level
- Location of robot is its pose
- Always known with respect to a map coordinate frame (also called sometimes the world coordinate frame)
AMCL
maintains a set of candidate poses plus a probability that they reflect reality
- As robot moves, actual sensor readings are compared with expected sensor readings for each pose, and the probability of each candidate pose can be updated.
- Low probability poses are discarded, and high probability poses are updated based on odometry, scan, and probability.
- For path planning purposes the highest probability pose is used.
- It is definitely a guess not a certainty.
Simulating localization
- We will rebuild the map here to make sure things are consistent
- A new wrinkle here is the use of turtlebot3_simulation which will take the place of teleop
- That node drives the robot around randomly while gmapping is building the map
- After some time has gone by, save the map.
NBBe careful with the filenames of the map. You will get strange errors if the file name given to turtlebot3_navigation is incorrect or not resolvable!
Example
# Make sure to install AMCL: `sudo apt-get install ros-noetic-amcl`
# create the simulated environment called stage_4
$ roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch
# launch a simulated turtlebot3 that drives a random pattern
$ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
# launch the slam algoritm, which will create an in-memory map data structure
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
# After the map looks done, save it into a map file for later.
$ cd ~
$ rosrun map_server map_saver -f stage4
# Now, close all the exiting ROS nodes down and next run this. Be careful with the
# file names because the yaml file contains a file name too and it is easy to
# get things misaligned.
# {filemname} will be something like /home/youraccount/stage4.yaml but check to make sure.
$ roslaunch turtlebot3_gazebo turtlebot3_stage_4.launch
$ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:={filename}
Gazebo after building the map