DBDriver: when an empty database url is provided, an empty database "in memory" is used by default. Tango: fixed second database not recorded in Data Recorder mode (now creating a new one on save). Mapping parameters are saved in database instead of the one used to record data (Data Recorder mode).

This commit is contained in:
matlabbe
2016-11-23 15:13:09 -05:00
parent 639896b309
commit 23bb5d5147
9 changed files with 77 additions and 47 deletions

View File

@@ -2,7 +2,7 @@
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.introlab.rtabmap"
android:versionCode="22"
android:versionCode="23"
android:versionName="@RTABMAP_VERSION@">
<uses-permission android:name="android.permission.CAMERA" />

View File

@@ -1020,9 +1020,24 @@ void RTABMapApp::resetMapping()
void RTABMapApp::save(const std::string & databasePath)
{
rtabmapThread_->join(true);
if(dataRecorderMode_)
{
// to save mapping parameters in the database
dataRecorderMode_ = false;
rtabmap::ParametersMap parameters = getRtabmapParameters();
rtabmap_->parseParameters(parameters);
dataRecorderMode_ = true;
}
rtabmap_->close(true, databasePath);
rtabmap_->init(getRtabmapParameters(), databasePath);
rtabmap_->init(getRtabmapParameters(), dataRecorderMode_?"":databasePath);
if(dataRecorderMode_)
{
clearSceneOnNextRender_ = true;
}
rtabmapThread_->start();
}
bool RTABMapApp::exportMesh(const std::string & filePath)

View File

@@ -52,7 +52,7 @@ class RTABMapApp : public UEventsHandler {
void onCreate(JNIEnv* env, jobject caller_activity);
void openDatabase(const std::string & databasePath);
void openDatabase(const std::string & databasePath = "");
bool onTangoServiceConnected(JNIEnv* env, jobject iBinder);

View File

@@ -55,6 +55,13 @@ Java_com_introlab_rtabmap_RTABMapLib_onCreate(
return app.onCreate(env, activity);
}
JNIEXPORT void JNICALL
Java_com_introlab_rtabmap_RTABMapLib_openEmptyDatabase(
JNIEnv* env, jobject)
{
return app.openDatabase();
}
JNIEXPORT void JNICALL
Java_com_introlab_rtabmap_RTABMapLib_openDatabase(
JNIEnv* env, jobject, jstring databasePath)

View File

@@ -86,7 +86,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
private String mOpenedDatabasePath = "";
private String mTempDatabasePath = "";
private String mWorkingDirectory = "";
private int mMaxDepthIndex = 5;
@@ -177,7 +176,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
mOpenedDatabasePath = "";
mTempDatabasePath = "";
mWorkingDirectory = "";
mTotalLoopClosures = 0;
@@ -187,13 +185,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mWorkingDirectory = extStore.getAbsolutePath() + "/" + getString(R.string.app_name) + "/";
extStore = new File(mWorkingDirectory);
extStore.mkdirs();
mTempDatabasePath = mWorkingDirectory + "rtabmap.tmp.db";
extStore = new File(mTempDatabasePath);
if(extStore.exists())
{
extStore.delete();
}
}
else
{
@@ -204,7 +195,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
RTABMapLib.onCreate(this);
RTABMapLib.openDatabase(mTempDatabasePath);
RTABMapLib.openEmptyDatabase();
}
@Override
@@ -908,7 +899,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
if(which >=0 && which < mUpdateRateValues.length)
{
mParamUpdateRateHzIndex = which;
if(RTABMapLib.setMappingParameter("Rtabmap/DetectionRate", mUpdateRateValues[which]) != 0)
if(RTABMapLib.setMappingParameter("Rtabmap/DetectionRate", which == mUpdateRateValues.length-1?"0":mUpdateRateValues[which]) != 0)
{
mToast.makeText(getActivity(), "Failed to set parameter \"Rtabmap/DetectionRate\"!", mToast.LENGTH_LONG).show();
}
@@ -1082,7 +1073,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
notificationManager.notify(0, n);
}
mOpenedDatabasePath = newDatabasePath;
if(!mItemDataRecorderMode.isChecked())
{
mOpenedDatabasePath = newDatabasePath;
}
mProgressDialog.dismiss();
}
});
@@ -1144,7 +1138,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
notificationManager.notify(0, n);
}
mOpenedDatabasePath = newDatabasePath;
if(!mItemDataRecorderMode.isChecked())
{
mOpenedDatabasePath = newDatabasePath;
}
mProgressDialog.dismiss();
}
});
@@ -1180,7 +1177,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
else
{
mOpenedDatabasePath = "";
RTABMapLib.openDatabase(mTempDatabasePath);
RTABMapLib.openEmptyDatabase();
}
mMapIsEmpty = true;
}
@@ -1211,7 +1208,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
RTABMapLib.setDataRecorderMode(mItemDataRecorderMode.isChecked());
mOpenedDatabasePath = "";
RTABMapLib.openDatabase(mTempDatabasePath);
RTABMapLib.openEmptyDatabase();
mItemOpen.setEnabled(!mItemDataRecorderMode.isChecked() && mItemPause.isChecked());
mItemPostProcessing.setEnabled(!mItemDataRecorderMode.isChecked() && mItemPause.isChecked());
@@ -1437,12 +1434,6 @@ public class RTABMapActivity extends Activity implements OnClickListener {
RTABMapLib.openDatabase(mOpenedDatabasePath);
RTABMapLib.setCamera(1);
File extStore = new File(mTempDatabasePath);
if(extStore.exists())
{
extStore.delete();
}
}
});
builder.show();

View File

@@ -25,6 +25,7 @@ public class RTABMapLib
// The activity object is used for checking if the API version is outdated.
public static native void onCreate(RTABMapActivity activity);
public static native void openEmptyDatabase();
public static native void openDatabase(String databasePath);
/*