Reread Orb_slam's localmapping threading difficulties

Source: Internet
Author: User
Tags usleep

1. Recognize several locks and Boolean parameters

The communication and interaction of threads is more complex in the Orb, and it needs to be well-thought-clear.
1.1 mbstoprequested, set by the RequestStop function, mainly in the return loop, when the global optimization, and after the detection, adjust loop, localmapping need to pause.
1.2 mbstopped: Set by the Stop () function. Mbnotstop: Set by Setnotstop (). These two really make a big head of people. In the tracking thread, if the mapping thread is required to pause, that is mplocalmapper->isstopped () | | Mplocalmapper->stoprequested () is true, stop adding keyframes to it. If you can add keyframes, you must ensure that locamapping cannot be terminated when the tracking thread adds keyframes, Mbnotstop needs to be true.

   if(!mpLocalMapper->SetNotStop(true))        return;

This judgment is to be true.

1.3 Mplocalmapper->release (); This function is used after global optimization and the adjustment of loops to set the mbstopped,mbstoprequested to False. and empty the mlnewkeyframes.
1.4 Mmutexstop Lock is mainly used when setting the above two parameters to prevent simultaneous changes.
1.5 Mmutexaccept locks are also prevented from being asynchronous when setting mbacceptkeyframes. MMUTEXNEWKFS is the same principle.

2 overall flow
void Localmapping::run () {mbfinished = false;        while (1) {//Tracking would see that Local Mapping is busy Setacceptkeyframes (false); Check If there is keyframes in the queue if (Checknewkeyframes ()) {//BoW conversion and Inse Rtion in Map/* 1. First Calculate Bow 2. For the MapPoint that the tracking thread matches to do some processing, such as adding observations for MapPoint, update the description sub 3. Updates the current frame's relationship to its neighbor frame 4.            Finally add the keyframe to map */Processnewkeyframe (); Check recent mappoints/* Here mainly deals with the newly added map points. The newly added map point is usually generated by the last createnewmappoints. Here to do the deletion. But there's no knowing what mlprecentaddedmappoints does.            It doesn't seem to work anywhere, and erase these MapPoint pointers in the list doesn't affect the MapPoint pointer in the map.            */mappointculling (); Triangulate New Mappoints/* This generates a map point that is not the same as the tracking line thread, where the map point is generated directly using the depth information. This is done again based on the neighbor frame of the current frame, using triangulation to generate the map points.            This increases the visible distance of the slam */createnewmappoints (); if (!           Checknewkeyframes ()) {//Find more matches in neighbor KeyFrames and Fuse point duplications searchinneighbors (            );            } MBABORTBA = false; if (! Checknewkeyframes () &&!stoprequested ()) {//Local BA if (mpmap->keyfr                Amesinmap () >2) optimizer::localbundleadjustment (MPCURRENTKEYFRAME,&MBABORTBA, MPMAP); Check redundant local Keyframes/* If there is such a keyframe in the current local map: 90% of the map points you see are also visible at least three other keyframes, you should delete                This keyframe.            */keyframeculling ();        } mploopcloser->insertkeyframe (Mpcurrentkeyframe); } else if (Stop ()) {//Safe area-to-Stop while (isStopped () &&!            Checkfinish ()) {usleep (3000);        } if (Checkfinish ()) break;        } resetifrequested (); Tracking'll see that Local Mappingis busy Setacceptkeyframes (true);        if (Checkfinish ()) break;    Usleep (3000); } setfinish ();}

Reread Orb_slam's localmapping threading difficulties

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.