testBearingRangeFactor.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 
20 #include <gtsam/geometry/Pose2.h>
21 #include <gtsam/geometry/Pose3.h>
26 
28 
29 using namespace std;
30 using namespace gtsam;
31 
32 Key poseKey(1);
33 Key pointKey(2);
34 
36 static SharedNoiseModel model2D(noiseModel::Isotropic::Sigma(2, 0.5));
38 
40 static SharedNoiseModel model3D(noiseModel::Isotropic::Sigma(3, 0.5));
41 BearingRangeFactor3D factor3D(poseKey, pointKey,
42  Pose3().bearing(Point3(1, 0, 0)), 1, model3D);
43 
44 /* ************************************************************************* */
45 // Export Noisemodels
46 // See http://www.boost.org/doc/libs/1_32_0/libs/serialization/doc/special.html
48 
49 /* ************************************************************************* */
50 TEST(BearingRangeFactor, Serialization2D) {
54 }
55 
56 /* ************************************************************************* */
58  // Serialize the factor
59  std::string serialized = serializeXML(factor2D);
60 
61  // And de-serialize it
62  BearingRangeFactor2D factor;
63  deserializeXML(serialized, factor);
64 
65  // Set the linearization point
66  Values values;
67  values.insert(poseKey, Pose2(1.0, 2.0, 0.57));
68  values.insert(pointKey, Point2(-4.0, 11.0));
69 
70  EXPECT_CORRECT_EXPRESSION_JACOBIANS(factor.expression({poseKey, pointKey}),
71  values, 1e-7, 1e-5);
72  EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, 1e-7, 1e-5);
73 }
74 
75 /* ************************************************************************* */
76 TEST(BearingRangeFactor, Serialization3D) {
80 }
81 
82 /* ************************************************************************* */
83 // TODO(frank): this test is disabled (for now) because the macros below are
84 // incompatible with the Unit3 localCoordinates. See testBearingFactor...
85 //TEST(BearingRangeFactor, 3D) {
86 // // Serialize the factor
87 // std::string serialized = serializeXML(factor3D);
88 //
89 // // And de-serialize it
90 // BearingRangeFactor3D factor;
91 // deserializeXML(serialized, factor);
92 //
93 // // Set the linearization point
94 // Values values;
95 // values.insert(poseKey, Pose3());
96 // values.insert(pointKey, Point3(1, 0, 0));
97 //
98 // EXPECT_CORRECT_EXPRESSION_JACOBIANS(factor.expression({poseKey, pointKey}),
99 // values, 1e-7, 1e-5);
100 // EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, 1e-7, 1e-5);
101 //}
102 
103 /* ************************************************************************* */
104 int main() {
105  TestResult tr;
106  return TestRegistry::runAllTests(tr);
107 }
108 /* ************************************************************************* */
Key pointKey(2)
static SharedNoiseModel model3D(noiseModel::Isotropic::Sigma(3, 0.5))
static int runAllTests(TestResult &result)
void insert(Key j, const Value &val)
Definition: Values.cpp:140
BearingRangeFactor2D factor2D(poseKey, pointKey, 1, 2, model2D)
BOOST_CLASS_EXPORT(gtsam::noiseModel::Isotropic)
Vector2 Point2
Definition: Point2.h:27
leaf::MyValues values
Definition: Half.h:150
Evaluate derivatives of a nonlinear factor numerically.
static SharedNoiseModel model2D(noiseModel::Isotropic::Sigma(2, 0.5))
#define EXPECT_CORRECT_EXPRESSION_JACOBIANS(expression, values, numerical_derivative_step, tolerance)
Check the Jacobians produced by an expression against finite differences.
void deserializeXML(const std::string &serialized, T &output, const std::string &name="data")
deserializes from a string in XML
BearingRangeFactor< Pose3, Point3 > BearingRangeFactor3D
Test harness methods for expressions.
#define EXPECT(condition)
Definition: Test.h:151
TEST(BearingRangeFactor, Serialization2D)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
traits
Definition: chartTesting.h:28
std::string serializeXML(const T &input, const std::string &name="data")
serializes to a string in XML
BearingRangeFactor3D factor3D(poseKey, pointKey, Pose3().bearing(Point3(1, 0, 0)), 1, model3D)
#define EXPECT_CORRECT_FACTOR_JACOBIANS(factor, values, numerical_derivative_step, tolerance)
Check the Jacobians produced by a factor against finite differences.
Vector3 Point3
Definition: Point3.h:35
2D Pose
BearingRangeFactor< Pose2, Point2 > BearingRangeFactor2D
3D Pose
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:734
Key poseKey(1)
Expression< T > expression(const typename Base::ArrayNKeys &keys) const override


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:46:18