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
+16 -6
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())
{
+2 -1
View File
@@ -106,7 +106,8 @@ private:
private:
void * tango_config_;
bool firstFrame_;
Transform previousPose_;
double previousStamp_;
UTimer cameraStartedTime_;
double stampEpochOffset_;
bool colorCamera_;
+14 -1
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_,
@@ -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;
@@ -121,6 +122,9 @@ public class RTABMapActivity extends Activity implements OnClickListener {
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 {
STATE_IDLE,
@@ -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() {
@@ -1151,6 +1161,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)
{
if(mState == State.STATE_VISUALIZING && state == State.STATE_IDLE && mMapNodes > 100)
@@ -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())
+1 -1
View File
@@ -327,7 +327,7 @@ class RTABMAP_EXP Parameters
// Local/Proximity loop closure detection
RTABMAP_PARAM(RGBD, ProximityByTime, bool, false, "Detection over all locations in STM.");
RTABMAP_PARAM(RGBD, ProximityBySpace, bool, true, "Detection over locations (in Working Memory or STM) near in space.");
RTABMAP_PARAM(RGBD, ProximityBySpace, bool, true, "Detection over locations (in Working Memory) near in space.");
RTABMAP_PARAM(RGBD, ProximityMaxGraphDepth, int, 50, "Maximum depth from the current/last loop closure location and the local loop closure hypotheses. Set 0 to ignore.");
RTABMAP_PARAM(RGBD, ProximityMaxPaths, int, 3, "Maximum paths compared (from the most recent) for proximity detection by space. 0 means no limit.");
RTABMAP_PARAM(RGBD, ProximityPathFilteringRadius, float, 0.5, "Path filtering radius to reduce the number of nodes to compare in a path. A path should also be inside that radius to be considered for proximity detection.");
@@ -32,6 +32,7 @@ RTAB-Map integration: Mathieu Labbe
#include <assert.h>
#include <vector>
#include <set>
#include <Eigen/Core>
#include <opencv2/opencv.hpp>
#include <rtabmap/utilite/UMutex.h>
+18 -10
View File
@@ -1029,7 +1029,8 @@ SensorData CameraStereoZed::captureImage(CameraInfo * info)
sl::Pose pose;
zed_->getPosition(pose);
int trackingConfidence = pose.pose_confidence;
if (trackingConfidence)
// FIXME What does pose_confidence == -1 mean?
if (trackingConfidence>0)
{
info->odomPose = zedPoseToTransform(pose);
if (!info->odomPose.isNull())
@@ -1037,24 +1038,31 @@ SensorData CameraStereoZed::captureImage(CameraInfo * info)
//transform x->forward, y->left, z->up
Transform opticalTransform(0, 0, 1, 0, -1, 0, 0, 0, 0, -1, 0, 0);
info->odomPose = opticalTransform * info->odomPose * opticalTransform.inverse();
}
if (lost_)
{
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f; // don't know transform with previous pose
lost_ = false;
UDEBUG("Init %s (var=%f)", info->odomPose.prettyPrint().c_str(), 9999.0f);
if (lost_)
{
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f; // don't know transform with previous pose
lost_ = false;
UDEBUG("Init %s (var=%f)", info->odomPose.prettyPrint().c_str(), 9999.0f);
}
else
{
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 1.0f / float(trackingConfidence);
UDEBUG("Run %s (var=%f)", info->odomPose.prettyPrint().c_str(), 1.0f / float(trackingConfidence));
}
}
else
{
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 1.0f / float(trackingConfidence);
UDEBUG("Run %s (var=%f)", info->odomPose.prettyPrint().c_str(), 1.0f / float(trackingConfidence));
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f; // lost
lost_ = true;
UWARN("ZED lost! (trackingConfidence=%d)", trackingConfidence);
}
}
else
{
info->odomCovariance = cv::Mat::eye(6, 6, CV_64FC1) * 9999.0f; // lost
lost_ = true;
UWARN("ZED lost!");
UWARN("ZED lost! (trackingConfidence=%d)", trackingConfidence);
}
}
}
@@ -1327,7 +1327,7 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
cv::Mat depth = cameras[current_cam].depth;
bool currentDepthSet = false;
float maxDepthError = max_depth_error_==0.0f?std::sqrt(iter->second.longestEdgeSqrd) : max_depth_error_;
float maxDepthError = max_depth_error_==0.0f?std::sqrt(iter->second.longestEdgeSqrd)*2.0f : max_depth_error_;
if(!cameras[current_cam].depth.empty() && maxDepthError > 0.0f)
{
float d1 = depth.type() == CV_32FC1?
+2 -5
View File
@@ -990,12 +990,9 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_EXP cloudRGBFromSensorData(
decimation = 1;
}
UASSERT(!sensorData.imageRaw().empty());
UASSERT((!sensorData.depthRaw().empty() && sensorData.cameraModels().size()) ||
(!sensorData.rightRaw().empty() && sensorData.stereoCameraModel().isValidForProjection()));
pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>);
if(!sensorData.depthRaw().empty() && sensorData.cameraModels().size())
if(!sensorData.imageRaw().empty() && !sensorData.depthRaw().empty() && sensorData.cameraModels().size())
{
//depth
UDEBUG("");
@@ -1090,7 +1087,7 @@ pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_EXP cloudRGBFromSensorData(
}
}
}
else if(!sensorData.rightRaw().empty() && sensorData.stereoCameraModel().isValidForProjection())
else if(!sensorData.imageRaw().empty() && !sensorData.rightRaw().empty() && sensorData.stereoCameraModel().isValidForProjection())
{
//stereo
UDEBUG("");
+18 -5
View File
@@ -134,8 +134,21 @@ cd
rm -r pcl
# OpenCV
echo "wget opencv..."
wget -nv https://downloads.sourceforge.net/project/opencvlibrary/opencv-android/3.2.0/opencv-3.2.0-android-sdk.zip
unzip -qq opencv-3.2.0-android-sdk.zip
rm opencv-3.2.0-android-sdk.zip
mv OpenCV-android-sdk /opt/.
git clone https://github.com/opencv/opencv_contrib.git
cd opencv_contrib
git checkout tags/3.2.0
cd
git clone https://github.com/opencv/opencv.git
cd opencv
git checkout tags/3.2.0
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/root/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DOPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/opt/android/armeabi-v7a ..
make
make install
rm -r *
cmake -DCMAKE_TOOLCHAIN_FILE=/root/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DOPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/opt/android/arm64-v8a ..
make
make install
cd
rm -r opencv opencv_contrib
+2 -2
View File
@@ -27,13 +27,13 @@ mv TangoSDK_Hopak_Java.jar rtabmap-tango/app/android/libs/.
# rtabmap
mkdir rtabmap-tango/build/armeabi-v7a
cd rtabmap-tango/build/armeabi-v7a
cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_modules/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/opt/OpenCV-android-sdk/sdk/native/jni -DCMAKE_INSTALL_PREFIX=/opt/android/armeabi-v7a ../..
cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_modules/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/opt/android/armeabi-v7a/sdk/native/jni -DCMAKE_INSTALL_PREFIX=/opt/android/armeabi-v7a ../..
make
cd
mkdir rtabmap-tango/build/arm64-v8a
cd rtabmap-tango/build/arm64-v8a
cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_modules/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/opt/OpenCV-android-sdk/sdk/native/jni -DCMAKE_INSTALL_PREFIX=/opt/android/arm64-v8a ../..
cmake -DCMAKE_TOOLCHAIN_FILE=../../cmake_modules/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DBUILD_SHARED_LIBS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TOOLS=OFF -DCMAKE_BUILD_TYPE=Release -DOpenCV_DIR=/opt/android/arm64-v8a/sdk/native/jni -DCMAKE_INSTALL_PREFIX=/opt/android/arm64-v8a ../..
make
# package with binaries of both architectures
+1 -1
View File
@@ -1733,7 +1733,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
Transform groundTruthOffset = alignPosesToGroundTruth(poses, groundTruth, stat.stamp(), stat.refImageId());
UDEBUG("time= %d ms", time.restart());
if(!_odometryReceived && poses.size())
if(!_odometryReceived && poses.size() && poses.rbegin()->first == stat.refImageId())
{
_cloudViewer->updateCameraTargetPosition(poses.rbegin()->second);