GNCExample.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
25 #include <gtsam/geometry/Pose2.h>
32 
33 #include <iostream>
34 
35 using namespace std;
36 using namespace gtsam;
37 
38 int main() {
39  cout << "Graduated Non-Convexity Example\n";
40 
42 
43  // Add a prior to the first point, set to the origin
44  auto priorNoise = noiseModel::Isotropic::Sigma(3, 0.1);
45  graph.addPrior(1, Pose2(0.0, 0.0, 0.0), priorNoise);
46 
47  // Add additional factors, noise models must be Gaussian
48  Pose2 x1(1.0, 0.0, 0.1);
49  graph.emplace_shared<BetweenFactor<Pose2>>(1, 2, x1, noiseModel::Isotropic::Sigma(3, 0.2));
50  Pose2 x2(0.0, 1.0, 0.1);
51  graph.emplace_shared<BetweenFactor<Pose2>>(2, 3, x2, noiseModel::Isotropic::Sigma(3, 0.4));
52 
53  // Initial estimates
55  initial.insert(1, Pose2(0.2, 0.5, -0.1));
56  initial.insert(2, Pose2(0.8, 0.3, 0.1));
57  initial.insert(3, Pose2(0.8, 0.2, 0.3));
58 
59  // Set options for the non-minimal solver
63 
64  // Set GNC-specific options
66  gncParams.setLossType(GncLossType::TLS);
67 
68  // Optimize the graph and print results
70  Values result = optimizer.optimize();
71  result.print("Final Result:");
72 
73  return 0;
74 }
75 
Pose2.h
2D Pose
gtsam::TLS
@ TLS
Definition: GncParams.h:38
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
LevenbergMarquardtOptimizer.h
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
initial
Values initial
Definition: OdometryOptimize.cpp:2
gtsam::GncOptimizer
Definition: GncOptimizer.h:44
gtsam::GncParams::setLossType
void setLossType(const GncLossType type)
Set the robust loss function to be used in GNC (chosen among the ones in GncLossType).
Definition: GncParams.h:84
lmParams
LevenbergMarquardtParams lmParams
Definition: testSmartProjectionRigFactor.cpp:55
gtsam::NonlinearOptimizerParams::setRelativeErrorTol
void setRelativeErrorTol(double value)
Definition: NonlinearOptimizerParams.h:56
LevenbergMarquardtParams.h
Parameters for Levenberg-Marquardt trust-region scheme.
result
Values result
Definition: OdometryOptimize.cpp:8
gtsam::GncParams
Definition: GncParams.h:42
BetweenFactor.h
x1
Pose3 x1
Definition: testPose3.cpp:663
GncParams.h
gtsam::NonlinearFactorGraph
Definition: NonlinearFactorGraph.h:55
gtsam::NonlinearFactorGraph::addPrior
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
Definition: NonlinearFactorGraph.h:199
main
int main()
Definition: GNCExample.cpp:38
priorNoise
auto priorNoise
Definition: doc/Code/OdometryExample.cpp:6
gtsam::Values::print
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Definition: Values.cpp:66
gtsam
traits
Definition: SFMdata.h:40
NonlinearFactorGraph.h
Factor Graph consisting of non-linear factors.
gtsam::Values
Definition: Values.h:65
std
Definition: BFloat16.h:88
gtsam::GncOptimizer::optimize
Values optimize()
Compute optimal solution using graduated non-convexity.
Definition: GncOptimizer.h:183
GncOptimizer.h
The GncOptimizer class.
gtsam::LevenbergMarquardtParams
Definition: LevenbergMarquardtParams.h:35
initial
Definition: testScenarioRunner.cpp:148
gtsam::NonlinearOptimizerParams::setMaxIterations
void setMaxIterations(int value)
Definition: NonlinearOptimizerParams.h:55
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
x2
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
gtsam::FactorGraph::emplace_shared
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition: FactorGraph.h:153
gtsam::Pose2
Definition: Pose2.h:39
gtsam::BetweenFactor
Definition: BetweenFactor.h:40


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:23