mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Added LOAM (loam_velodyne) odometry support
This commit is contained in:
@@ -155,6 +155,7 @@ option(WITH_TORO "Include TORO support" ON)
|
||||
option(WITH_VERTIGO "Include Vertigo support" ON)
|
||||
option(WITH_CVSBA "Include cvsba support" ON)
|
||||
option(WITH_POINTMATCHER "Include libpointmatcher support" ON)
|
||||
option(WITH_LOAM "Include LOAM support" ON)
|
||||
option(WITH_FLYCAPTURE2 "Include FlyCapture2/Triclops support" ON)
|
||||
option(WITH_ZED "Include ZED sdk support" ON)
|
||||
option(WITH_REALSENSE "Include RealSense support" ON)
|
||||
@@ -329,6 +330,13 @@ IF(WITH_POINTMATCHER)
|
||||
ENDIF(libpointmatcher_FOUND)
|
||||
ENDIF(WITH_POINTMATCHER)
|
||||
|
||||
IF(WITH_LOAM)
|
||||
find_package(loam_velodyne QUIET)
|
||||
IF(loam_velodyne_FOUND)
|
||||
MESSAGE(STATUS "Found loam_velodyne: ${loam_velodyne_INCLUDE_DIRS}")
|
||||
ENDIF(loam_velodyne_FOUND)
|
||||
ENDIF(WITH_LOAM)
|
||||
|
||||
SET(ZED_FOUND FALSE)
|
||||
IF(WITH_ZED)
|
||||
IF(WIN32) # Windows
|
||||
@@ -454,7 +462,18 @@ IF(WITH_ORB_SLAM2 AND NOT G2O_FOUND)
|
||||
ENDIF(ORB_SLAM2_FOUND)
|
||||
ENDIF(WITH_ORB_SLAM2 AND NOT G2O_FOUND)
|
||||
|
||||
IF(G2O_FOUND OR GTSAM_FOUND OR ZED_FOUND OR ANDROID OR RealSense_FOUND OR realsense2_FOUND OR ORB_SLAM2_FOUND OR okvis_FOUND OR open_chisel_FOUND)
|
||||
IF(loam_velodyne_FOUND)
|
||||
#LOAM requires c++14
|
||||
IF(NOT MSVC)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
|
||||
IF(COMPILER_SUPPORTS_CXX14)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
ELSE()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler if you want to use LOAM (set \"-DWITH_LOAM=OFF\" to build without LOAM).")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ELSEIF(G2O_FOUND OR GTSAM_FOUND OR ZED_FOUND OR ANDROID OR RealSense_FOUND OR realsense2_FOUND OR ORB_SLAM2_FOUND OR okvis_FOUND OR open_chisel_FOUND)
|
||||
#Newest versions require std11
|
||||
IF(NOT MSVC)
|
||||
include(CheckCXXCompilerFlag)
|
||||
@@ -534,6 +553,9 @@ ENDIF()
|
||||
IF(NOT libpointmatcher_FOUND)
|
||||
SET(POINTMATCHER "//")
|
||||
ENDIF(NOT libpointmatcher_FOUND)
|
||||
IF(NOT loam_velodyne_FOUND)
|
||||
SET(LOAM "//")
|
||||
ENDIF(NOT loam_velodyne_FOUND)
|
||||
IF(NOT Freenect_FOUND)
|
||||
SET(FREENECT "//")
|
||||
ELSE()
|
||||
@@ -927,6 +949,14 @@ ELSE()
|
||||
MESSAGE(STATUS " With libpointmatcher = NO (libpointmatcher not found)")
|
||||
ENDIF()
|
||||
|
||||
IF(loam_velodyne_FOUND)
|
||||
MESSAGE(STATUS " With loam_velodyne = YES (License: BSD)")
|
||||
ELSEIF(NOT WITH_POINTMATCHER)
|
||||
MESSAGE(STATUS " With loam_velodyne = NO (WITH_LOAM=OFF)")
|
||||
ELSE()
|
||||
MESSAGE(STATUS " With loam_velodyne = NO (loam_velodyne not found)")
|
||||
ENDIF()
|
||||
|
||||
IF(ZED_FOUND)
|
||||
IF(CUDA_FOUND)
|
||||
MESSAGE(STATUS " With ZED = YES (With CUDA)")
|
||||
|
||||
@@ -50,6 +50,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@K4W2@#define RTABMAP_K4W2
|
||||
@CVSBA@#define RTABMAP_CVSBA
|
||||
@POINTMATCHER@#define RTABMAP_POINTMATCHER
|
||||
@LOAM@#define RTABMAP_LOAM
|
||||
@DC1394@#define RTABMAP_DC1394
|
||||
@FLYCAPTURE2@#define RTABMAP_FLYCAPTURE2
|
||||
@ZED@#define RTABMAP_ZED
|
||||
|
||||
@@ -50,7 +50,8 @@ public:
|
||||
kTypeViso2 = 3,
|
||||
kTypeDVO = 4,
|
||||
kTypeORBSLAM2 = 5,
|
||||
kTypeOkvis = 6
|
||||
kTypeOkvis = 6,
|
||||
kTypeLOAM = 7
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
74
corelib/include/rtabmap/core/OdometryLOAM.h
Normal file
74
corelib/include/rtabmap/core/OdometryLOAM.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2010-2016, 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 ODOMETRYLOAM_H_
|
||||
#define ODOMETRYLOAM_H_
|
||||
|
||||
#include <rtabmap/core/Odometry.h>
|
||||
|
||||
#ifdef RTABMAP_LOAM
|
||||
#include <loam_velodyne/BasicScanRegistration.h>
|
||||
#include <loam_velodyne/BasicLaserOdometry.h>
|
||||
#include <loam_velodyne/BasicLaserMapping.h>
|
||||
#include <loam_velodyne/BasicTransformMaintenance.h>
|
||||
#include <loam_velodyne/MultiScanRegistration.h>
|
||||
#endif
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class RTABMAP_EXP OdometryLOAM : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryLOAM(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryLOAM();
|
||||
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
virtual Odometry::Type getType() {return Odometry::kTypeLOAM;}
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(SensorData & image, const Transform & guess = Transform(), OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
#ifdef RTABMAP_LOAM
|
||||
std::vector<pcl::PointCloud<pcl::PointXYZI> > segmentScanRings(const pcl::PointCloud<pcl::PointXYZ> & laserCloudIn);
|
||||
|
||||
loam::BasicScanRegistration scanRegistration_;
|
||||
loam::MultiScanMapper scanMapper_;
|
||||
loam::BasicLaserOdometry * laserOdometry_;
|
||||
loam::BasicLaserMapping * laserMapping_;
|
||||
loam::BasicTransformMaintenance transformMaintenance_;
|
||||
Transform lastPose_;
|
||||
float scanPeriod_;
|
||||
float linVar_;
|
||||
float angVar_;
|
||||
bool lost_;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ODOMETRYLOAM_H_ */
|
||||
@@ -492,6 +492,12 @@ class RTABMAP_EXP Parameters
|
||||
// Odometry OKVIS
|
||||
RTABMAP_PARAM_STR(OdomOKVIS, ConfigPath, "", "Path of OKVIS config file.");
|
||||
|
||||
// Odometry LOAM
|
||||
RTABMAP_PARAM(OdomLOAM, Sensor, int, 2, "Velodyne sensor: 0=VLP-16, 1=HDL-32, 2=HDL-64E");
|
||||
RTABMAP_PARAM(OdomLOAM, ScanPeriod, float, 0.1, "Scan period (s)");
|
||||
RTABMAP_PARAM(OdomLOAM, LinVar, float, 0.01, "Linear output variance.");
|
||||
RTABMAP_PARAM(OdomLOAM, AngVar, float, 0.01, "Angular output variance.");
|
||||
|
||||
// Common registration parameters
|
||||
RTABMAP_PARAM(Reg, RepeatOnce, bool, true, "Do a second registration with the output of the first registration as guess. Only done if no guess was provided for the first registration (like on loop closure). It can be useful if the registration approach used can use a guess to get better matches.");
|
||||
RTABMAP_PARAM(Reg, Strategy, int, 0, "0=Vis, 1=Icp, 2=VisIcp");
|
||||
|
||||
@@ -68,6 +68,7 @@ SET(SRC_FILES
|
||||
OdometryDVO.cpp
|
||||
OdometryOkvis.cpp
|
||||
OdometryORBSLAM2.cpp
|
||||
OdometryLOAM.cpp
|
||||
|
||||
IMUThread.cpp
|
||||
|
||||
@@ -274,6 +275,17 @@ IF(libpointmatcher_FOUND)
|
||||
)
|
||||
ENDIF(libpointmatcher_FOUND)
|
||||
|
||||
IF(loam_velodyne_FOUND)
|
||||
SET(INCLUDE_DIRS
|
||||
${INCLUDE_DIRS}
|
||||
${loam_velodyne_INCLUDE_DIRS}
|
||||
)
|
||||
SET(LIBRARIES
|
||||
${LIBRARIES}
|
||||
${loam_velodyne_LIBRARIES}
|
||||
)
|
||||
ENDIF(loam_velodyne_FOUND)
|
||||
|
||||
IF(ZED_FOUND)
|
||||
SET(INCLUDE_DIRS
|
||||
${INCLUDE_DIRS}
|
||||
|
||||
@@ -33,6 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "rtabmap/core/OdometryDVO.h"
|
||||
#include "rtabmap/core/OdometryOkvis.h"
|
||||
#include "rtabmap/core/OdometryORBSLAM2.h"
|
||||
#include "rtabmap/core/OdometryLOAM.h"
|
||||
#include "rtabmap/core/OdometryInfo.h"
|
||||
#include "rtabmap/core/util3d.h"
|
||||
#include "rtabmap/core/util3d_mapping.h"
|
||||
@@ -80,6 +81,9 @@ Odometry * Odometry::create(Odometry::Type & type, const ParametersMap & paramet
|
||||
case Odometry::kTypeOkvis:
|
||||
odometry = new OdometryOkvis(parameters);
|
||||
break;
|
||||
case Odometry::kTypeLOAM:
|
||||
odometry = new OdometryLOAM(parameters);
|
||||
break;
|
||||
default:
|
||||
odometry = new OdometryF2M(parameters);
|
||||
type = Odometry::kTypeF2M;
|
||||
|
||||
299
corelib/src/OdometryLOAM.cpp
Normal file
299
corelib/src/OdometryLOAM.cpp
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
Copyright (c) 2010-2016, 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.
|
||||
*/
|
||||
|
||||
#include "rtabmap/core/OdometryLOAM.h"
|
||||
#include "rtabmap/core/OdometryInfo.h"
|
||||
#include "rtabmap/core/util2d.h"
|
||||
#include "rtabmap/utilite/ULogger.h"
|
||||
#include "rtabmap/utilite/UTimer.h"
|
||||
#include "rtabmap/utilite/UStl.h"
|
||||
#include "rtabmap/core/util3d.h"
|
||||
#include <pcl/common/transforms.h>
|
||||
|
||||
float SCAN_PERIOD = 0.1f;
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
/**
|
||||
* https://github.com/laboshinl/loam_velodyne/pull/66
|
||||
*/
|
||||
|
||||
OdometryLOAM::OdometryLOAM(const ParametersMap & parameters) :
|
||||
Odometry(parameters)
|
||||
#ifdef RTABMAP_LOAM
|
||||
,lastPose_(Transform::getIdentity())
|
||||
,scanPeriod_(Parameters::defaultOdomLOAMScanPeriod())
|
||||
,linVar_(Parameters::defaultOdomLOAMLinVar())
|
||||
,angVar_(Parameters::defaultOdomLOAMAngVar())
|
||||
,lost_(false)
|
||||
#endif
|
||||
{
|
||||
#ifdef RTABMAP_LOAM
|
||||
int velodyneType = 0;
|
||||
Parameters::parse(parameters, Parameters::kOdomLOAMSensor(), velodyneType);
|
||||
Parameters::parse(parameters, Parameters::kOdomLOAMScanPeriod(), scanPeriod_);
|
||||
UASSERT(scanPeriod_>0.0f);
|
||||
Parameters::parse(parameters, Parameters::kOdomLOAMLinVar(), linVar_);
|
||||
UASSERT(linVar_>0.0f);
|
||||
Parameters::parse(parameters, Parameters::kOdomLOAMAngVar(), angVar_);
|
||||
UASSERT(angVar_>0.0f);
|
||||
if(velodyneType == 1)
|
||||
{
|
||||
scanMapper_ = loam::MultiScanMapper::Velodyne_HDL_32();
|
||||
}
|
||||
else if(velodyneType == 2)
|
||||
{
|
||||
scanMapper_ = loam::MultiScanMapper::Velodyne_HDL_64E();
|
||||
}
|
||||
else
|
||||
{
|
||||
scanMapper_ = loam::MultiScanMapper::Velodyne_VLP_16();
|
||||
}
|
||||
laserOdometry_ = new loam::BasicLaserOdometry(scanPeriod_);
|
||||
laserMapping_ = new loam::BasicLaserMapping(scanPeriod_);
|
||||
#endif
|
||||
}
|
||||
|
||||
OdometryLOAM::~OdometryLOAM()
|
||||
{
|
||||
#ifdef RTABMAP_LOAM
|
||||
delete laserOdometry_;
|
||||
delete laserMapping_;
|
||||
#endif
|
||||
}
|
||||
|
||||
void OdometryLOAM::reset(const Transform & initialPose)
|
||||
{
|
||||
Odometry::reset(initialPose);
|
||||
#ifdef RTABMAP_LOAM
|
||||
lastPose_.setIdentity();
|
||||
scanRegistration_ = loam::BasicScanRegistration();
|
||||
loam::RegistrationParams regParams;
|
||||
regParams.scanPeriod = scanPeriod_;
|
||||
scanRegistration_.configure(regParams);
|
||||
delete laserOdometry_;
|
||||
laserOdometry_ = new loam::BasicLaserOdometry(scanPeriod_);
|
||||
delete laserMapping_;
|
||||
laserMapping_ = new loam::BasicLaserMapping(scanPeriod_);
|
||||
transformMaintenance_ = loam::BasicTransformMaintenance();
|
||||
lost_ = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef RTABMAP_LOAM
|
||||
std::vector<pcl::PointCloud<pcl::PointXYZI> > OdometryLOAM::segmentScanRings(const pcl::PointCloud<pcl::PointXYZ> & laserCloudIn)
|
||||
{
|
||||
std::vector<pcl::PointCloud<pcl::PointXYZI> > laserCloudScans;
|
||||
|
||||
size_t cloudSize = laserCloudIn.size();
|
||||
|
||||
// determine scan start and end orientations
|
||||
float startOri = -std::atan2(laserCloudIn[0].y, laserCloudIn[0].x);
|
||||
float endOri = -std::atan2(laserCloudIn[cloudSize - 1].y,
|
||||
laserCloudIn[cloudSize - 1].x) + 2 * float(M_PI);
|
||||
if (endOri - startOri > 3 * M_PI) {
|
||||
endOri -= 2 * M_PI;
|
||||
} else if (endOri - startOri < M_PI) {
|
||||
endOri += 2 * M_PI;
|
||||
}
|
||||
|
||||
bool halfPassed = false;
|
||||
pcl::PointXYZI point;
|
||||
laserCloudScans.resize(scanMapper_.getNumberOfScanRings());
|
||||
// clear all scanline points
|
||||
std::for_each(laserCloudScans.begin(), laserCloudScans.end(), [](auto&&v) {v.clear(); });
|
||||
|
||||
// extract valid points from input cloud
|
||||
for (size_t i = 0; i < cloudSize; i++) {
|
||||
point.x = laserCloudIn[i].y;
|
||||
point.y = laserCloudIn[i].z;
|
||||
point.z = laserCloudIn[i].x;
|
||||
|
||||
// skip NaN and INF valued points
|
||||
if (!pcl_isfinite(point.x) ||
|
||||
!pcl_isfinite(point.y) ||
|
||||
!pcl_isfinite(point.z)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip zero valued points
|
||||
if (point.x * point.x + point.y * point.y + point.z * point.z < 0.0001) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// calculate vertical point angle and scan ID
|
||||
float angle = std::atan(point.y / std::sqrt(point.x * point.x + point.z * point.z));
|
||||
int scanID = scanMapper_.getRingForAngle(angle);
|
||||
if (scanID >= scanMapper_.getNumberOfScanRings() || scanID < 0 ){
|
||||
continue;
|
||||
}
|
||||
|
||||
// calculate horizontal point angle
|
||||
float ori = -std::atan2(point.x, point.z);
|
||||
if (!halfPassed) {
|
||||
if (ori < startOri - M_PI / 2) {
|
||||
ori += 2 * M_PI;
|
||||
} else if (ori > startOri + M_PI * 3 / 2) {
|
||||
ori -= 2 * M_PI;
|
||||
}
|
||||
|
||||
if (ori - startOri > M_PI) {
|
||||
halfPassed = true;
|
||||
}
|
||||
} else {
|
||||
ori += 2 * M_PI;
|
||||
|
||||
if (ori < endOri - M_PI * 3 / 2) {
|
||||
ori += 2 * M_PI;
|
||||
} else if (ori > endOri + M_PI / 2) {
|
||||
ori -= 2 * M_PI;
|
||||
}
|
||||
}
|
||||
|
||||
// calculate relative scan time based on point orientation
|
||||
float relTime = SCAN_PERIOD * (ori - startOri) / (endOri - startOri);
|
||||
point.intensity = scanID + relTime;
|
||||
|
||||
// imu not used...
|
||||
//scanRegistration_.projectPointToStartOfSweep(point, relTime);
|
||||
|
||||
laserCloudScans[scanID].push_back(point);
|
||||
}
|
||||
|
||||
return laserCloudScans;
|
||||
}
|
||||
#endif
|
||||
|
||||
// return not null transform if odometry is correctly computed
|
||||
Transform OdometryLOAM::computeTransform(
|
||||
SensorData & data,
|
||||
const Transform & guess,
|
||||
OdometryInfo * info)
|
||||
{
|
||||
Transform t;
|
||||
#ifdef RTABMAP_LOAM
|
||||
UTimer timer;
|
||||
|
||||
if(data.laserScanRaw().isEmpty())
|
||||
{
|
||||
UERROR("LOAM works only with laser scans and the current input is empty. Aborting odometry update...");
|
||||
return t;
|
||||
}
|
||||
else if(data.laserScanRaw().is2d())
|
||||
{
|
||||
UERROR("LOAM version used works only with 3D laser scans from Velodyne. Aborting odometry update...");
|
||||
return t;
|
||||
}
|
||||
|
||||
cv::Mat covariance = cv::Mat::eye(6,6,CV_64FC1)*9999;
|
||||
if(!lost_)
|
||||
{
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr laserCloudInPtr = util3d::laserScanToPointCloud(data.laserScanRaw());
|
||||
std::vector<pcl::PointCloud<pcl::PointXYZI> > laserCloudScans = segmentScanRings(*laserCloudInPtr);
|
||||
|
||||
ros::Time stampT;
|
||||
stampT.fromSec(data.stamp());
|
||||
loam::Time scanTime = loam::fromROSTime(stampT);
|
||||
scanRegistration_.processScanlines(scanTime, laserCloudScans);
|
||||
|
||||
*laserOdometry_->cornerPointsSharp() = scanRegistration_.cornerPointsSharp();
|
||||
*laserOdometry_->cornerPointsLessSharp() = scanRegistration_.cornerPointsLessSharp();
|
||||
*laserOdometry_->surfPointsFlat() = scanRegistration_.surfacePointsFlat();
|
||||
*laserOdometry_->surfPointsLessFlat() = scanRegistration_.surfacePointsLessFlat();
|
||||
*laserOdometry_->laserCloud() = scanRegistration_.laserCloud();
|
||||
pcl::PointCloud<pcl::PointXYZ> imuTrans;
|
||||
imuTrans.resize(4);
|
||||
laserOdometry_->updateIMU(imuTrans);
|
||||
laserOdometry_->process();
|
||||
|
||||
laserMapping_->laserCloudCornerLast() = *laserOdometry_->lastCornerCloud();
|
||||
laserMapping_->laserCloudSurfLast() = *laserOdometry_->lastSurfaceCloud();
|
||||
laserMapping_->laserCloud() = *laserOdometry_->laserCloud();
|
||||
laserMapping_->updateOdometry(laserOdometry_->transformSum());
|
||||
laserMapping_->process(scanTime);
|
||||
|
||||
transformMaintenance_.updateOdometry(
|
||||
laserOdometry_->transformSum().rot_x.rad(),
|
||||
laserOdometry_->transformSum().rot_y.rad(),
|
||||
laserOdometry_->transformSum().rot_z.rad(),
|
||||
laserOdometry_->transformSum().pos.x(),
|
||||
laserOdometry_->transformSum().pos.y(),
|
||||
laserOdometry_->transformSum().pos.z());
|
||||
transformMaintenance_.updateMappingTransform(laserMapping_->transformAftMapped(), laserMapping_->transformBefMapped());
|
||||
transformMaintenance_.transformAssociateToMap();
|
||||
const float * tm = transformMaintenance_.transformMapped();
|
||||
Transform pose = Transform(tm[5], tm[3], tm[4], tm[2], tm[0], tm[1]);
|
||||
|
||||
if(!pose.isNull())
|
||||
{
|
||||
covariance = cv::Mat::eye(6,6,CV_64FC1);
|
||||
covariance(cv::Range(0,3), cv::Range(0,3)) *= linVar_;
|
||||
covariance(cv::Range(3,6), cv::Range(3,6)) *= angVar_;
|
||||
|
||||
t = lastPose_.inverse() * pose; // incremental
|
||||
lastPose_ = pose;
|
||||
|
||||
const Transform & localTransform = data.laserScanRaw().localTransform();
|
||||
if(!t.isNull() && !t.isIdentity() && !localTransform.isIdentity() && !localTransform.isNull())
|
||||
{
|
||||
// from laser frame to base frame
|
||||
t = localTransform * t * localTransform.inverse();
|
||||
}
|
||||
|
||||
if(info)
|
||||
{
|
||||
info->type = (int)kTypeLOAM;
|
||||
info->localScanMapSize = laserMapping_->laserCloudSurroundDS().size();
|
||||
if(covariance.cols == 6 && covariance.rows == 6 && covariance.type() == CV_64FC1)
|
||||
{
|
||||
info->reg.covariance = covariance;
|
||||
}
|
||||
|
||||
if(this->isInfoDataFilled())
|
||||
{
|
||||
Transform rot(0,0,1,0,1,0,0,0,0,1,0,0);
|
||||
pcl::PointCloud<pcl::PointXYZI> out;
|
||||
pcl::transformPointCloud(laserMapping_->laserCloudSurroundDS(), out, rot.toEigen3f());
|
||||
info->localScanMap = LaserScan::backwardCompatibility(util3d::laserScanFromPointCloud(out), 0, data.laserScanRaw().maxRange(), data.laserScanRaw().localTransform());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lost_ = true;
|
||||
UWARN("LOAM failed to register the latest scan, odometry should be reset.");
|
||||
}
|
||||
}
|
||||
UINFO("Odom update time = %fs, lost=%s", timer.elapsed(), lost_?"true":"false");
|
||||
|
||||
#else
|
||||
UERROR("RTAB-Map is not built with LOAM support! Select another odometry approach.");
|
||||
#endif
|
||||
return t;
|
||||
}
|
||||
|
||||
} // namespace rtabmap
|
||||
@@ -177,6 +177,9 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
||||
#ifndef RTABMAP_OKVIS
|
||||
_ui->odom_strategy->setItemData(6, 0, Qt::UserRole - 1);
|
||||
#endif
|
||||
#ifndef RTABMAP_LOAM
|
||||
_ui->odom_strategy->setItemData(7, 0, Qt::UserRole - 1);
|
||||
#endif
|
||||
|
||||
#ifndef RTABMAP_NONFREE
|
||||
_ui->comboBox_detector_strategy->setItemData(0, 0, Qt::UserRole - 1);
|
||||
@@ -1097,6 +1100,11 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) :
|
||||
_ui->lineEdit_OdomOkvisPath->setObjectName(Parameters::kOdomOKVISConfigPath().c_str());
|
||||
connect(_ui->toolButton_OdomOkvisPath, SIGNAL(clicked()), this, SLOT(changeOdometryOKVISConfigPath()));
|
||||
|
||||
// Odometry LOAM
|
||||
_ui->odom_loam_sensor->setObjectName(Parameters::kOdomLOAMSensor().c_str());
|
||||
_ui->odom_loam_scan_period->setObjectName(Parameters::kOdomLOAMScanPeriod().c_str());
|
||||
_ui->odom_loam_linvar->setObjectName(Parameters::kOdomLOAMLinVar().c_str());
|
||||
_ui->odom_loam_angvar->setObjectName(Parameters::kOdomLOAMAngVar().c_str());
|
||||
|
||||
//Stereo
|
||||
_ui->stereo_winWidth->setObjectName(Parameters::kStereoWinWidth().c_str());
|
||||
|
||||
@@ -94,7 +94,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-396</y>
|
||||
<y>-609</y>
|
||||
<width>681</width>
|
||||
<height>2811</height>
|
||||
</rect>
|
||||
@@ -126,7 +126,7 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>18</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_22">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_29" stretch="0,1">
|
||||
@@ -10813,6 +10813,11 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
|
||||
<string>OKVIS</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>LOAM</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@@ -11084,7 +11089,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget_odometryType">
|
||||
<property name="currentIndex">
|
||||
<number>6</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_52">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_77">
|
||||
@@ -13086,7 +13091,7 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
|
||||
<widget class="QWidget" name="page_54">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_85" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_odomORBSLAM2_2">
|
||||
<widget class="QGroupBox" name="groupBox_odomOKVIS">
|
||||
<property name="title">
|
||||
<string>OKVIS</string>
|
||||
</property>
|
||||
@@ -13152,6 +13157,180 @@ If set to false, classic RTAB-Map loop closure detection is done using only imag
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_73">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_130" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_odomLOAM">
|
||||
<property name="title">
|
||||
<string>LOAM</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_129" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_472">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>LOAM: <a href="https://github.com/laboshinl/loam_velodyne"><span style=" text-decoration: underline; color:#0000ff;">https://github.com/laboshinl/loam_velodyne</span></a></p><p>Velodyne input required. Currently tested only with KITTI data set and with pull request #66.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_101" columnstretch="0,1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_475">
|
||||
<property name="text">
|
||||
<string>Linear output variance.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_473">
|
||||
<property name="text">
|
||||
<string>Velodyne sensor.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_474">
|
||||
<property name="text">
|
||||
<string>Scan period (s).</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDoubleSpinBox" name="odom_loam_scan_period">
|
||||
<property name="minimum">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="odom_loam_sensor">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>VLP-16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HDL-32</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>HDL-64E</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_476">
|
||||
<property name="text">
|
||||
<string>Angular output variance.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDoubleSpinBox" name="odom_loam_linvar">
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000100000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.000100000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QDoubleSpinBox" name="odom_loam_angvar">
|
||||
<property name="decimals">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000100000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.000100000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_73">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>961</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_26">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_88">
|
||||
<item>
|
||||
|
||||
@@ -395,7 +395,7 @@ int main(int argc, char * argv[])
|
||||
Parameters::parse(parameters, Parameters::kRtabmapCreateIntermediateNodes(), intermediateNodes);
|
||||
|
||||
// assuming source is 10 Hz
|
||||
int mapUpdate = 10 / detectionRate;
|
||||
int mapUpdate = detectionRate>0?10 / detectionRate:1;
|
||||
if(mapUpdate < 1)
|
||||
{
|
||||
mapUpdate = 1;
|
||||
|
||||
Reference in New Issue
Block a user