Mechanism of SLAM (3/3)
The mapping thread should provide several different features to support tracking. The mapper functionalities include providing the existing keyframe information to the tracker, creating new keyframes when asked by the tracker, optimising and refining the keyframes and map points both locally and globally, supporting the tracking relocalisation and correcting the map based on the detected visual loops. Some of these tasks are actually performed in parallel using multithreading techniques.
Because the application is used in real time, the most urgent mapping operations are not applied to the full map but to its relevant local part. The local part of the map comprises the most recently detected keyframe and a set of keyframes that are close to it in terms of co-visibility. This allows the mapper to quickly provide information to the tracker, and new keyframes are connected only to the parts of the local map that are co-visible to them. The optimisation of the keyframe positions, creation of new map points and culling of redundant information are performed often and quickly at the local level.
The mapper also maintains a visual vocabulary and a recognition database of all the keyframes in the map that are used both by the tracker for relocalisation purposes and by a specialised thread in the mapper that tries to detect the visual loops. Further, the information about a visual loop is used to rectify the possible drift in trajectory once the visual loop is detected.
To propagate local corrections through the map, global optimisation is performed when possible. This global optimisation becomes slower as the map grows; therefore, it is done only occasionally in a separate thread when the computational resources allow it. Global optimisation can also be triggered by the detected visual loops.