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 /* ************************************************************************* */
47 TEST(SmartFactorBase, serialize) {
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;
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;
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 /* ************************************************************************* */
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
Gaussian
double Gaussian(double mu, double sigma, double z)
Gaussian density function.
Definition: testGaussianMixture.cpp:47
PinholeFactor.h
helper class for tests
vanillaPose
Definition: smartFactorScenarios.h:74
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
TestHarness.h
BOOST_CLASS_EXPORT_GUID
BOOST_CLASS_EXPORT_GUID(DecisionTreeFactor, "gtsam_DecisionTreeFactor")
gtsam::SmartProjectionParams
Definition: SmartFactorParams.h:42
SmartProjectionFactor.h
Smart factor on cameras (pose + calibration)
LevenbergMarquardtOptimizer.h
A nonlinear optimizer that uses the Levenberg-Marquardt trust-region scheme.
TEST
TEST(SmartFactorBase, serialize)
Definition: testSerializationInSlam.cpp:47
vanillaPose::sharedK
static const Cal3_S2::shared_ptr sharedK(new Cal3_S2(fov, w, h))
vanilla::params
static const SmartProjectionParams params
Definition: smartFactorScenarios.h:69
rankTol
static const double rankTol
Definition: testSmartProjectionRigFactor.cpp:35
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:92
gtsam::noiseModel::Constrained
Definition: NoiseModel.h:404
sampling::sigma
static const double sigma
Definition: testGaussianBayesNet.cpp:170
gtsam::SmartProjectionParams::setRankTolerance
void setRankTolerance(double rankTol)
Definition: SmartFactorParams.h:106
gtsam::Pose3
Definition: Pose3.h:37
gtsam::SmartProjectionPoseFactor
Definition: SmartProjectionPoseFactor.h:45
gtsam::SharedDiagonal
noiseModel::Diagonal::shared_ptr SharedDiagonal
Definition: NoiseModel.h:764
main
int main()
Definition: testSerializationInSlam.cpp:101
gtsam::Point2
Vector2 Point2
Definition: Point2.h:32
gtsam::SharedNoiseModel
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:762
model
noiseModel::Diagonal::shared_ptr model
Definition: doc/Code/Pose2SLAMExample.cpp:7
serializationTestHelpers.h
TestResult
Definition: TestResult.h:26
std_optional_serialization.h
gtsam::SmartFactorBase
Base class for smart factors. This base class has no internal point, but it has a measurement,...
Definition: SmartFactorBase.h:51
gtsam::SmartProjectionFactor
Definition: SmartProjectionFactor.h:44
gtsam::PinholeFactor
Definition: PinholeFactor.h:33
gtsam::Diagonal
static noiseModel::Diagonal::shared_ptr Diagonal(const Matrix &covariance)
Definition: ScenarioRunner.h:27
gtsam::Point2Vector
std::vector< Point2, Eigen::aligned_allocator< Point2 > > Point2Vector
Definition: Point2.h:49
vanilla
Definition: smartFactorScenarios.h:56
gtsam::SharedIsotropic
noiseModel::Isotropic::shared_ptr SharedIsotropic
Definition: NoiseModel.h:766
gtsam::SmartFactorBase::add
void add(const Z &measured, const Key &key)
Definition: SmartFactorBase.h:127
smartFactorScenarios.h
gtsam::Symbol
Definition: inference/Symbol.h:37


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:08:26