-
Notifications
You must be signed in to change notification settings - Fork 2
Using AMCL to Localize Against a Static Map
Written by: Michael Ruan
Our aim is to be able to localize our robot using AMCL with against a static map (here we use the husky playpen).
NOTE: assume a static map already exists
In move_base.launch
, we first reference a static map, and launch a node that will give the static map to RViz via the /map_server
node. This is done with the code below (ommited "<", ">").
arg name="map_file" default="$(find nav_husky_gazebo)/maps/playpen_map.yaml" node name="map_server" pkg="map_server" type="map_server" args="$(arg map_file)"
The first line will reference the playpen_map.yaml
file that will reference the playpen_map.pgm
occupancy grid. The second line will publish a node under the name map_server with the playpen_map occupancy grid.
To reference a different map, we would change the first line's relative file location to a map of our choice.
Short for Adaptive Monte Carlo Localization, AMCL aims to localize the robot using laser scan data, or some form of depth data, in addition to odometry information to estimate where the robot is with respect to some map--the map frame. With AMCL, and essentially any localization method, the more a robot explores a map, the more certain the robot is of its pose in the map.
Below is a block diagram depicting how the transform frames would connect with AMCL and without AMCL (i.e. only odometry).
For more information about AMCL ROS implementation, checkout http://wiki.ros.org/amcl
For more information about AMCL from a theoretical standpoint, checkout https://en.wikipedia.org/wiki/Monte_Carlo_localization
# [Terminal 1] Start up the Robot in simulation
$ roslaunch husky_gazebo husky_playpen.launch
# [Terminal 2] Start rviz
$ roslaunch husky_viz view_robot.launch
# In rviz, tick the "Navigation" tick box
# [Terminal 3] Start up the Navigation Stack and AMCL
# NOTE: make sure you build the package first!
$ roslaunch nav_hamcl move_base_amcl.launch
It is necessary to set the initial robot pose close to where the robot actually is when starting navigation. This will allow the robot to have an estimate of where the robot actually is. Note that a not too erroneous pose estimate will eventually converge to the robot's true pose with respect to the map frame eventually. To do this, we do the following (after running all the above terminal commands):
- change odom to map in rviz in "global options"-->"fixed frames"
- add --> PoseArray
- change the PoseArray topic name to "particlecloud". You should now be able to see a lot of red arrows, representing the possible poses the robot is at.
- click the 2D pose estimate button, and pick a pose that you wish for the robot to have. The robot will spawn at that pose with respect to the fixed map frame. Ideally, it should be as close to the robot's actual pose as possible to provide faster localization convergence, but can be slightly off to show to prowess of amcl.
- use the 2D nav goal button to pick new navigation goals. As the robot moves, the pose array should converge closer and closer to the robot's true pose.
Note: your pose estimate should be close to the robot's actual pose, else this may mess up navigation.