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 
69  EXPECT(equalsObj<gtsam::Rot3>(rt3));
70  EXPECT(equalsObj<gtsam::Pose3>(Pose3(rt3, pt3)));
71 
78 
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 
102 
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 
126 
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:27
Definition: Half.h:150
Calibration of a camera with radial distortion, calculations in base class Cal3DS2_Base.
Represents a 3D point on a unit sphere.
Definition: Unit3.h:42
Base class for all pinhole cameras.
static EssentialMatrix ematrix(rt3, unit3)
boost::shared_ptr< Cal3_S2Stereo > shared_ptr
Definition: Cal3_S2Stereo.h:38
static Cal3Bundler cal3(1.0, 2.0, 3.0)
#define EXPECT(condition)
Definition: Test.h:151
static Pose3 pose3(rt3, pt3)
TEST(Serialization, text_geometry)
Calibrated camera for which only pose is unknown.
static Unit3 unit3(1.0, 2.1, 3.4)
traits
Definition: chartTesting.h:28
The most common 5DOF 3D->2D calibration + Stereo baseline.
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:35
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 Sat May 8 2021 02:49:23