RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
OptimizerGTSAM.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef OPTIMIZERGTSAM_H_
29#define OPTIMIZERGTSAM_H_
30
31#include <rtabmap/core/Optimizer.h>
32
33namespace gtsam {
34 class ISAM2;
35}
36
37namespace rtabmap {
38
39class RTABMAP_CORE_EXPORT OptimizerGTSAM : public Optimizer
40{
41public:
42 static bool available();
43
44public:
45 OptimizerGTSAM(const ParametersMap & parameters = ParametersMap());
46 virtual ~OptimizerGTSAM();
47
48 virtual Type type() const {return kTypeGTSAM;}
49
50 virtual void parseParameters(const ParametersMap & parameters);
51
52 virtual std::map<int, Transform> optimize(
53 int rootId,
54 const std::map<int, Transform> & poses,
55 const std::multimap<int, Link> & edgeConstraints,
56 cv::Mat & outputCovariance,
57 std::list<std::map<int, Transform> > * intermediateGraphes = 0,
58 double * finalError = 0,
59 int * iterationsDone = 0);
60
61 virtual std::map<int, Transform> optimizeBA(
62 int rootId,
63 const std::map<int, Transform> & poses,
64 const std::multimap<int, Link> & links,
65 const std::map<int, std::vector<CameraModel> > & models,
66 std::map<int, cv::Point3f> & points3DMap,
67 const std::map<int, std::map<int, FeatureBA> > & wordReferences,
68 BAOutliers * outliers = 0);
69
70private:
71 int internalOptimizerType_;
72 double pixelVariance_;
73 double disparityVariance_;
74 double robustKernelDelta_;
75 double baseline_;
76
77 gtsam::ISAM2 * isam2_;
78 struct ConstraintToFactor {
79 ConstraintToFactor(int _from, int _to, std::uint64_t _factorIndice)
80 {
81 from = _from;
82 to = _to;
83 factorIndice = _factorIndice;
84 }
85 int from;
86 int to;
87 std::uint64_t factorIndice;
88 };
89
90 std::vector<ConstraintToFactor> lastAddedConstraints_;
91 int lastSwitchId_;
92 std::set<int> addedPoses_;
93 std::map<int, bool> isLandmarkWithRotation_; // persists across iSAM2 incremental calls
94 std::pair<int, std::uint64_t> lastRootFactorIndex_;
95};
96
97} /* namespace rtabmap */
98#endif /* OPTIMIZERGTSAM_H_ */
virtual Type type() const
Returns the concrete back-end identifier (one of Type).
virtual std::map< int, Transform > optimize(int rootId, const std::map< int, Transform > &poses, const std::multimap< int, Link > &edgeConstraints, cv::Mat &outputCovariance, std::list< std::map< int, Transform > > *intermediateGraphes=0, double *finalError=0, int *iterationsDone=0)
Pose-graph optimization with marginal covariance of rootId.
virtual std::map< int, Transform > optimizeBA(int rootId, const std::map< int, Transform > &poses, const std::multimap< int, Link > &links, const std::map< int, std::vector< CameraModel > > &models, std::map< int, cv::Point3f > &points3DMap, const std::map< int, std::map< int, FeatureBA > > &wordReferences, BAOutliers *outliers=0)
Bundle adjustment: jointly refine poses and 3D points (back-end-level entry point).
virtual void parseParameters(const ParametersMap &parameters)
Reads shared knobs from parameters and applies them to this instance.
Abstract base for pose-graph and bundle-adjustment optimizers.
Definition Optimizer.h:91
Type
Graph-optimizer back-end identifier.
Definition Optimizer.h:94
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44