# Understanding Drift in Simultaneous Localization and Mapping (SLAM)

I am trying to understand the effect of drift in Simultaneous Localization and Mapping (SLAM). My understanding is that drift occurs because the robot tracks its position relative to a set of landmarks it is storing, but each landmark has a small error in its location. Therefore, an accumulation of these small errors over a long trajectory causes a large error by the end of the trajectory.

However, what I am confused about is what would happen when the robot tracks its way back to its starting positions. Suppose the robot starts in position A, and then starts to move along a path, mapping the environment as it does so, until it reaches position B. Now, the robot will have some error in its stored position of B, due to the drift during tracking. But then suppose the robot makes its way back to A, by tracking relative to all the landmarks it created during the first path. When it reaches A, will it be back at the true position of A, i.e. where it started the first path? Or will it have drifted away from A?

My intuition is that it will end up at the true position of A, because even though the landmarks have errors in them, as long as the error is not too large then the robot will eventually get back to the position where it stored the landmarks for A. And once it is there, those landmarks are definitely correct, without error, because they were initialized before any drift errors had started to accumulate.

Any help? Thanks!

## 1 Answer

Your intuition is mostly correct. Returning to where you started and re-observing landmarks you mapped earlier is called closing the loop in the SLAM literature. As you mentioned, your uncertainty will grow as the errors accumulate before you return to the start, if you don't have an absolute sensor. An absolute sensor is one that directly measures your state in the inertial coordinate frame (e.g., GPS). If you are relying on relative sensors (e.g., wheel encoders, an IMU, laser scanner), your uncertainty will grow. This is called dead reckoning in the literature.

Closing the loop can be difficult because how do you know you've returned to the start? How do you know the landmarks you're observing now are the same ones you observed when you started? This depends on a number things. For example, if the landmarks have some sort of unique signature about them (e.g., this is possible with some computer vision algorithms), you can look up each landmark you come across in your "dictionary" of landmarks you've seen so far. But let's say the landmarks are trees that all kind of look the same and you have a laser scanner. Well if you have been keeping track of your uncertainty properly, and you know the uncertainty of your measurements, you can determine the likelihood any new landmark is one you've seen before by calculating the Mahalanobis distance (i.e., distance that takes uncertainty into account) between new observations and landmarks in your current map. If the Mahalanobis distance is below some threshold, then you say you've found a match.

Once you've successfully closed the loop, depending on your SLAM algorithm, the uncertainty in your pose and the landmarks in your map becomes greatly reduced. This intuitively makes sense when you think about it. Let's say right before you close the loop, the uncertainty in your position was $\pm 3$ metres. Then your laser scanner (which has noise of $\pm 0.02$ metres) measures a landmark that you saw earlier, whose position you know pretty well (e.g., $\pm 0.05$ metres). It then makes sense that you know your position way better now! But wait, what about the other landmarks in your map? Their uncertainties are correlated with the uncertainty of your position because they were measured from the robot (these correlations manifest themselves in the off-diagonal terms of your covariance matrix). Then it only makes sense that drastically improving knowledge of your pose also improves your map!

So you're definitely on the right track. If you want to learn more, there is a good chapter on this topic in Probabilistic Robotics by Thrun et al. that has some pretty pictures showing the effects of loop closures. Here is a video that shows a loop closure (watch what happens to the uncertainty ellipses around both the robot and the landmarks when the robot returns to the start).

• Thanks very much for your detailed response. I understand the idea of loop closure, and how this can help when returning to the original position. However, what I am trying to understand is just the effect of tracking relative to the store landmarks, without any loop closure. Suppose the robot is just going down a corridor, such that it roughly goes in a straight line from A to B. If after reaching B, it then turns around and follows the landmarks back to A, will it reach the "true" position A, or the "noisy" position A? – Karnivaurus Mar 4 '16 at 4:03
• My intuition is the former, because even though the stored landmarks have errors in them, they are the same landmarks which took it from A to B, and so if the robot just tracks relative to them then it will still eventually reach A, no matter how big those errors are.... Correct? – Karnivaurus Mar 4 '16 at 4:04
• It depends on a few things, like how accurate your landmark measuring sensor is, and how much your uncertainty has grown since you left. If you're using a Kalman filter, and your uncertainty has grown a lot but your sensor is quite accurate, then the Kalman gain would be approximately equal to one (in a 1D example) when you close the loop. A Kalman gain of one means "believe your sensor measurement 100%", so your position estimate after you close your loop would be proportional to the noise in your sensor (which may be quite small), no matter how much error you've accumulated. – kamek Mar 4 '16 at 4:28