38 using namespace gtsam;
70 Rot2 bearing11 = Rot2::fromDegrees(45),
71 bearing21 = Rot2::fromDegrees(90),
72 bearing32 = Rot2::fromDegrees(90);
73 double range11 =
sqrt(4.0+4.0),
84 soln.insert(x1,
Pose2(0.0, 0.0, 0.0));
85 soln.insert(x2,
Pose2(2.0, 0.0, 0.0));
86 soln.insert(x3,
Pose2(4.0, 0.0, 0.0));
87 soln.insert(l1,
Point2(2.0, 2.0));
88 soln.insert(l2,
Point2(4.0, 2.0));
98 0.09, -7.1942452e-18, -1.27897692e-17,
99 -7.1942452e-18, 0.09, 1.27897692e-17,
100 -1.27897692e-17, 1.27897692e-17, 0.01;
103 0.120967742, -0.00129032258, 0.00451612903,
104 -0.00129032258, 0.158387097, 0.0206451613,
105 0.00451612903, 0.0206451613, 0.0177419355;
108 0.160967742, 0.00774193548, 0.00451612903,
109 0.00774193548, 0.351935484, 0.0561290323,
110 0.00451612903, 0.0561290323, 0.0277419355;
113 0.168709677, -0.0477419355,
114 -0.0477419355, 0.163548387;
117 0.293870968, -0.104516129,
118 -0.104516129, 0.391935484;
130 Matrix expected_l2x1x3(8,8);
132 0.293871159514111, -0.104516127560770, 0.090000180000270, -0.000000000000000, -0.020000000000000, 0.151935669757191, -0.104516127560770, -0.050967744878460,
133 -0.104516127560770, 0.391935664055174, 0.000000000000000, 0.090000180000270, 0.040000000000000, 0.007741936219615, 0.351935664055174, 0.056129031890193,
134 0.090000180000270, 0.000000000000000, 0.090000180000270, -0.000000000000000, 0.000000000000000, 0.090000180000270, 0.000000000000000, 0.000000000000000,
135 -0.000000000000000, 0.090000180000270, -0.000000000000000, 0.090000180000270, 0.000000000000000, -0.000000000000000, 0.090000180000270, 0.000000000000000,
136 -0.020000000000000, 0.040000000000000, 0.000000000000000, 0.000000000000000, 0.010000000000000, 0.000000000000000, 0.040000000000000, 0.010000000000000,
137 0.151935669757191, 0.007741936219615, 0.090000180000270, -0.000000000000000, 0.000000000000000, 0.160967924878730, 0.007741936219615, 0.004516127560770,
138 -0.104516127560770, 0.351935664055174, 0.000000000000000, 0.090000180000270, 0.040000000000000, 0.007741936219615, 0.351935664055174, 0.056129031890193,
139 -0.050967744878460, 0.056129031890193, 0.000000000000000, 0.000000000000000, 0.010000000000000, 0.004516127560770, 0.056129031890193, 0.027741936219615;
155 Matrix expected_l2x1(5,5);
157 0.293871159514111, -0.104516127560770, 0.090000180000270, -0.000000000000000, -0.020000000000000,
158 -0.104516127560770, 0.391935664055174, 0.000000000000000, 0.090000180000270, 0.040000000000000,
159 0.090000180000270, 0.000000000000000, 0.090000180000270, -0.000000000000000, 0.000000000000000,
160 -0.000000000000000, 0.090000180000270, -0.000000000000000, 0.090000180000270, 0.000000000000000,
161 -0.020000000000000, 0.040000000000000, 0.000000000000000, 0.000000000000000, 0.010000000000000;
180 marginals =
Marginals(graph, soln, Marginals::CHOLESKY);
181 testMarginals(marginals);
182 marginals =
Marginals(graph, soln, Marginals::QR);
183 testMarginals(marginals);
184 testJointMarginals(marginals);
187 marginals =
Marginals(gfg, soln_lin, Marginals::CHOLESKY);
188 testMarginals(marginals);
189 marginals =
Marginals(gfg, soln_lin, Marginals::QR);
190 testMarginals(marginals);
191 testJointMarginals(marginals);
203 vals.insert(0,
Pose2());
204 vals.insert(1,
Pose2(1,0,0));
205 vals.insert(2,
Pose2(2,0,0));
206 vals.insert(3,
Pose2(3,0,0));
208 vals.insert(100,
Point2(0,1));
209 vals.insert(101,
Point2(1,1));
213 vals.at<
Pose2>(0).
range(vals.at<
Point2>(100)), noiseModel::Unit::Create(2));
216 vals.at<
Pose2>(0).
range(vals.at<
Point2>(101)), noiseModel::Unit::Create(2));
220 vals.at<
Pose2>(1).
range(vals.at<
Point2>(100)), noiseModel::Unit::Create(2));
223 vals.at<
Pose2>(1).
range(vals.at<
Point2>(101)), noiseModel::Unit::Create(2));
227 vals.at<
Pose2>(2).
range(vals.at<
Point2>(100)), noiseModel::Unit::Create(2));
230 vals.at<
Pose2>(2).
range(vals.at<
Point2>(101)), noiseModel::Unit::Create(2));
234 vals.at<
Pose2>(3).
range(vals.at<
Point2>(100)), noiseModel::Unit::Create(2));
237 vals.at<
Pose2>(3).
range(vals.at<
Point2>(101)), noiseModel::Unit::Create(2));
253 testMarginals(marginals,
set);
258 testMarginals(marginals,
set);
Matrix marginalCovariance(Key variable) const
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
static int runAllTests(TestResult &result)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
iterator insert(const std::pair< Key, Vector > &key_value)
GTSAM_EXPORT double range(const Point2 &point, OptionalJacobian< 1, 3 > H1={}, OptionalJacobian< 1, 2 > H2={}) const
NonlinearFactorGraph graph
std::shared_ptr< GaussianFactorGraph > linearize(const Values &linearizationPoint) const
Linearize a nonlinear factor graph.
void addPrior(Key key, const T &prior, const SharedNoiseModel &model=nullptr)
JointMarginal jointMarginalCovariance(const KeyVector &variables) const
#define EXPECT(condition)
TEST(Marginals, planarSLAMmarginals)
Pose2 priorMean(0.0, 0.0, 0.0)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Pose3 x3(Rot3::Ypr(M_PI/4.0, 0.0, 0.0), l2)
#define LONGS_EQUAL(expected, actual)
noiseModel::Diagonal::shared_ptr SharedDiagonal
static EIGEN_DEPRECATED const end_t end
A class for computing marginals in a NonlinearFactorGraph.
Jet< T, N > sqrt(const Jet< T, N > &f)
Pose2 odometry(2.0, 0.0, 0.0)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Marginals marginals(graph, result)