mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-01 17:10:26 +08:00
Refactoring: Split Odometry classes in multiple headers. Added Odometry::create(type) for convenience, working with "Odom/Strategy" parameter. Renamed OdometryBOW to OdometryLocalMap (more descriptive name).
This commit is contained in:
@@ -33,22 +33,25 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <rtabmap/core/Transform.h>
|
||||
#include <rtabmap/core/SensorData.h>
|
||||
#include <rtabmap/core/Parameters.h>
|
||||
#include <rtabmap/core/Signature.h>
|
||||
#include <rtabmap/core/RegistrationVis.h>
|
||||
#include <pcl/point_types.h>
|
||||
#include <pcl/point_cloud.h>
|
||||
|
||||
class UTimer;
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class Feature2D;
|
||||
class OdometryInfo;
|
||||
class ParticleFilter;
|
||||
class Stereo;
|
||||
|
||||
class RTABMAP_EXP Odometry
|
||||
{
|
||||
public:
|
||||
enum Type {
|
||||
kTypeUndef = -1,
|
||||
kTypeLocalMap = 0,
|
||||
kTypeF2F = 1
|
||||
};
|
||||
|
||||
public:
|
||||
static Odometry * create(const ParametersMap & parameters);
|
||||
static Odometry * create(Type & type, const ParametersMap & parameters);
|
||||
|
||||
public:
|
||||
virtual ~Odometry();
|
||||
Transform process(const SensorData & data, OdometryInfo * info = 0);
|
||||
@@ -116,116 +119,5 @@ protected:
|
||||
Odometry(const rtabmap::ParametersMap & parameters);
|
||||
};
|
||||
|
||||
class Memory;
|
||||
|
||||
class RTABMAP_EXP OdometryBOW : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryBOW(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryBOW();
|
||||
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
const std::map<int, cv::Point3f> & getLocalMap() const {return localMap_;}
|
||||
const Memory * getMemory() const {return _memory;}
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
//Parameters
|
||||
int _localHistoryMaxSize;
|
||||
std::string _fixedLocalMapPath;
|
||||
|
||||
Memory * _memory;
|
||||
std::map<int, cv::Point3f> localMap_;
|
||||
};
|
||||
|
||||
class RTABMAP_EXP OdometryF2F : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryF2F(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryF2F();
|
||||
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
|
||||
const Signature & getRefFrame() const {return refFrame_;}
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
//Parameters:
|
||||
int keyFrameThr_;
|
||||
bool guessFromMotion_;
|
||||
|
||||
RegistrationVis registration_;
|
||||
Signature refFrame_;
|
||||
Transform motionSinceLastKeyFrame_;
|
||||
};
|
||||
|
||||
|
||||
class RTABMAP_EXP OdometryMono : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryMono(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryMono();
|
||||
virtual void reset(const Transform & initialPose);
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & data, OdometryInfo * info = 0);
|
||||
private:
|
||||
//Parameters:
|
||||
int flowWinSize_;
|
||||
int flowIterations_;
|
||||
double flowEps_;
|
||||
int flowMaxLevel_;
|
||||
|
||||
Stereo * stereo_;
|
||||
|
||||
Memory * memory_;
|
||||
int localHistoryMaxSize_;
|
||||
float initMinFlow_;
|
||||
float initMinTranslation_;
|
||||
float minTranslation_;
|
||||
float fundMatrixReprojError_;
|
||||
float fundMatrixConfidence_;
|
||||
|
||||
cv::Mat refDepthOrRight_;
|
||||
std::map<int, cv::Point2f> cornersMap_;
|
||||
std::map<int, cv::Point3f> localMap_;
|
||||
std::map<int, std::map<int, cv::Point3f> > keyFrameWords3D_;
|
||||
std::map<int, Transform> keyFramePoses_;
|
||||
float maxVariance_;
|
||||
};
|
||||
|
||||
class RTABMAP_EXP OdometryICP : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryICP(int decimation = 4,
|
||||
float voxelSize = 0.005f,
|
||||
int samples = 0,
|
||||
float maxCorrespondenceDistance = 0.05f,
|
||||
int maxIterations = 30,
|
||||
float correspondenceRatio = 0.7f,
|
||||
bool pointToPlane = true,
|
||||
const ParametersMap & odometryParameter = rtabmap::ParametersMap());
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
int _decimation;
|
||||
float _voxelSize;
|
||||
float _samples;
|
||||
float _maxCorrespondenceDistance;
|
||||
int _maxIterations;
|
||||
float _correspondenceRatio;
|
||||
bool _pointToPlane;
|
||||
|
||||
pcl::PointCloud<pcl::PointNormal>::Ptr _previousCloudNormal; // for point ot plane
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr _previousCloud; // for point to point
|
||||
};
|
||||
|
||||
} /* namespace rtabmap */
|
||||
#endif /* ODOMETRY_H_ */
|
||||
|
||||
61
corelib/include/rtabmap/core/OdometryF2F.h
Normal file
61
corelib/include/rtabmap/core/OdometryF2F.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (c) 2010-2014, 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 ODOMETRYF2F_H_
|
||||
#define ODOMETRYF2F_H_
|
||||
|
||||
#include <rtabmap/core/Odometry.h>
|
||||
#include <rtabmap/core/RegistrationVis.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class RTABMAP_EXP OdometryF2F : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryF2F(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryF2F();
|
||||
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
|
||||
const Signature & getRefFrame() const {return refFrame_;}
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
//Parameters:
|
||||
int keyFrameThr_;
|
||||
bool guessFromMotion_;
|
||||
|
||||
RegistrationVis registration_;
|
||||
Signature refFrame_;
|
||||
Transform motionSinceLastKeyFrame_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ODOMETRYF2F_H_ */
|
||||
68
corelib/include/rtabmap/core/OdometryICP.h
Normal file
68
corelib/include/rtabmap/core/OdometryICP.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright (c) 2010-2014, 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 ODOMETRYICP_H_
|
||||
#define ODOMETRYICP_H_
|
||||
|
||||
#include <rtabmap/core/Odometry.h>
|
||||
#include <pcl/point_cloud.h>
|
||||
#include <pcl/point_types.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class RTABMAP_EXP OdometryICP : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryICP(int decimation = 4,
|
||||
float voxelSize = 0.005f,
|
||||
int samples = 0,
|
||||
float maxCorrespondenceDistance = 0.05f,
|
||||
int maxIterations = 30,
|
||||
float correspondenceRatio = 0.7f,
|
||||
bool pointToPlane = true,
|
||||
const ParametersMap & odometryParameter = rtabmap::ParametersMap());
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
int _decimation;
|
||||
float _voxelSize;
|
||||
float _samples;
|
||||
float _maxCorrespondenceDistance;
|
||||
int _maxIterations;
|
||||
float _correspondenceRatio;
|
||||
bool _pointToPlane;
|
||||
|
||||
pcl::PointCloud<pcl::PointNormal>::Ptr _previousCloudNormal; // for point ot plane
|
||||
pcl::PointCloud<pcl::PointXYZ>::Ptr _previousCloud; // for point to point
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ODOMETRYICP_H_ */
|
||||
61
corelib/include/rtabmap/core/OdometryLocalMap.h
Normal file
61
corelib/include/rtabmap/core/OdometryLocalMap.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (c) 2010-2014, 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 ODOMETRYLOCALMAP_H_
|
||||
#define ODOMETRYLOCALMAP_H_
|
||||
|
||||
#include <rtabmap/core/Odometry.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class Memory;
|
||||
|
||||
class RTABMAP_EXP OdometryLocalMap : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryLocalMap(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryLocalMap();
|
||||
|
||||
virtual void reset(const Transform & initialPose = Transform::getIdentity());
|
||||
const std::map<int, cv::Point3f> & getLocalMap() const {return localMap_;}
|
||||
const Memory * getMemory() const {return _memory;}
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & image, OdometryInfo * info = 0);
|
||||
|
||||
private:
|
||||
//Parameters
|
||||
int _localHistoryMaxSize;
|
||||
std::string _fixedLocalMapPath;
|
||||
|
||||
Memory * _memory;
|
||||
std::map<int, cv::Point3f> localMap_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ODOMETRYLOCALMAP_H_ */
|
||||
74
corelib/include/rtabmap/core/OdometryMono.h
Normal file
74
corelib/include/rtabmap/core/OdometryMono.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Copyright (c) 2010-2014, 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 ODOMETRYMONO_H_
|
||||
#define ODOMETRYMONO_H_
|
||||
|
||||
#include <rtabmap/core/Odometry.h>
|
||||
|
||||
namespace rtabmap {
|
||||
|
||||
class Memory;
|
||||
class Stereo;
|
||||
|
||||
class RTABMAP_EXP OdometryMono : public Odometry
|
||||
{
|
||||
public:
|
||||
OdometryMono(const rtabmap::ParametersMap & parameters = rtabmap::ParametersMap());
|
||||
virtual ~OdometryMono();
|
||||
virtual void reset(const Transform & initialPose);
|
||||
|
||||
private:
|
||||
virtual Transform computeTransform(const SensorData & data, OdometryInfo * info = 0);
|
||||
private:
|
||||
//Parameters:
|
||||
int flowWinSize_;
|
||||
int flowIterations_;
|
||||
double flowEps_;
|
||||
int flowMaxLevel_;
|
||||
|
||||
Stereo * stereo_;
|
||||
|
||||
Memory * memory_;
|
||||
int localHistoryMaxSize_;
|
||||
float initMinFlow_;
|
||||
float initMinTranslation_;
|
||||
float minTranslation_;
|
||||
float fundMatrixReprojError_;
|
||||
float fundMatrixConfidence_;
|
||||
|
||||
cv::Mat refDepthOrRight_;
|
||||
std::map<int, cv::Point2f> cornersMap_;
|
||||
std::map<int, cv::Point3f> localMap_;
|
||||
std::map<int, std::map<int, cv::Point3f> > keyFrameWords3D_;
|
||||
std::map<int, Transform> keyFramePoses_;
|
||||
float maxVariance_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* ODOMETRYMONO_H_ */
|
||||
@@ -331,7 +331,7 @@ class RTABMAP_EXP Parameters
|
||||
RTABMAP_PARAM(Optimizer, Robust, bool, true, "Robust graph optimization using Vertigo (only work for g2o and GTSAM optimization strategies).");
|
||||
|
||||
// Odometry
|
||||
RTABMAP_PARAM(Odom, Strategy, int, 0, "0=Features Map 1=Frame-to-Frame");
|
||||
RTABMAP_PARAM(Odom, Strategy, int, 0, "0=Local Map 1=Frame-to-Frame");
|
||||
RTABMAP_PARAM(Odom, ResetCountdown, int, 0, "Automatically reset odometry after X consecutive images on which odometry cannot be computed (value=0 disables auto-reset).");
|
||||
RTABMAP_PARAM(Odom, Holonomic, bool, true, "If the robot is holonomic (strafing commands can be issued). If not, y value will be estimated from x and yaw values (y=x*tan(yaw)).");
|
||||
RTABMAP_PARAM(Odom, FillInfoData, bool, true, "Fill info with data (inliers/outliers features).");
|
||||
|
||||
Reference in New Issue
Block a user