mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 17:40:23 +08:00
Refactored RegistrationIcp: libpointmatcher yaml config usage / integrated CCCoreLib (#704)
* Refactored RegistrationIcp so that libpointmatcher yaml can work with icp odometry (we can then avoid refiltering data with local map of F2M). All data filtering (including libpointmatcher DataFilters) are done at the beginning of the function. * ICP: Restored ref and data scans order for libpointmatcher (seems more stable this way). * Fixed compilation error without libpointmatcher * CCCoreLib integration (Icp/Strategy=2). Icp/PMForce4DoF is now Icp/Force4DoF. Icp/PM is now Icp/Strategy. Icp/PMOutlierRatio is now Icp/OutlierRatio. * Fixed build without CCCoreLib * Cleanup RegistrationIcp from third party functions. * Preferences: disable libpointmatcher and cccorlib options if not available
This commit is contained in:
@@ -433,6 +433,13 @@ IF(libpointmatcher_FOUND)
|
||||
)
|
||||
ENDIF(libpointmatcher_FOUND)
|
||||
|
||||
IF(CCCoreLib_FOUND)
|
||||
SET(LIBRARIES
|
||||
${LIBRARIES}
|
||||
CCCoreLib::CCCoreLib
|
||||
)
|
||||
ENDIF(CCCoreLib_FOUND)
|
||||
|
||||
IF(FastCV_FOUND)
|
||||
SET(INCLUDE_DIRS
|
||||
${INCLUDE_DIRS}
|
||||
|
||||
@@ -3075,7 +3075,7 @@ Transform Memory::computeIcpTransformMulti(
|
||||
Transform t;
|
||||
if(!fromScan.isEmpty() && !toScan.isEmpty())
|
||||
{
|
||||
Transform guess = poses.at(fromId).inverse() * poses.at(toId);
|
||||
Transform guess = poses.at(toId).inverse() * poses.at(fromId);
|
||||
float guessNorm = guess.getNorm();
|
||||
if(fromScan.rangeMax() > 0.0f && toScan.rangeMax() > 0.0f &&
|
||||
guessNorm > fromScan.rangeMax() + toScan.rangeMax())
|
||||
@@ -3214,7 +3214,11 @@ Transform Memory::computeIcpTransformMulti(
|
||||
fromScan.rangeMax(),
|
||||
fromScan.is2d()?Transform(0,0,fromScan.localTransform().z(),0,0,0):Transform::getIdentity()));
|
||||
|
||||
t = _registrationIcpMulti->computeTransformation(fromS->sensorData(), assembledData, guess, info);
|
||||
t = _registrationIcpMulti->computeTransformation(assembledData, fromS->sensorData(), guess, info);
|
||||
if(!t.isNull())
|
||||
{
|
||||
t = t.inverse();
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
|
||||
@@ -529,6 +529,7 @@ Transform Odometry::process(SensorData & data, const Transform & guessIn, Odomet
|
||||
kpts[i].octave += log2value;
|
||||
}
|
||||
data.setFeatures(kpts, decimatedData.keypoints3D(), decimatedData.descriptors());
|
||||
data.setLaserScan(decimatedData.laserScanRaw());
|
||||
|
||||
if(info)
|
||||
{
|
||||
|
||||
@@ -244,6 +244,10 @@ const std::map<std::string, std::pair<bool, std::string> > & Parameters::getRemo
|
||||
|
||||
removedParameters_.insert(std::make_pair("RGBD/SavedLocalizationIgnored", std::make_pair(true, Parameters::kRGBDStartAtOrigin())));
|
||||
|
||||
removedParameters_.insert(std::make_pair("Icp/PMForce4DoF", std::make_pair(true, Parameters::kIcpForce4DoF())));
|
||||
removedParameters_.insert(std::make_pair("Icp/PM", std::make_pair(true, Parameters::kIcpStrategy()))); // convert "true" to "1"
|
||||
removedParameters_.insert(std::make_pair("Icp/PMOutlierRatio", std::make_pair(true, Parameters::kIcpOutlierRatio())));
|
||||
|
||||
// 0.20.
|
||||
removedParameters_.insert(std::make_pair("SuperGlue/Path", std::make_pair(true, Parameters::kPyMatcherPath())));
|
||||
removedParameters_.insert(std::make_pair("SuperGlue/Iterations", std::make_pair(true, Parameters::kPyMatcherIterations())));
|
||||
@@ -784,6 +788,12 @@ ParametersMap Parameters::parseArguments(int argc, char * argv[], bool onlyParam
|
||||
std::cout << str << std::setw(spacing - str.size()) << "true" << std::endl;
|
||||
#else
|
||||
std::cout << str << std::setw(spacing - str.size()) << "false" << std::endl;
|
||||
#endif
|
||||
str = "With CCCoreLib:";
|
||||
#ifdef RTABMAP_CCCORELIB
|
||||
std::cout << str << std::setw(spacing - str.size()) << "true" << std::endl;
|
||||
#else
|
||||
std::cout << str << std::setw(spacing - str.size()) << "false" << std::endl;
|
||||
#endif
|
||||
str = "With octomap:";
|
||||
#ifdef RTABMAP_OCTOMAP
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
180
corelib/src/icp/cccorelib.h
Normal file
180
corelib/src/icp/cccorelib.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
Copyright (c) 2010-2021, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Universite de Sherbrooke nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef CORELIB_SRC_ICP_CCCORELIB_H_
|
||||
#define CORELIB_SRC_ICP_CCCORELIB_H_
|
||||
|
||||
#include <CCCoreLib/RegistrationTools.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
rtabmap::Transform icpCC(
|
||||
const pcl::PointCloud<pcl::PointXYZI>::Ptr & fromCloud,
|
||||
pcl::PointCloud<pcl::PointXYZI>::Ptr & toCloud,
|
||||
int maxIterations = 150,
|
||||
double minRMSDecrease = 0.00001,
|
||||
bool force3DoF = false,
|
||||
bool force4DoF = false,
|
||||
int samplingLimit = 50000,
|
||||
double finalOverlapRatio = 0.85,
|
||||
bool filterOutFarthestPoints = false,
|
||||
double maxFinalRMS = 0.2,
|
||||
std::string * errorMsg = 0)
|
||||
{
|
||||
UDEBUG("maxIterations=%d", maxIterations);
|
||||
UDEBUG("minRMSDecrease=%f", minRMSDecrease);
|
||||
UDEBUG("samplingLimit=%d", samplingLimit);
|
||||
UDEBUG("finalOverlapRatio=%f", finalOverlapRatio);
|
||||
UDEBUG("filterOutFarthestPoints=%s", filterOutFarthestPoints?"true":"false");
|
||||
UDEBUG("force 3DoF=%s 4DoF=%s", force3DoF?"true":"false", force4DoF?"true":"false");
|
||||
UDEBUG("maxFinalRMS=%f", maxFinalRMS);
|
||||
|
||||
rtabmap::Transform icpTransformation;
|
||||
|
||||
CCCoreLib::ICPRegistrationTools::RESULT_TYPE result;
|
||||
CCCoreLib::PointProjectionTools::Transformation transform;
|
||||
CCCoreLib::ICPRegistrationTools::Parameters params;
|
||||
{
|
||||
if(minRMSDecrease > 0.0)
|
||||
{
|
||||
params.convType = CCCoreLib::ICPRegistrationTools::MAX_ERROR_CONVERGENCE;
|
||||
params.minRMSDecrease = minRMSDecrease; //! The minimum error (RMS) reduction between two consecutive steps to continue process (ignored if convType is not MAX_ERROR_CONVERGENCE)
|
||||
}
|
||||
else
|
||||
{
|
||||
params.convType = CCCoreLib::ICPRegistrationTools::MAX_ITER_CONVERGENCE;
|
||||
params.nbMaxIterations = maxIterations; //! The maximum number of iteration (ignored if convType is not MAX_ITER_CONVERGENCE)
|
||||
}
|
||||
params.adjustScale = false; //! Whether to release the scale parameter during the registration procedure or not
|
||||
params.filterOutFarthestPoints = filterOutFarthestPoints; //! If true, the algorithm will automatically ignore farthest points from the reference, for better convergence
|
||||
params.samplingLimit = samplingLimit; //! Maximum number of points per cloud (they are randomly resampled below this limit otherwise)
|
||||
params.finalOverlapRatio = finalOverlapRatio; //! Theoretical overlap ratio (at each iteration, only this percentage (between 0 and 1) will be used for registration
|
||||
params.modelWeights = nullptr; //! Weights for model points (i.e. only if the model entity is a cloud) (optional)
|
||||
params.dataWeights = nullptr; //! Weights for data points (optional)
|
||||
params.transformationFilters = force3DoF?33:force4DoF?1:0; //! Filters to be applied on the resulting transformation at each step (experimental) - see RegistrationTools::TRANSFORMATION_FILTERS flags
|
||||
params.maxThreadCount = 0; //! Maximum number of threads to use (0 = max)
|
||||
}
|
||||
|
||||
double finalError = 0.0;
|
||||
unsigned finalPointCount = 0;
|
||||
|
||||
CCCoreLib::PointCloud toPointCloud = CCCoreLib::PointCloud();
|
||||
CCCoreLib::PointCloud fromPointCloud = CCCoreLib::PointCloud();
|
||||
|
||||
fromPointCloud.reserve(fromCloud->points.size());
|
||||
for(uint nIndex=0; nIndex < fromCloud->points.size(); nIndex++)
|
||||
{
|
||||
CCVector3 P;
|
||||
P.x = fromCloud->points[nIndex].x;
|
||||
P.y = fromCloud->points[nIndex].y;
|
||||
P.z = fromCloud->points[nIndex].z;
|
||||
fromPointCloud.addPoint(P);
|
||||
}
|
||||
toPointCloud.reserve(toCloud->points.size());
|
||||
for(uint nIndex=0; nIndex < toCloud->points.size(); nIndex++)
|
||||
{
|
||||
CCVector3 P;
|
||||
P.x = toCloud->points[nIndex].x;
|
||||
P.y = toCloud->points[nIndex].y;
|
||||
P.z = toCloud->points[nIndex].z;
|
||||
toPointCloud.addPoint(P);
|
||||
}
|
||||
|
||||
UDEBUG("CCCoreLib: start ICP");
|
||||
result = CCCoreLib::ICPRegistrationTools::Register(
|
||||
&fromPointCloud,
|
||||
nullptr,
|
||||
&toPointCloud,
|
||||
params,
|
||||
transform,
|
||||
finalError,
|
||||
finalPointCount);
|
||||
UDEBUG("CCCoreLib: ICP done!");
|
||||
|
||||
UDEBUG("CC ICP result: %d", result);
|
||||
UDEBUG("CC Final error: %f . Finall Pointcount: %d", finalError, finalPointCount);
|
||||
UDEBUG("CC ICP success Trans: %f %f %f", transform.T.x,transform.T.y,transform.T.z);
|
||||
|
||||
if(result != 1)
|
||||
{
|
||||
std::string msg = uFormat("CCCoreLib has failed: Rejecting transform as result %d !=1", result);
|
||||
UDEBUG(msg.c_str());
|
||||
if(errorMsg)
|
||||
{
|
||||
*errorMsg = msg;
|
||||
}
|
||||
|
||||
icpTransformation.setNull();
|
||||
return icpTransformation;
|
||||
}
|
||||
else if(finalPointCount <10)
|
||||
{
|
||||
std::string msg = uFormat("CCCoreLib has failed: Rejecting transform as finalPointCount %d < 10 ", finalPointCount);
|
||||
UDEBUG(msg.c_str());
|
||||
if(errorMsg)
|
||||
{
|
||||
*errorMsg = msg;
|
||||
}
|
||||
|
||||
icpTransformation.setNull();
|
||||
return icpTransformation;
|
||||
}
|
||||
//CC transform to EIgen4f
|
||||
Eigen::Matrix4f matrix;
|
||||
matrix.setIdentity();
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
for(int j=0;j<3;j++)
|
||||
{
|
||||
matrix(i,j)=transform.R.getValue(i,j);
|
||||
}
|
||||
}
|
||||
for(int i=0;i<3;i++)
|
||||
{
|
||||
matrix(i,3)=transform.T[i];
|
||||
}
|
||||
|
||||
icpTransformation = rtabmap::Transform::fromEigen4f(matrix);
|
||||
icpTransformation = icpTransformation.inverse();
|
||||
UDEBUG("CC ICP result: %s", icpTransformation.prettyPrint().c_str());
|
||||
|
||||
if(finalError > maxFinalRMS)
|
||||
{
|
||||
std::string msg = uFormat("CCCoreLib has failed: Rejecting transform as RMS %f > %f (%s) ", finalError, maxFinalRMS, rtabmap::Parameters::kIcpCCMaxFinalRMS().c_str());
|
||||
UDEBUG(msg.c_str());
|
||||
if(errorMsg)
|
||||
{
|
||||
*errorMsg = msg;
|
||||
}
|
||||
icpTransformation.setNull();
|
||||
}
|
||||
return icpTransformation;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* CORELIB_SRC_ICP_CCCORELIB_H_ */
|
||||
534
corelib/src/icp/libpointmatcher.h
Normal file
534
corelib/src/icp/libpointmatcher.h
Normal file
@@ -0,0 +1,534 @@
|
||||
/*
|
||||
Copyright (c) 2010-2021, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Universite de Sherbrooke nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef CORELIB_SRC_ICP_LIBPOINTMATCHER_H_
|
||||
#define CORELIB_SRC_ICP_LIBPOINTMATCHER_H_
|
||||
|
||||
#include <fstream>
|
||||
#include "pointmatcher/PointMatcher.h"
|
||||
#include "nabo/nabo.h"
|
||||
typedef PointMatcher<float> PM;
|
||||
typedef PM::DataPoints DP;
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
DP pclToDP(const pcl::PointCloud<pcl::PointXYZI>::Ptr & pclCloud, bool is2D)
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::Label Label;
|
||||
typedef DP::Labels Labels;
|
||||
typedef DP::View View;
|
||||
|
||||
if (pclCloud->empty())
|
||||
return DP();
|
||||
|
||||
// fill labels
|
||||
// conversions of descriptor fields from pcl
|
||||
// see http://www.ros.org/wiki/pcl/Overview
|
||||
Labels featLabels;
|
||||
Labels descLabels;
|
||||
featLabels.push_back(Label("x", 1));
|
||||
featLabels.push_back(Label("y", 1));
|
||||
if(!is2D)
|
||||
{
|
||||
featLabels.push_back(Label("z", 1));
|
||||
}
|
||||
featLabels.push_back(Label("pad", 1));
|
||||
|
||||
descLabels.push_back(Label("intensity", 1));
|
||||
|
||||
// create cloud
|
||||
DP cloud(featLabels, descLabels, pclCloud->size());
|
||||
cloud.getFeatureViewByName("pad").setConstant(1);
|
||||
|
||||
// fill cloud
|
||||
View view(cloud.getFeatureViewByName("x"));
|
||||
View viewIntensity(cloud.getDescriptorRowViewByName("intensity",0));
|
||||
for(unsigned int i=0; i<pclCloud->size(); ++i)
|
||||
{
|
||||
view(0, i) = pclCloud->at(i).x;
|
||||
view(1, i) = pclCloud->at(i).y;
|
||||
if(!is2D)
|
||||
{
|
||||
view(2, i) = pclCloud->at(i).z;
|
||||
}
|
||||
viewIntensity(0, i) = pclCloud->at(i).intensity;
|
||||
}
|
||||
|
||||
return cloud;
|
||||
}
|
||||
|
||||
DP pclToDP(const pcl::PointCloud<pcl::PointXYZINormal>::Ptr & pclCloud, bool is2D)
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::Label Label;
|
||||
typedef DP::Labels Labels;
|
||||
typedef DP::View View;
|
||||
|
||||
if (pclCloud->empty())
|
||||
return DP();
|
||||
|
||||
// fill labels
|
||||
// conversions of descriptor fields from pcl
|
||||
// see http://www.ros.org/wiki/pcl/Overview
|
||||
Labels featLabels;
|
||||
Labels descLabels;
|
||||
featLabels.push_back(Label("x", 1));
|
||||
featLabels.push_back(Label("y", 1));
|
||||
if(!is2D)
|
||||
{
|
||||
featLabels.push_back(Label("z", 1));
|
||||
}
|
||||
featLabels.push_back(Label("pad", 1));
|
||||
|
||||
descLabels.push_back(Label("normals", 3));
|
||||
descLabels.push_back(Label("intensity", 1));
|
||||
|
||||
// create cloud
|
||||
DP cloud(featLabels, descLabels, pclCloud->size());
|
||||
cloud.getFeatureViewByName("pad").setConstant(1);
|
||||
|
||||
// fill cloud
|
||||
View view(cloud.getFeatureViewByName("x"));
|
||||
View viewNormalX(cloud.getDescriptorRowViewByName("normals",0));
|
||||
View viewNormalY(cloud.getDescriptorRowViewByName("normals",1));
|
||||
View viewNormalZ(cloud.getDescriptorRowViewByName("normals",2));
|
||||
View viewIntensity(cloud.getDescriptorRowViewByName("intensity",0));
|
||||
for(unsigned int i=0; i<pclCloud->size(); ++i)
|
||||
{
|
||||
view(0, i) = pclCloud->at(i).x;
|
||||
view(1, i) = pclCloud->at(i).y;
|
||||
if(!is2D)
|
||||
{
|
||||
view(2, i) = pclCloud->at(i).z;
|
||||
}
|
||||
viewNormalX(0, i) = pclCloud->at(i).normal_x;
|
||||
viewNormalY(0, i) = pclCloud->at(i).normal_y;
|
||||
viewNormalZ(0, i) = pclCloud->at(i).normal_z;
|
||||
viewIntensity(0, i) = pclCloud->at(i).intensity;
|
||||
}
|
||||
|
||||
return cloud;
|
||||
}
|
||||
|
||||
DP laserScanToDP(const rtabmap::LaserScan & scan, bool ignoreLocalTransform = false)
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::Label Label;
|
||||
typedef DP::Labels Labels;
|
||||
typedef DP::View View;
|
||||
|
||||
if (scan.isEmpty())
|
||||
return DP();
|
||||
|
||||
// fill labels
|
||||
// conversions of descriptor fields from pcl
|
||||
// see http://www.ros.org/wiki/pcl/Overview
|
||||
Labels featLabels;
|
||||
Labels descLabels;
|
||||
featLabels.push_back(Label("x", 1));
|
||||
featLabels.push_back(Label("y", 1));
|
||||
if(!scan.is2d())
|
||||
{
|
||||
featLabels.push_back(Label("z", 1));
|
||||
}
|
||||
featLabels.push_back(Label("pad", 1));
|
||||
|
||||
if(scan.hasNormals())
|
||||
{
|
||||
descLabels.push_back(Label("normals", 3));
|
||||
}
|
||||
if(scan.hasIntensity())
|
||||
{
|
||||
descLabels.push_back(Label("intensity", 1));
|
||||
}
|
||||
|
||||
|
||||
// create cloud
|
||||
DP cloud(featLabels, descLabels, scan.size());
|
||||
cloud.getFeatureViewByName("pad").setConstant(1);
|
||||
|
||||
// fill cloud
|
||||
int nx = scan.getNormalsOffset();
|
||||
int ny = nx+1;
|
||||
int nz = ny+1;
|
||||
int offsetI = scan.getIntensityOffset();
|
||||
bool hasLocalTransform = !ignoreLocalTransform && !scan.localTransform().isNull() && !scan.localTransform().isIdentity();
|
||||
View view(cloud.getFeatureViewByName("x"));
|
||||
View viewNormalX(nx!=-1?cloud.getDescriptorRowViewByName("normals",0):view);
|
||||
View viewNormalY(nx!=-1?cloud.getDescriptorRowViewByName("normals",1):view);
|
||||
View viewNormalZ(nx!=-1?cloud.getDescriptorRowViewByName("normals",2):view);
|
||||
View viewIntensity(offsetI!=-1?cloud.getDescriptorRowViewByName("intensity",0):view);
|
||||
int oi = 0;
|
||||
for(int i=0; i<scan.size(); ++i)
|
||||
{
|
||||
const float * ptr = scan.data().ptr<float>(0, i);
|
||||
|
||||
if(uIsFinite(ptr[0]) && uIsFinite(ptr[1]) && (scan.is2d() || uIsFinite(ptr[2])))
|
||||
{
|
||||
if(hasLocalTransform)
|
||||
{
|
||||
if(nx == -1)
|
||||
{
|
||||
cv::Point3f pt(ptr[0], ptr[1], scan.is2d()?0:ptr[2]);
|
||||
pt = rtabmap::util3d::transformPoint(pt, scan.localTransform());
|
||||
view(0, oi) = pt.x;
|
||||
view(1, oi) = pt.y;
|
||||
if(!scan.is2d())
|
||||
{
|
||||
view(2, oi) = pt.z;
|
||||
}
|
||||
if(offsetI!=-1)
|
||||
{
|
||||
viewIntensity(0, oi) = ptr[offsetI];
|
||||
}
|
||||
++oi;
|
||||
}
|
||||
else if(uIsFinite(ptr[nx]) && uIsFinite(ptr[ny]) && uIsFinite(ptr[nz]))
|
||||
{
|
||||
pcl::PointNormal pt;
|
||||
pt.x=ptr[0];
|
||||
pt.y=ptr[1];
|
||||
pt.z=scan.is2d()?0:ptr[2];
|
||||
pt.normal_x=ptr[nx];
|
||||
pt.normal_y=ptr[ny];
|
||||
pt.normal_z=ptr[nz];
|
||||
pt = rtabmap::util3d::transformPoint(pt, scan.localTransform());
|
||||
view(0, oi) = pt.x;
|
||||
view(1, oi) = pt.y;
|
||||
if(!scan.is2d())
|
||||
{
|
||||
view(2, oi) = pt.z;
|
||||
}
|
||||
viewNormalX(0, oi) = pt.normal_x;
|
||||
viewNormalY(0, oi) = pt.normal_y;
|
||||
viewNormalZ(0, oi) = pt.normal_z;
|
||||
|
||||
if(offsetI!=-1)
|
||||
{
|
||||
viewIntensity(0, oi) = ptr[offsetI];
|
||||
}
|
||||
|
||||
++oi;
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("Ignoring point %d with invalid data: pos=%f %f %f, normal=%f %f %f", i, ptr[0], ptr[1], scan.is2d()?0:ptr[3], ptr[nx], ptr[ny], ptr[nz]);
|
||||
}
|
||||
}
|
||||
else if(nx==-1 || (uIsFinite(ptr[nx]) && uIsFinite(ptr[ny]) && uIsFinite(ptr[nz])))
|
||||
{
|
||||
view(0, oi) = ptr[0];
|
||||
view(1, oi) = ptr[1];
|
||||
if(!scan.is2d())
|
||||
{
|
||||
view(2, oi) = ptr[2];
|
||||
}
|
||||
if(nx!=-1)
|
||||
{
|
||||
viewNormalX(0, oi) = ptr[nx];
|
||||
viewNormalY(0, oi) = ptr[ny];
|
||||
viewNormalZ(0, oi) = ptr[nz];
|
||||
}
|
||||
if(offsetI!=-1)
|
||||
{
|
||||
viewIntensity(0, oi) = ptr[offsetI];
|
||||
}
|
||||
++oi;
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("Ignoring point %d with invalid data: pos=%f %f %f, normal=%f %f %f", i, ptr[0], ptr[1], scan.is2d()?0:ptr[3], ptr[nx], ptr[ny], ptr[nz]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("Ignoring point %d with invalid data: pos=%f %f %f", i, ptr[0], ptr[1], scan.is2d()?0:ptr[3]);
|
||||
}
|
||||
|
||||
}
|
||||
if(oi != scan.size())
|
||||
{
|
||||
cloud.conservativeResize(oi);
|
||||
}
|
||||
|
||||
return cloud;
|
||||
}
|
||||
|
||||
void pclFromDP(const DP & cloud, pcl::PointCloud<pcl::PointXYZI> & pclCloud)
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::ConstView ConstView;
|
||||
|
||||
if (cloud.features.cols() == 0)
|
||||
return;
|
||||
|
||||
pclCloud.resize(cloud.features.cols());
|
||||
pclCloud.is_dense = true;
|
||||
|
||||
bool hasIntensity = cloud.descriptorExists("intensity");
|
||||
|
||||
// fill cloud
|
||||
ConstView view(cloud.getFeatureViewByName("x"));
|
||||
ConstView viewIntensity(hasIntensity?cloud.getDescriptorRowViewByName("intensity",0):view);
|
||||
bool is3D = cloud.featureExists("z");
|
||||
for(unsigned int i=0; i<pclCloud.size(); ++i)
|
||||
{
|
||||
pclCloud.at(i).x = view(0, i);
|
||||
pclCloud.at(i).y = view(1, i);
|
||||
pclCloud.at(i).z = is3D?view(2, i):0;
|
||||
if(hasIntensity)
|
||||
pclCloud.at(i).intensity = viewIntensity(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
void pclFromDP(const DP & cloud, pcl::PointCloud<pcl::PointXYZINormal> & pclCloud)
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::ConstView ConstView;
|
||||
|
||||
if (cloud.features.cols() == 0)
|
||||
return;
|
||||
|
||||
pclCloud.resize(cloud.features.cols());
|
||||
pclCloud.is_dense = true;
|
||||
|
||||
bool hasIntensity = cloud.descriptorExists("intensity");
|
||||
|
||||
// fill cloud
|
||||
ConstView view(cloud.getFeatureViewByName("x"));
|
||||
bool is3D = cloud.featureExists("z");
|
||||
ConstView viewNormalX(cloud.getDescriptorRowViewByName("normals",0));
|
||||
ConstView viewNormalY(cloud.getDescriptorRowViewByName("normals",1));
|
||||
ConstView viewNormalZ(cloud.getDescriptorRowViewByName("normals",2));
|
||||
ConstView viewIntensity(hasIntensity?cloud.getDescriptorRowViewByName("intensity",0):view);
|
||||
for(unsigned int i=0; i<pclCloud.size(); ++i)
|
||||
{
|
||||
pclCloud.at(i).x = view(0, i);
|
||||
pclCloud.at(i).y = view(1, i);
|
||||
pclCloud.at(i).z = is3D?view(2, i):0;
|
||||
pclCloud.at(i).normal_x = viewNormalX(0, i);
|
||||
pclCloud.at(i).normal_y = viewNormalY(0, i);
|
||||
pclCloud.at(i).normal_z = viewNormalZ(0, i);
|
||||
if(hasIntensity)
|
||||
pclCloud.at(i).intensity = viewIntensity(0, i);
|
||||
}
|
||||
}
|
||||
|
||||
rtabmap::LaserScan laserScanFromDP(const DP & cloud, const rtabmap::Transform & localTransform = rtabmap::Transform::getIdentity())
|
||||
{
|
||||
UDEBUG("");
|
||||
typedef DP::ConstView ConstView;
|
||||
|
||||
rtabmap::LaserScan scan;
|
||||
|
||||
if (cloud.features.cols() == 0)
|
||||
return rtabmap::LaserScan();
|
||||
|
||||
// fill cloud
|
||||
bool transformValid = !localTransform.isNull() && !localTransform.isIdentity();
|
||||
rtabmap::Transform localTransformInv;
|
||||
if(transformValid)
|
||||
localTransformInv = localTransform.inverse();
|
||||
bool is3D = cloud.featureExists("z");
|
||||
bool hasNormals = cloud.descriptorExists("normals");
|
||||
bool hasIntensity = cloud.descriptorExists("intensity");
|
||||
ConstView view(cloud.getFeatureViewByName("x"));
|
||||
ConstView viewNormalX(hasNormals?cloud.getDescriptorRowViewByName("normals",0):view);
|
||||
ConstView viewNormalY(hasNormals?cloud.getDescriptorRowViewByName("normals",1):view);
|
||||
ConstView viewNormalZ(hasNormals?cloud.getDescriptorRowViewByName("normals",2):view);
|
||||
ConstView viewIntensity(hasIntensity?cloud.getDescriptorRowViewByName("intensity",0):view);
|
||||
int channels = 2+(is3D?1:0) + (hasNormals?3:0) + (hasIntensity?1:0);
|
||||
cv::Mat data(1, cloud.features.cols(), CV_32FC(channels));
|
||||
for(unsigned int i=0; i<cloud.features.cols(); ++i)
|
||||
{
|
||||
pcl::PointXYZINormal pt;
|
||||
pt.x = view(0, i);
|
||||
pt.y = view(1, i);
|
||||
if(is3D)
|
||||
pt.z = view(2, i);
|
||||
if(hasIntensity)
|
||||
pt.intensity = viewIntensity(0, i);
|
||||
if(hasNormals) {
|
||||
pt.normal_x = viewNormalX(0, i);
|
||||
pt.normal_y = viewNormalY(0, i);
|
||||
pt.normal_z = viewNormalZ(0, i);
|
||||
}
|
||||
if(transformValid)
|
||||
pt = rtabmap::util3d::transformPoint(pt, localTransformInv);
|
||||
|
||||
float * value = data.ptr<float>(0, i);
|
||||
int index = 0;
|
||||
value[index++] = pt.x;
|
||||
value[index++] = pt.y;
|
||||
if(is3D)
|
||||
value[index++] = pt.z;
|
||||
if(hasIntensity)
|
||||
value[index++] = pt.intensity;
|
||||
if(hasNormals) {
|
||||
value[index++] = pt.normal_x;
|
||||
value[index++] = pt.normal_y;
|
||||
value[index++] = pt.normal_z;
|
||||
}
|
||||
}
|
||||
|
||||
UASSERT(data.channels() >= 2 && data.channels() <=7);
|
||||
return rtabmap::LaserScan(data, 0, 0,
|
||||
data.channels()==2?rtabmap::LaserScan::kXY:
|
||||
data.channels()==3?(hasIntensity?rtabmap::LaserScan::kXYI:rtabmap::LaserScan::kXYZ):
|
||||
data.channels()==4?rtabmap::LaserScan::kXYZI:
|
||||
data.channels()==5?rtabmap::LaserScan::kXYINormal:
|
||||
data.channels()==6?rtabmap::LaserScan::kXYZNormal:
|
||||
rtabmap::LaserScan::kXYZINormal,
|
||||
localTransform);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename PointMatcher<T>::TransformationParameters eigenMatrixToDim(const typename PointMatcher<T>::TransformationParameters& matrix, int dimp1)
|
||||
{
|
||||
typedef typename PointMatcher<T>::TransformationParameters M;
|
||||
assert(matrix.rows() == matrix.cols());
|
||||
assert((matrix.rows() == 3) || (matrix.rows() == 4));
|
||||
assert((dimp1 == 3) || (dimp1 == 4));
|
||||
|
||||
if (matrix.rows() == dimp1)
|
||||
return matrix;
|
||||
|
||||
M out(M::Identity(dimp1,dimp1));
|
||||
out.topLeftCorner(2,2) = matrix.topLeftCorner(2,2);
|
||||
out.topRightCorner(2,1) = matrix.topRightCorner(2,1);
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace rtabmap
|
||||
|
||||
template<typename T>
|
||||
struct KDTreeMatcherIntensity : public PointMatcher<T>::Matcher
|
||||
{
|
||||
typedef PointMatcherSupport::Parametrizable Parametrizable;
|
||||
typedef PointMatcherSupport::Parametrizable P;
|
||||
typedef Parametrizable::Parameters Parameters;
|
||||
typedef Parametrizable::ParameterDoc ParameterDoc;
|
||||
typedef Parametrizable::ParametersDoc ParametersDoc;
|
||||
|
||||
typedef typename Nabo::NearestNeighbourSearch<T> NNS;
|
||||
typedef typename NNS::SearchType NNSearchType;
|
||||
|
||||
typedef typename PointMatcher<T>::DataPoints DataPoints;
|
||||
typedef typename PointMatcher<T>::Matcher Matcher;
|
||||
typedef typename PointMatcher<T>::Matches Matches;
|
||||
typedef typename PointMatcher<T>::Matrix Matrix;
|
||||
|
||||
inline static const std::string description()
|
||||
{
|
||||
return "This matcher matches a point from the reading to its closest neighbors in the reference.";
|
||||
}
|
||||
inline static const ParametersDoc availableParameters()
|
||||
{
|
||||
return {
|
||||
{"knn", "number of nearest neighbors to consider it the reference", "1", "1", "2147483647", &P::Comp<unsigned>},
|
||||
{"epsilon", "approximation to use for the nearest-neighbor search", "0", "0", "inf", &P::Comp<T>},
|
||||
{"searchType", "Nabo search type. 0: brute force, check distance to every point in the data (very slow), 1: kd-tree with linear heap, good for small knn (~up to 30) and 2: kd-tree with tree heap, good for large knn (~from 30)", "1", "0", "2", &P::Comp<unsigned>},
|
||||
{"maxDist", "maximum distance to consider for neighbors", "inf", "0", "inf", &P::Comp<T>}
|
||||
};
|
||||
}
|
||||
|
||||
const int knn;
|
||||
const T epsilon;
|
||||
const NNSearchType searchType;
|
||||
const T maxDist;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<NNS> featureNNS;
|
||||
Matrix filteredReferenceIntensity;
|
||||
|
||||
public:
|
||||
KDTreeMatcherIntensity(const Parameters& params = Parameters()) :
|
||||
PointMatcher<T>::Matcher("KDTreeMatcherIntensity", KDTreeMatcherIntensity::availableParameters(), params),
|
||||
knn(Parametrizable::get<int>("knn")),
|
||||
epsilon(Parametrizable::get<T>("epsilon")),
|
||||
searchType(NNSearchType(Parametrizable::get<int>("searchType"))),
|
||||
maxDist(Parametrizable::get<T>("maxDist"))
|
||||
{
|
||||
UINFO("* KDTreeMatcherIntensity: initialized with knn=%d, epsilon=%f, searchType=%d and maxDist=%f", knn, epsilon, searchType, maxDist);
|
||||
}
|
||||
virtual ~KDTreeMatcherIntensity() {}
|
||||
virtual void init(const DataPoints& filteredReference)
|
||||
{
|
||||
// build and populate NNS
|
||||
if(knn>1)
|
||||
{
|
||||
filteredReferenceIntensity = filteredReference.getDescriptorCopyByName("intensity");
|
||||
}
|
||||
else
|
||||
{
|
||||
UWARN("KDTreeMatcherIntensity: knn is not over 1 (%d), intensity re-ordering will be ignored.", knn);
|
||||
}
|
||||
featureNNS.reset( NNS::create(filteredReference.features, filteredReference.features.rows() - 1, searchType, NNS::TOUCH_STATISTICS));
|
||||
}
|
||||
virtual PM::Matches findClosests(const DP& filteredReading)
|
||||
{
|
||||
const int pointsCount(filteredReading.features.cols());
|
||||
Matches matches(
|
||||
typename Matches::Dists(knn, pointsCount),
|
||||
typename Matches::Ids(knn, pointsCount)
|
||||
);
|
||||
|
||||
const BOOST_AUTO(filteredReadingIntensity, filteredReading.getDescriptorViewByName("intensity"));
|
||||
|
||||
static_assert(NNS::InvalidIndex == PM::Matches::InvalidId, "");
|
||||
static_assert(NNS::InvalidValue == PM::Matches::InvalidDist, "");
|
||||
this->visitCounter += featureNNS->knn(filteredReading.features, matches.ids, matches.dists, knn, epsilon, NNS::ALLOW_SELF_MATCH, maxDist);
|
||||
|
||||
if(knn > 1)
|
||||
{
|
||||
Matches matchesOrderedByIntensity(
|
||||
typename Matches::Dists(1, pointsCount),
|
||||
typename Matches::Ids(1, pointsCount)
|
||||
);
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < pointsCount; ++i)
|
||||
{
|
||||
float minDistance = std::numeric_limits<float>::max();
|
||||
for(int k=0; k<knn && k<filteredReferenceIntensity.rows(); ++k)
|
||||
{
|
||||
float distIntensity = fabs(filteredReadingIntensity(0,i) - filteredReferenceIntensity(0, matches.ids.coeff(k, i)));
|
||||
if(distIntensity < minDistance)
|
||||
{
|
||||
matchesOrderedByIntensity.ids.coeffRef(0, i) = matches.ids.coeff(k, i);
|
||||
matchesOrderedByIntensity.dists.coeffRef(0, i) = matches.dists.coeff(k, i);
|
||||
minDistance = distIntensity;
|
||||
}
|
||||
}
|
||||
}
|
||||
matches = matchesOrderedByIntensity;
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* CORELIB_SRC_ICP_LIBPOINTMATCHER_H_ */
|
||||
@@ -99,7 +99,7 @@ Transform OdometryF2F::computeTransform(
|
||||
if(refFrame_.sensorData().isValid())
|
||||
{
|
||||
float maxCorrespondenceDistance = 0.0f;
|
||||
float pmOutlierRatio = 0.0f;
|
||||
float outlierRatio = 0.0f;
|
||||
if(guess.isNull() &&
|
||||
!registrationPipeline_->isImageRequired() &&
|
||||
registrationPipeline_->isScanRequired() &&
|
||||
@@ -107,12 +107,12 @@ Transform OdometryF2F::computeTransform(
|
||||
{
|
||||
// only on initialization (first frame to register), increase icp max correspondences in case the robot is already moving
|
||||
maxCorrespondenceDistance = Parameters::defaultIcpMaxCorrespondenceDistance();
|
||||
pmOutlierRatio = Parameters::defaultIcpPMOutlierRatio();
|
||||
outlierRatio = Parameters::defaultIcpOutlierRatio();
|
||||
Parameters::parse(parameters_, Parameters::kIcpMaxCorrespondenceDistance(), maxCorrespondenceDistance);
|
||||
Parameters::parse(parameters_, Parameters::kIcpPMOutlierRatio(), pmOutlierRatio);
|
||||
Parameters::parse(parameters_, Parameters::kIcpOutlierRatio(), outlierRatio);
|
||||
ParametersMap params;
|
||||
params.insert(ParametersPair(Parameters::kIcpMaxCorrespondenceDistance(), uNumber2Str(maxCorrespondenceDistance*3.0f)));
|
||||
params.insert(ParametersPair(Parameters::kIcpPMOutlierRatio(), uNumber2Str(0.95f)));
|
||||
params.insert(ParametersPair(Parameters::kIcpOutlierRatio(), uNumber2Str(0.95f)));
|
||||
registrationPipeline_->parseParameters(params);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ Transform OdometryF2F::computeTransform(
|
||||
// set it back
|
||||
ParametersMap params;
|
||||
params.insert(ParametersPair(Parameters::kIcpMaxCorrespondenceDistance(), uNumber2Str(maxCorrespondenceDistance)));
|
||||
params.insert(ParametersPair(Parameters::kIcpPMOutlierRatio(), uNumber2Str(pmOutlierRatio)));
|
||||
params.insert(ParametersPair(Parameters::kIcpOutlierRatio(), uNumber2Str(outlierRatio)));
|
||||
registrationPipeline_->parseParameters(params);
|
||||
}
|
||||
|
||||
@@ -240,15 +240,19 @@ Transform OdometryF2F::computeTransform(
|
||||
{
|
||||
UDEBUG("Update key frame");
|
||||
int features = newFrame.getWordsDescriptors().rows;
|
||||
if(registrationPipeline_->isImageRequired() && features == 0)
|
||||
if(!refFrame_.sensorData().isValid())
|
||||
{
|
||||
newFrame = Signature(data);
|
||||
// this will generate features only for the first frame or if optical flow was used (no 3d words)
|
||||
// For scan, we want to use reading filters, so set dummy's scan and set back to reference afterwards
|
||||
Signature dummy;
|
||||
dummy.sensorData().setLaserScan(newFrame.sensorData().laserScanRaw());
|
||||
newFrame.sensorData().setLaserScan(LaserScan());
|
||||
registrationPipeline_->computeTransformationMod(
|
||||
newFrame,
|
||||
dummy);
|
||||
features = (int)newFrame.sensorData().keypoints().size();
|
||||
newFrame.sensorData().setLaserScan(dummy.sensorData().laserScanRaw(), true);
|
||||
}
|
||||
|
||||
if((features >= registrationPipeline_->getMinVisualCorrespondences()) &&
|
||||
@@ -295,6 +299,7 @@ Transform OdometryF2F::computeTransform(
|
||||
}
|
||||
|
||||
data.setFeatures(newFrame.sensorData().keypoints(), newFrame.sensorData().keypoints3D(), newFrame.sensorData().descriptors());
|
||||
data.setLaserScan(newFrame.sensorData().laserScanRaw());
|
||||
|
||||
if(info)
|
||||
{
|
||||
|
||||
@@ -268,7 +268,7 @@ Transform OdometryF2M::computeTransform(
|
||||
bundleModels.clear();
|
||||
|
||||
float maxCorrespondenceDistance = 0.0f;
|
||||
float pmOutlierRatio = 0.0f;
|
||||
float outlierRatio = 0.0f;
|
||||
if(guess.isNull() &&
|
||||
!regPipeline_->isImageRequired() &&
|
||||
regPipeline_->isScanRequired() &&
|
||||
@@ -276,12 +276,12 @@ Transform OdometryF2M::computeTransform(
|
||||
{
|
||||
// only on initialization (first frame to register), increase icp max correspondences in case the robot is already moving
|
||||
maxCorrespondenceDistance = Parameters::defaultIcpMaxCorrespondenceDistance();
|
||||
pmOutlierRatio = Parameters::defaultIcpPMOutlierRatio();
|
||||
outlierRatio = Parameters::defaultIcpOutlierRatio();
|
||||
Parameters::parse(parameters_, Parameters::kIcpMaxCorrespondenceDistance(), maxCorrespondenceDistance);
|
||||
Parameters::parse(parameters_, Parameters::kIcpPMOutlierRatio(), pmOutlierRatio);
|
||||
Parameters::parse(parameters_, Parameters::kIcpOutlierRatio(), outlierRatio);
|
||||
ParametersMap params;
|
||||
params.insert(ParametersPair(Parameters::kIcpMaxCorrespondenceDistance(), uNumber2Str(maxCorrespondenceDistance*3.0f)));
|
||||
params.insert(ParametersPair(Parameters::kIcpPMOutlierRatio(), uNumber2Str(0.95f)));
|
||||
params.insert(ParametersPair(Parameters::kIcpOutlierRatio(), uNumber2Str(0.95f)));
|
||||
regPipeline_->parseParameters(params);
|
||||
}
|
||||
|
||||
@@ -302,11 +302,12 @@ Transform OdometryF2M::computeTransform(
|
||||
// set it back
|
||||
ParametersMap params;
|
||||
params.insert(ParametersPair(Parameters::kIcpMaxCorrespondenceDistance(), uNumber2Str(maxCorrespondenceDistance)));
|
||||
params.insert(ParametersPair(Parameters::kIcpPMOutlierRatio(), uNumber2Str(pmOutlierRatio)));
|
||||
params.insert(ParametersPair(Parameters::kIcpOutlierRatio(), uNumber2Str(outlierRatio)));
|
||||
regPipeline_->parseParameters(params);
|
||||
}
|
||||
|
||||
data.setFeatures(lastFrame_->sensorData().keypoints(), lastFrame_->sensorData().keypoints3D(), lastFrame_->sensorData().descriptors());
|
||||
data.setLaserScan(lastFrame_->sensorData().laserScanRaw());
|
||||
|
||||
UDEBUG("Registration time = %fs", regInfo.totalTime);
|
||||
if(!transform.isNull())
|
||||
@@ -950,7 +951,7 @@ Transform OdometryF2M::computeTransform(
|
||||
}
|
||||
else
|
||||
{
|
||||
newPoints = mapCloudNormals->size();
|
||||
newPoints = frameCloudNormals->size();
|
||||
}
|
||||
|
||||
if(newPoints)
|
||||
@@ -1124,16 +1125,18 @@ Transform OdometryF2M::computeTransform(
|
||||
}
|
||||
else
|
||||
{
|
||||
// just generate keypoints for the new signature
|
||||
if(regPipeline_->isImageRequired())
|
||||
{
|
||||
Signature dummy;
|
||||
regPipeline_->computeTransformationMod(
|
||||
*lastFrame_,
|
||||
dummy);
|
||||
}
|
||||
// Just generate keypoints for the new signature
|
||||
// For scan, we want to use reading filters, so set dummy's scan and set back to reference afterwards
|
||||
Signature dummy;
|
||||
dummy.sensorData().setLaserScan(lastFrame_->sensorData().laserScanRaw());
|
||||
lastFrame_->sensorData().setLaserScan(LaserScan());
|
||||
regPipeline_->computeTransformationMod(
|
||||
*lastFrame_,
|
||||
dummy);
|
||||
lastFrame_->sensorData().setLaserScan(dummy.sensorData().laserScanRaw());
|
||||
|
||||
data.setFeatures(lastFrame_->sensorData().keypoints(), lastFrame_->sensorData().keypoints3D(), lastFrame_->sensorData().descriptors());
|
||||
data.setLaserScan(lastFrame_->sensorData().laserScanRaw());
|
||||
|
||||
// a very high variance tells that the new pose is not linked with the previous one
|
||||
regInfo.covariance = cv::Mat::eye(6,6,CV_64FC1)*9999.0;
|
||||
|
||||
Reference in New Issue
Block a user