Tango: fixed export failing after saving the database

This commit is contained in:
matlabbe
2017-06-29 10:31:59 -04:00
parent ebada30984
commit b6d3e785df
2 changed files with 20 additions and 4 deletions

View File

@@ -2020,8 +2020,10 @@ void RTABMapApp::save(const std::string & databasePath)
dataRecorderMode_ = dataRecorderModeBackup; dataRecorderMode_ = dataRecorderModeBackup;
} }
std::map<int, rtabmap::Transform> poses = rtabmap_->getLocalOptimizedPoses();
rtabmap_->close(true, databasePath); rtabmap_->close(true, databasePath);
rtabmap_->init(getRtabmapParameters(), dataRecorderMode_?"":databasePath); rtabmap_->init(getRtabmapParameters(), dataRecorderMode_?"":databasePath);
rtabmap_->setOptimizedPoses(poses);
if(dataRecorderMode_) if(dataRecorderMode_)
{ {
clearSceneOnNextRender_ = true; clearSceneOnNextRender_ = true;
@@ -2057,6 +2059,13 @@ bool RTABMapApp::exportMesh(
// make sure createdMeshes_ is not modified while exporting! We don't // make sure createdMeshes_ is not modified while exporting! We don't
// lock the meshesMutex_ because we want to continue rendering. // lock the meshesMutex_ because we want to continue rendering.
std::map<int, rtabmap::Transform> poses = rtabmap_->getLocalOptimizedPoses();
if(poses.empty())
{
UERROR("Empty optimized poses!");
return false;
}
if(blockRendering) if(blockRendering)
{ {
renderingMutex_.lock(); renderingMutex_.lock();
@@ -2069,8 +2078,6 @@ bool RTABMapApp::exportMesh(
try try
{ {
std::map<int, rtabmap::Transform> poses = rtabmap_->getLocalOptimizedPoses();
int totalSteps = 0; int totalSteps = 0;
totalSteps+=poses.size(); // assemble totalSteps+=poses.size(); // assemble
if(meshing) if(meshing)
@@ -2373,6 +2380,10 @@ bool RTABMapApp::exportMesh(
} }
} }
} }
else
{
UERROR("Merged cloud too small (%d points) to create polygons!", (int)mergedClouds->size());
}
} }
else // organized meshes else // organized meshes
{ {
@@ -2736,6 +2747,10 @@ bool RTABMapApp::exportMesh(
success = true; success = true;
} }
} }
else
{
UERROR("Merged cloud is empty!");
}
} }
progressionStatus_.finish(); progressionStatus_.finish();

View File

@@ -2128,7 +2128,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
} }
else else
{ {
updateState(State.STATE_IDLE); updateState(previousState);
mToast.makeText(getActivity(), String.format("Exporting map failed!"), mToast.LENGTH_LONG).show(); mToast.makeText(getActivity(), String.format("Exporting map failed!"), mToast.LENGTH_LONG).show();
} }
mExportProgressDialog.dismiss(); mExportProgressDialog.dismiss();
@@ -2159,6 +2159,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
mProgressDialog.setMessage(String.format("Please wait while saving \"%s\"...", newDatabasePathHuman)); mProgressDialog.setMessage(String.format("Please wait while saving \"%s\"...", newDatabasePathHuman));
} }
mProgressDialog.show(); mProgressDialog.show();
final State previousState = mState;
updateState(State.STATE_PROCESSING); updateState(State.STATE_PROCESSING);
Thread saveThread = new Thread(new Runnable() { Thread saveThread = new Thread(new Runnable() {
public void run() { public void run() {
@@ -2197,7 +2198,7 @@ public class RTABMapActivity extends Activity implements OnClickListener, OnItem
mOpenedDatabasePath = newDatabasePath; mOpenedDatabasePath = newDatabasePath;
} }
mProgressDialog.dismiss(); mProgressDialog.dismiss();
updateState(State.STATE_IDLE); updateState(previousState);
} }
}); });
} }