# How does turtlebot tell if its localization matches its position on rviz?

According to this video, the localization in amcl compares the laserscan of its surroundings to the pre-saved map_file that is now loaded onto map_server as in this tutorial.

However, how does the turtlebot know if something new is just a local costmap addition or that the turtlebot pose estimate, as on rviz, is incorrect based on said comparison?

I find my robot jumping around on rviz as a result of this incorrect pose estimation.

edit retag close merge delete

Sort by » oldest newest most voted

amcl does use the gridmap from map_server, but that is not a costmap. amcl is only for localization (against a static gridmap) and does not deal with the global and local costmap. For the ros navigation stack, global and local costmap are a concept used not for localization, but only for navigation, i.e. for the move_base node. This is path planning and obstacle avoidance, but not localization.

Edit: Even after the update, the answer largely stays the same. For localization, the costmaps in move_base do not play any role. amcl looks at the laser scan, odometry and the map. If you see the robot jumping around, this might indicate that localization is not performing as well as you might want it to. This can have many reasons, but the local costmap is not one of them.

Edit 2: The map from gmapping you load into map_server is a gridmap, not a costmap. However, the global costmap in move_base has a layer that gets initialized from this gridmap. When you add an object in the field of view of your laser scanner, you do see it as an obstacle in the costmaps and these obstacles are considered for path planning and obstacle avoidance. However this new obstacle is not added to the gridmap used by amcl for localization. The gridmap is static, i.e. does not change. To see this, simple disable all displays in rviz relating to move_base (costmaps etc). Only display your robot, the laser scan and the gridmap. Now if you add the obstacle, you will see it in your laser scan, but not in the gridmap. amcl can handle some amount of obstacles and still localize. However, if you significantly change the environment, localization performance will decrease.

more

I edited the question, how about now? The question is still valid, right? Edit: let's say I use gmapping to make a map of my lab. I then load this map onto map_server. (1) Is not this map the global costmap? Also, now, after loading the map, I add an obstacle in front of the robot, in its 'rolling..

( 2014-04-16 08:27:04 -0500 )edit

.. window'. And I can see this on rviz, but it's darker in color than the rest of the map's default obstacles (unless those obstacles too are within the rolling window). And when I remove the aforementioned added obstacle, it disappears from rviz. So, I guess to clarify my question, what I mean is..

( 2014-04-16 09:01:28 -0500 )edit

.. when the turtlebot sees this added obstacle, (2) how does it know that is not one of the obstacles it detected during gmapping and thus part of the glob-... larger map that is loaded (a localization issue), but rather a new obstacle to update locally or temporarily? Hopefully this makes more sense?

( 2014-04-16 09:05:59 -0500 )edit

Are we talking an actual physical obstacle, or something in your custom costmap layer?

( 2014-04-16 09:18:50 -0500 )edit

Good point: actual, physical :)

( 2014-04-16 10:12:19 -0500 )edit

In response to Edit 2, that makes SO MUCH more sense! Thank you! Just a follow-up question then: let's say I intentionally set the 2D Pose Estimate on rviz incorrectly, with NO NEW obstacle. So obviously the laser scan will not match what rviz is telling the robot is infront of it. Does the ...

( 2014-04-17 04:21:28 -0500 )edit

... robot now consider this new laser scan information a 'new obstacle'? Or does the robot use this information to alter its localization, considering "amcl works by figuring out where the robot would need to be on the map in order for its laser scan to make sense" (according to the linked video)?

( 2014-04-17 04:27:51 -0500 )edit

If the pose is only slightly wrong, it will be able to correct over time. If it is very wrong, it probably will not converge. You can use global localization (check the amcl wiki page) to initalize particles evenly accross the map. This way the turtlebot should find its poistion after a while.

( 2014-04-17 04:59:08 -0500 )edit