testSerializationInSlam.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 
19 #include "smartFactorScenarios.h"
20 #include "PinholeFactor.h"
21 
26 
28 
29 #include <iostream>
30 
31 namespace {
32 static const double rankTol = 1.0;
33 static const double sigma = 0.1;
34 static SharedIsotropic model(noiseModel::Isotropic::Sigma(2, sigma));
35 } // namespace
36 
37 /* ************************************************************************* */
38 BOOST_CLASS_EXPORT_GUID(noiseModel::Constrained, "gtsam_noiseModel_Constrained")
39 BOOST_CLASS_EXPORT_GUID(noiseModel::Diagonal, "gtsam_noiseModel_Diagonal")
40 BOOST_CLASS_EXPORT_GUID(noiseModel::Gaussian, "gtsam_noiseModel_Gaussian")
41 BOOST_CLASS_EXPORT_GUID(noiseModel::Unit, "gtsam_noiseModel_Unit")
42 BOOST_CLASS_EXPORT_GUID(noiseModel::Isotropic, "gtsam_noiseModel_Isotropic")
43 BOOST_CLASS_EXPORT_GUID(SharedNoiseModel, "gtsam_SharedNoiseModel")
44 BOOST_CLASS_EXPORT_GUID(SharedDiagonal, "gtsam_SharedDiagonal")
45 
46 /* ************************************************************************* */
48  using namespace serializationTestHelpers;
49  PinholeFactor factor(unit2);
50 
51  EXPECT(equalsObj(factor));
52  EXPECT(equalsXML(factor));
53  EXPECT(equalsBinary(factor));
54 }
55 
56 /* ************************************************************************* */
57 TEST(SerializationSlam, SmartProjectionFactor) {
58  using namespace vanilla;
59  using namespace serializationTestHelpers;
60  SmartFactor factor(unit2);
61 
62  EXPECT(equalsObj(factor));
63  EXPECT(equalsXML(factor));
64  EXPECT(equalsBinary(factor));
65 }
66 
67 /* ************************************************************************* */
68 TEST(SerializationSlam, SmartProjectionPoseFactor) {
69  using namespace vanillaPose;
70  using namespace serializationTestHelpers;
72  params.setRankTolerance(rankTol);
73  SmartFactor factor(model, sharedK, params);
74 
75  EXPECT(equalsObj(factor));
76  EXPECT(equalsXML(factor));
77  EXPECT(equalsBinary(factor));
78 }
79 
80 TEST(SerializationSlam, SmartProjectionPoseFactor2) {
81  using namespace vanillaPose;
82  using namespace serializationTestHelpers;
84  params.setRankTolerance(rankTol);
85  Pose3 bts;
86  SmartFactor factor(model, sharedK, bts, params);
87 
88  // insert some measurments
89  KeyVector key_view;
90  Point2Vector meas_view;
91  key_view.push_back(Symbol('x', 1));
92  meas_view.push_back(Point2(10, 10));
93  factor.add(meas_view, key_view);
94 
95  EXPECT(equalsObj(factor));
96  EXPECT(equalsXML(factor));
97  EXPECT(equalsBinary(factor));
98 }
99 
100 /* ************************************************************************* */
101 int main() {
102  TestResult tr;
103  return TestRegistry::runAllTests(tr);
104 }
105 /* ************************************************************************* */
static int runAllTests(TestResult &result)
std::string serialize(const T &input)
serializes to a string
noiseModel::Diagonal::shared_ptr model
Vector2 Point2
Definition: Point2.h:32
noiseModel::Isotropic::shared_ptr SharedIsotropic
Definition: NoiseModel.h:745
static const SmartProjectionParams params
helper class for tests
void setRankTolerance(double rankTol)
Smart factor on cameras (pose + calibration)
static const double rankTol
Base class for smart factors. This base class has no internal point, but it has a measurement...
#define EXPECT(condition)
Definition: Test.h:150
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
static const Cal3_S2::shared_ptr sharedK(new Cal3_S2(fov, w, h))
noiseModel::Diagonal::shared_ptr SharedDiagonal
Definition: NoiseModel.h:743
void add(const Z &measured, const Key &key)
std::vector< Point2, Eigen::aligned_allocator< Point2 > > Point2Vector
Definition: Point2.h:49
TEST(SmartFactorBase, serialize)
static noiseModel::Diagonal::shared_ptr Diagonal(const Matrix &covariance)
static const double sigma
BOOST_CLASS_EXPORT_GUID(DecisionTreeFactor, "gtsam_DecisionTreeFactor")
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:86
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:39:20