METISOrderingExample.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>
29 #include <gtsam/nonlinear/Values.h>
31 
32 using namespace std;
33 using namespace gtsam;
34 
35 int main(int argc, char** argv) {
37 
38  Pose2 priorMean(0.0, 0.0, 0.0); // prior at origin
39  auto priorNoise = noiseModel::Diagonal::Sigmas(Vector3(0.3, 0.3, 0.1));
40  graph.addPrior(1, priorMean, priorNoise);
41 
42  Pose2 odometry(2.0, 0.0, 0.0);
43  auto odometryNoise = noiseModel::Diagonal::Sigmas(Vector3(0.2, 0.2, 0.1));
46  graph.print("\nFactor Graph:\n"); // print
47 
49  initial.insert(1, Pose2(0.5, 0.0, 0.2));
50  initial.insert(2, Pose2(2.3, 0.1, -0.2));
51  initial.insert(3, Pose2(4.1, 0.1, 0.1));
52  initial.print("\nInitial Estimate:\n"); // print
53 
54  // optimize using Levenberg-Marquardt optimization
56  // In order to specify the ordering type, we need to se the "orderingType". By
57  // default this parameter is set to OrderingType::COLAMD
58  params.orderingType = Ordering::METIS;
59  LevenbergMarquardtOptimizer optimizer(graph, initial, params);
60  Values result = optimizer.optimize();
61  result.print("Final Result:\n");
62 
63  return 0;
64 }
virtual const Values & optimize()
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition: FactorGraph.h:196
Eigen::Vector3d Vector3
Definition: Vector.h:43
A non-templated config holding any types of Manifold-group elements.
Factor Graph consisting of non-linear factors.
Values initial
Definition: BFloat16.h:88
NonlinearFactorGraph graph
static const SmartProjectionParams params
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
void print(const std::string &str="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Definition: Values.cpp:66
Values result
auto odometryNoise
Pose2 priorMean(0.0, 0.0, 0.0)
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
int main(int argc, char **argv)
traits
Definition: chartTesting.h:28
auto priorNoise
void print(const std::string &str="NonlinearFactorGraph: ", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
void insert(Key j, const Value &val)
Definition: Values.cpp:155
A class for computing marginals in a NonlinearFactorGraph.
Pose2 odometry(2.0, 0.0, 0.0)
2D Pose
Ordering::OrderingType orderingType
The method of ordering use during variable elimination (default COLAMD)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:55