2 GTSAM Copyright 2010-2018, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 5 Authors: Frank Dellaert, et al. (see THANKS for the full author list) 7 See LICENSE for the license information 9 Simple robotics example using odometry measurements and bearing-range (laser) measurements 10 Author: Alex Cunningham (C++), Kevin Deng & Frank Dellaert (Python) 14 from __future__
import print_function
37 graph.add(gtsam.PriorFactorPose2(X1,
gtsam.Pose2(0.0, 0.0, 0.0), PRIOR_NOISE))
40 graph.add(gtsam.BetweenFactorPose2(
41 X1, X2,
gtsam.Pose2(2.0, 0.0, 0.0), ODOMETRY_NOISE))
42 graph.add(gtsam.BetweenFactorPose2(
43 X2, X3,
gtsam.Pose2(2.0, 0.0, 0.0), ODOMETRY_NOISE))
46 graph.add(gtsam.BearingRangeFactor2D(
48 graph.add(gtsam.BearingRangeFactor2D(
50 graph.add(gtsam.BearingRangeFactor2D(
54 print(
"Factor Graph:\n{}".format(graph))
58 initial_estimate.insert(X1,
gtsam.Pose2(-0.25, 0.20, 0.15))
59 initial_estimate.insert(X2,
gtsam.Pose2(2.30, 0.10, -0.20))
60 initial_estimate.insert(X3,
gtsam.Pose2(4.10, 0.10, 0.10))
65 print(
"Initial Estimate:\n{}".format(initial_estimate))
75 result = optimizer.optimize()
76 print(
"\nFinal Result:\n{}".format(result))
80 for (key, str)
in [(X1,
"X1"), (X2,
"X2"), (X3,
"X3"), (L1,
"L1"), (L2,
"L2")]:
81 print(
"{} covariance:\n{}\n".format(str, marginals.marginalCovariance(key)))
void print(const Matrix &A, const string &s, ostream &stream)
static Rot2 fromDegrees(double theta)
Named constructor from angle in degrees.
static shared_ptr Sigmas(const Vector &sigmas, bool smart=true)