修复保存地图时会崩坏bug

master
laobai 2022-04-24 23:16:35 +08:00
parent b9b28931ec
commit 009e985d93
2 changed files with 23 additions and 12 deletions

View File

@ -2832,6 +2832,7 @@ void Optimizer::LocalInertialBA(KeyFrame *pKF, bool *pbStopFlag, Map *pMap, int&
} }
//cout << "Total map points: " << lLocalMapPoints.size() << endl; //cout << "Total map points: " << lLocalMapPoints.size() << endl;
// TODO debug会报错先注释掉
for(map<int,int>::iterator mit=mVisEdges.begin(), mend=mVisEdges.end(); mit!=mend; mit++) for(map<int,int>::iterator mit=mVisEdges.begin(), mend=mVisEdges.end(); mit!=mend; mit++)
{ {
assert(mit->second>=3); assert(mit->second>=3);

View File

@ -569,6 +569,13 @@ void System::Shutdown()
cout << "Shutdown" << endl; cout << "Shutdown" << endl;
if (mpViewer)
{
mpViewer->RequestFinish();
while (!mpViewer->isFinished())
usleep(5000);
}
mpLocalMapper->RequestFinish(); mpLocalMapper->RequestFinish();
mpLoopCloser->RequestFinish(); mpLoopCloser->RequestFinish();
/*if(mpViewer) /*if(mpViewer)
@ -579,22 +586,25 @@ void System::Shutdown()
}*/ }*/
// Wait until all thread have effectively stopped // Wait until all thread have effectively stopped
/*while(!mpLocalMapper->isFinished() || !mpLoopCloser->isFinished() || mpLoopCloser->isRunningGBA()) // 源代码这里注释掉了,但是不执行会有锁报错
while(!mpLocalMapper->isFinished() || !mpLoopCloser->isFinished() || mpLoopCloser->isRunningGBA())
{ {
if(!mpLocalMapper->isFinished()) // if(!mpLocalMapper->isFinished())
cout << "mpLocalMapper is not finished" << endl;*/ // cout << "mpLocalMapper is not finished" << endl;
/*if(!mpLoopCloser->isFinished()) // if(!mpLoopCloser->isFinished())
cout << "mpLoopCloser is not finished" << endl; // cout << "mpLoopCloser is not finished" << endl;
if(mpLoopCloser->isRunningGBA()){ // if(mpLoopCloser->isRunningGBA()){
cout << "mpLoopCloser is running GBA" << endl; // cout << "mpLoopCloser is running GBA" << endl;
cout << "break anyway..." << endl; // cout << "break anyway..." << endl;
break; // break;
}*/ // }
/*usleep(5000); usleep(5000);
}*/ }
if(!mStrSaveAtlasToFile.empty()) if(!mStrSaveAtlasToFile.empty())
{ {
std::cout << "开始保存地图" << std::endl;
Verbose::PrintMess("Atlas saving to file " + mStrSaveAtlasToFile, Verbose::VERBOSITY_NORMAL); Verbose::PrintMess("Atlas saving to file " + mStrSaveAtlasToFile, Verbose::VERBOSITY_NORMAL);
SaveAtlas(FileType::BINARY_FILE); SaveAtlas(FileType::BINARY_FILE);
} }