Merged master to devel

This commit is contained in:
matlabbe
2017-06-10 10:34:52 -04:00
12 changed files with 127 additions and 40 deletions

View File

@@ -107,7 +107,7 @@ const float CameraTango::bilateralFilteringSigmaR = 0.075f;
CameraTango::CameraTango(bool colorCamera, int decimation, bool publishRawScan, bool smoothing) :
Camera(0),
tango_config_(0),
firstFrame_(true),
previousStamp_(0.0),
stampEpochOffset_(0.0),
colorCamera_(colorCamera),
decimation_(decimation),
@@ -427,7 +427,8 @@ void CameraTango::close()
tango_config_ = nullptr;
TangoService_disconnect();
}
firstFrame_ = true;
previousPose_.setNull();
previousStamp_ = 0.0;
fisheyeRectifyMapX_ = cv::Mat();
fisheyeRectifyMapY_ = cv::Mat();
}
@@ -866,14 +867,23 @@ void CameraTango::mainLoop()
rtabmap::Transform pose = data.groundTruth();
data.setGroundTruth(Transform());
// convert stamp to epoch
if(firstFrame_)
bool firstFrame = previousPose_.isNull();
if(firstFrame)
{
stampEpochOffset_ = UTimer::now()-data.stamp();
}
data.setStamp(stampEpochOffset_ + data.stamp());
LOGI("Publish odometry message (variance=%f)", firstFrame_?9999:0.000001);
this->post(new OdometryEvent(data, pose, firstFrame_?9999:0.000001, firstFrame_?9999:0.000001));
firstFrame_ = false;
OdometryInfo info;
if(!firstFrame)
{
info.interval = data.stamp()-previousStamp_;
info.transform = previousPose_.inverse() * pose;
}
info.covariance = cv::Mat::eye(6,6,CV_64FC1) * (firstFrame?9999.0:0.000001);
LOGI("Publish odometry message (variance=%f)", firstFrame?9999:0.000001);
this->post(new OdometryEvent(data, pose, info));
previousPose_ = pose;
previousStamp_ = data.stamp();
}
else if(!this->isKilled())
{

View File

@@ -106,7 +106,8 @@ private:
private:
void * tango_config_;
bool firstFrame_;
Transform previousPose_;
double previousStamp_;
UTimer cameraStartedTime_;
double stampEpochOffset_;
bool colorCamera_;

View File

@@ -1914,7 +1914,7 @@ cv::Mat RTABMapApp::mergeTextures(
{
float scale = 0.0f;
std::vector<bool> materialsKept;
rtabmap::util3d::concatenateTextureMaterials(mesh, imageSize, textureSize, scale, &materialsKept);
rtabmap::util3d::concatenateTextureMaterials(mesh, imageSize, textureSize, 1, scale, &materialsKept);
LOGD("scale=%f materials=%d", scale, (int)mesh.tex_materials.size());
if(scale && mesh.tex_materials.size()==1)
{
@@ -2343,6 +2343,7 @@ bool RTABMapApp::exportMesh(
{
std::map<int, rtabmap::Transform> cameraPoses;
std::map<int, rtabmap::CameraModel> cameraModels;
std::map<int, cv::Mat> cameraDepths;
UTimer timer;
LOGI("Assemble clouds (%d)...", (int)poses.size());
@@ -2358,6 +2359,7 @@ bool RTABMapApp::exportMesh(
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud;
pcl::IndicesPtr indices(new std::vector<int>);
rtabmap::CameraModel model;
cv::Mat depth;
float gains[3] = {1.0f};
if(jter != createdMeshes_.end())
{
@@ -2367,6 +2369,9 @@ bool RTABMapApp::exportMesh(
gains[0] = jter->second.gains[0];
gains[1] = jter->second.gains[1];
gains[2] = jter->second.gains[2];
rtabmap::SensorData data = rtabmap_->getMemory()->getNodeData(iter->first, false);
data.uncompressData(0, &depth);
}
else
{
@@ -2375,6 +2380,7 @@ bool RTABMapApp::exportMesh(
{
cloud = rtabmap::util3d::cloudRGBFromSensorData(data, meshDecimation_, maxCloudDepth_, minCloudDepth_, indices.get());
model = data.cameraModels()[0];
depth = data.depthRaw();
}
}
if(cloud->size() && indices->size() && model.isValidForProjection())
@@ -2422,6 +2428,10 @@ bool RTABMapApp::exportMesh(
cameraPoses.insert(std::make_pair(iter->first, iter->second));
cameraModels.insert(std::make_pair(iter->first, model));
if(!depth.empty())
{
cameraDepths.insert(std::make_pair(iter->first, depth));
}
LOGI("Assembled %d points (%d/%d total=%d)", (int)cloudWithNormals->size(), ++cloudCount, (int)poses.size(), (int)mergedClouds->size());
}
@@ -2733,7 +2743,10 @@ bool RTABMapApp::exportMesh(
mesh,
cameraPoses,
cameraModels,
cameraDepths,
optimizedMaxTextureDistance,
0.0f,
0.0f,
optimizedMinTextureClusterSize,
std::vector<float>(),
&progressionStatus_,

View File

@@ -56,6 +56,7 @@ import android.os.Environment;
import android.os.Handler;
import android.os.Debug;
import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Html;
@@ -120,6 +121,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
public static final String RTABMAP_WORKING_DIR_KEY = "com.introlab.rtabmap.WORKING_DIR";
public static final int SKETCHFAB_ACTIVITY_CODE = 999;
private String mAuthToken;
public static final long NOTOUCH_TIMEOUT = 5000; // 5 sec
private boolean mHudVisible = true;
// UI states
private static enum State {
@@ -282,6 +286,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mGLView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
resetNoTouchTimer();
mGesDetect.onTouchEvent(event);
// Pass the touch event to the native layer for camera control.
@@ -432,6 +439,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
@Override
protected void onPause() {
super.onPause();
stopDisconnectTimer();
if(!DISABLE_LOG) Log.i(TAG, "onPause()");
mOnPause = true;
@@ -578,6 +586,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
}
TangoInitializationHelper.bindTangoService(getActivity(), mTangoServiceConnection);
resetNoTouchTimer();
}
private void setCamera(int type)
@@ -628,6 +637,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
default:
return;
}
resetNoTouchTimer();
}
private void setAndroidOrientation() {
@@ -1150,6 +1160,35 @@ public class RTABMapActivity extends Activity implements OnClickListener {
});
workingThread.start();
}
private Handler notouchHandler = new Handler(){
public void handleMessage(Message msg) {
}
};
private Runnable notouchCallback = new Runnable() {
@Override
public void run() {
mHudVisible = false;
updateState(mState);
}
};
public void resetNoTouchTimer(){
if(!mHudVisible)
{
mHudVisible = true;
updateState(mState);
}
mHudVisible = true;
notouchHandler.removeCallbacks(notouchCallback);
notouchHandler.postDelayed(notouchCallback, NOTOUCH_TIMEOUT);
}
public void stopDisconnectTimer(){
notouchHandler.removeCallbacks(notouchCallback);
}
private void updateState(State state)
{
@@ -1175,10 +1214,10 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mButtonPause.setVisibility(View.INVISIBLE);
break;
case STATE_VISUALIZING:
mButtonLighting.setVisibility(View.VISIBLE);
mButtonCloseVisualization.setVisibility(View.VISIBLE);
mButtonSaveOnDevice.setVisibility(View.VISIBLE);
mButtonShareOnSketchfab.setVisibility(View.VISIBLE);
mButtonLighting.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonCloseVisualization.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonSaveOnDevice.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonShareOnSketchfab.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mItemSave.setEnabled(mButtonPause.isChecked());
mItemExport.setEnabled(mButtonPause.isChecked() && !mItemDataRecorderMode.isChecked());
mItemOpen.setEnabled(false);
@@ -1201,11 +1240,15 @@ public class RTABMapActivity extends Activity implements OnClickListener {
mItemSettings.setEnabled(true);
mItemReset.setEnabled(true);
mItemModes.setEnabled(true);
mButtonPause.setVisibility(View.VISIBLE);
mButtonPause.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mItemDataRecorderMode.setEnabled(mButtonPause.isChecked());
RTABMapLib.postExportation(false);
break;
}
mButtonFirst.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonThird.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonTop.setVisibility(mHudVisible?View.VISIBLE:View.INVISIBLE);
mButtonBackfaceShown.setVisibility(mHudVisible && (mItemRenderingMesh.isChecked() || mItemRenderingTextureMesh.isChecked())?View.VISIBLE:View.INVISIBLE);
}
private void pauseMapping() {
@@ -1800,6 +1843,7 @@ public class RTABMapActivity extends Activity implements OnClickListener {
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
mExportedOBJ = isOBJ;
resetNoTouchTimer();
updateState(State.STATE_VISUALIZING);
RTABMapLib.postExportation(true);
if(mButtonFirst.isChecked())