testSerializationGeometry.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 <gtsam/geometry/Pose2.h>
20 #include <gtsam/geometry/Unit3.h>
22 #include <gtsam/geometry/Cal3_S2.h>
26 #include <gtsam/geometry/Cal3DS2.h>
31 
34 
35 using namespace std;
36 using namespace gtsam;
37 using namespace gtsam::serializationTestHelpers;
38 
39 /* ************************************************************************* */
40 static Point3 pt3(1.0, 2.0, 3.0);
41 static Rot3 rt3 = Rot3::RzRyRx(1.0, 3.0, 2.0);
42 static Pose3 pose3(rt3, pt3);
43 
44 static Unit3 unit3(1.0, 2.1, 3.4);
45 static EssentialMatrix ematrix(rt3, unit3);
46 
47 static Cal3_S2 cal1(1.0, 2.0, 0.3, 0.1, 0.5);
48 static Cal3DS2 cal2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
49 static Cal3Bundler cal3(1.0, 2.0, 3.0);
50 static Cal3_S2Stereo cal4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
52 static CalibratedCamera cal5(Pose3(rt3, pt3));
53 static Cal3Unified cal6(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0);
54 
57 static StereoPoint2 spt(1.0, 2.0, 3.0);
58 
59 /* ************************************************************************* */
60 TEST (Serialization, text_geometry) {
61  EXPECT(equalsObj<gtsam::Point2>(Point2(1.0, 2.0)));
62  EXPECT(equalsObj<gtsam::Pose2>(Pose2(1.0, 2.0, 0.3)));
63  EXPECT(equalsObj<gtsam::Rot2>(Rot2::fromDegrees(30.0)));
64 
65  EXPECT(equalsObj<gtsam::Unit3>(Unit3(1.0, 2.1, 3.4)));
66  EXPECT(equalsObj<gtsam::EssentialMatrix>(EssentialMatrix(rt3, unit3)));
67 
68  EXPECT(equalsObj(pt3));
69  EXPECT(equalsObj<gtsam::Rot3>(rt3));
70  EXPECT(equalsObj<gtsam::Pose3>(Pose3(rt3, pt3)));
71 
72  EXPECT(equalsObj(cal1));
73  EXPECT(equalsObj(cal2));
74  EXPECT(equalsObj(cal3));
75  EXPECT(equalsObj(cal4));
76  EXPECT(equalsObj(cal5));
77  EXPECT(equalsObj(cal6));
78 
79  EXPECT(equalsObj(cam1));
80  EXPECT(equalsObj(cam2));
81  EXPECT(equalsObj(spt));
82 }
83 
84 /* ************************************************************************* */
85 TEST (Serialization, xml_geometry) {
86  EXPECT(equalsXML<gtsam::Point2>(Point2(1.0, 2.0)));
87  EXPECT(equalsXML<gtsam::Pose2>(Pose2(1.0, 2.0, 0.3)));
88  EXPECT(equalsXML<gtsam::Rot2>(Rot2::fromDegrees(30.0)));
89 
90  EXPECT(equalsXML<gtsam::Unit3>(Unit3(1.0, 2.1, 3.4)));
91  EXPECT(equalsXML<gtsam::EssentialMatrix>(EssentialMatrix(rt3, unit3)));
92 
93  EXPECT(equalsXML<gtsam::Point3>(pt3));
94  EXPECT(equalsXML<gtsam::Rot3>(rt3));
95  EXPECT(equalsXML<gtsam::Pose3>(Pose3(rt3, pt3)));
96 
97  EXPECT(equalsXML(cal1));
98  EXPECT(equalsXML(cal2));
99  EXPECT(equalsXML(cal3));
100  EXPECT(equalsXML(cal4));
101  EXPECT(equalsXML(cal5));
102 
103  EXPECT(equalsXML(cam1));
104  EXPECT(equalsXML(cam2));
105  EXPECT(equalsXML(spt));
106 }
107 
108 /* ************************************************************************* */
109 TEST (Serialization, binary_geometry) {
110  EXPECT(equalsBinary<gtsam::Point2>(Point2(1.0, 2.0)));
111  EXPECT(equalsBinary<gtsam::Pose2>(Pose2(1.0, 2.0, 0.3)));
112  EXPECT(equalsBinary<gtsam::Rot2>(Rot2::fromDegrees(30.0)));
113 
114  EXPECT(equalsBinary<gtsam::Unit3>(Unit3(1.0, 2.1, 3.4)));
115  EXPECT(equalsBinary<gtsam::EssentialMatrix>(EssentialMatrix(rt3, unit3)));
116 
117  EXPECT(equalsBinary<gtsam::Point3>(pt3));
118  EXPECT(equalsBinary<gtsam::Rot3>(rt3));
119  EXPECT(equalsBinary<gtsam::Pose3>(Pose3(rt3, pt3)));
120 
121  EXPECT(equalsBinary(cal1));
122  EXPECT(equalsBinary(cal2));
123  EXPECT(equalsBinary(cal3));
124  EXPECT(equalsBinary(cal4));
125  EXPECT(equalsBinary(cal5));
126 
127  EXPECT(equalsBinary(cam1));
128  EXPECT(equalsBinary(cam2));
129  EXPECT(equalsBinary(spt));
130 }
131 
132 /* ************************************************************************* */
133 int main() { TestResult tr; return TestRegistry::runAllTests(tr); }
134 /* ************************************************************************* */
static Cal3Unified cal6(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)
static PinholeCamera< Cal3_S2 > cam1(pose3, cal1)
static int runAllTests(TestResult &result)
static CalibratedCamera cal5(Pose3(rt3, pt3))
static StereoCamera cam2(pose3, cal4ptr)
Vector2 Point2
Definition: Point2.h:32
Definition: BFloat16.h:88
Calibration of a camera with radial distortion, calculations in base class Cal3DS2_Base.
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
Represents a 3D point on a unit sphere.
Definition: Unit3.h:42
Base class for all pinhole cameras.
static EssentialMatrix ematrix(rt3, unit3)
static Cal3Bundler cal3(1.0, 2.0, 3.0)
The most common 5DOF 3D->2D calibration, stereo version.
Definition: Cal3_S2Stereo.h:30
#define EXPECT(condition)
Definition: Test.h:150
static Pose3 pose3(rt3, pt3)
The most common 5DOF 3D->2D calibration.
Definition: Cal3_S2.h:34
TEST(Serialization, text_geometry)
Calibration of a camera with radial distortion that also supports Lie-group behaviors for optimizatio...
Definition: Cal3DS2.h:35
std::shared_ptr< Cal3_S2Stereo > shared_ptr
Definition: Cal3_S2Stereo.h:38
Calibrated camera for which only pose is unknown.
static Unit3 unit3(1.0, 2.1, 3.4)
traits
Definition: chartTesting.h:28
Calibration of a omni-directional camera with mirror + lens radial distortion.
Definition: Cal3Unified.h:45
The most common 5DOF 3D->2D calibration + Stereo baseline.
Calibration used by Bundler.
Definition: Cal3Bundler.h:32
static StereoPoint2 spt(1.0, 2.0, 3.0)
A Stereo Camera based on two Simple Cameras.
static Cal3DS2 cal2(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)
A 2D stereo point (uL,uR,v)
static Cal3_S2Stereo cal4(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
Vector3 Point3
Definition: Point3.h:38
static Rot3 rt3
Unified Calibration Model, see Mei07icra for details.
2D Pose
static Cal3_S2Stereo::shared_ptr cal4ptr(new Cal3_S2Stereo(cal4))
static Point3 pt3(1.0, 2.0, 3.0)
Calibration used by Bundler.
static Cal3_S2 cal1(1.0, 2.0, 0.3, 0.1, 0.5)
The most common 5DOF 3D->2D calibration.


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