MRPT  1.9.9
conversions_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <gtest/gtest.h>
11 #include <mrpt/topography.h>
12 
13 using namespace mrpt;
14 using namespace mrpt::math;
15 using namespace mrpt::topography;
16 using namespace std;
17 
19 {
20  TGeocentricCoords geo1;
22  c1, geo1, TEllipsoid::Ellipsoid_WGS84());
23 
24  TGeodeticCoords c2;
26  geo1, c2, TEllipsoid::Ellipsoid_WGS84());
27 
28  EXPECT_NEAR(c1.lat, c2.lat, 1e-8);
29  EXPECT_NEAR(c1.lon, c2.lon, 1e-8);
30  EXPECT_NEAR(c1.height, c2.height, 1e-4);
31 }
32 
33 TEST(TopographyConversion, GeodeticToGeocentricToGeodetic)
34 {
36  TGeodeticCoords(TCoords(36, 1, 30), TCoords(3, 2, 40), 20));
38  TGeodeticCoords(TCoords(-36, 1, 30), TCoords(3, 2, 40), 20));
40  TGeodeticCoords(TCoords(36, 1, 30), TCoords(-3, 2, 40), 20));
42  TGeodeticCoords(TCoords(-36, 1, 30), TCoords(-3, 2, 40), 20));
43 }
44 
45 TEST(TopographyConversion, geodeticToENU_WGS84)
46 {
47  // A test of GPS WGS84 -> ENU Cartessian coordinates with known solution
49  gps_point.lon = -4.475828390;
50  gps_point.lat = 36.716411055;
51  gps_point.height = 48.243;
52 
54  gps_ref.lon = -4.4789588283333330;
55  gps_ref.lat = 36.714459075;
56  gps_ref.height = 38.8887;
57 
58  TPoint3D P;
59  mrpt::topography::geodeticToENU_WGS84(gps_point, P, gps_ref);
60 
61  TPoint3D P_true(279.679067794, 216.621954, 9.34448);
62  EXPECT_NEAR(P.x, P_true.x, 3e-3); // Precision should be *much* better than
63  // 1mm, but don't be so hard...
64  EXPECT_NEAR(P.y, P_true.y, 3e-3);
65  EXPECT_NEAR(P.z, P_true.z, 3e-3);
66 
67  // 2nd test: just modify the height and verify that ENU coordinates only
68  // change in Z:
69  mrpt::topography::TGeodeticCoords gps_point2 = gps_ref;
70  const double A_height = 15.0;
71  gps_point2.height += A_height;
72 
73  mrpt::topography::geodeticToENU_WGS84(gps_point2, P, gps_ref);
74 
75  EXPECT_NEAR(P.x, 0, 0.1e-3); // Precision: 0.1mm
76  EXPECT_NEAR(P.y, 0, 0.1e-3);
77  EXPECT_NEAR(P.z, A_height, 0.1e-3);
78 }
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:192
STL namespace.
void geodeticToENU_WGS84(const TGeodeticCoords &in_coords, mrpt::math::TPoint3D &out_ENU_point, const TGeodeticCoords &in_coords_origin)
Coordinates transformation from longitude/latitude/height to ENU (East-North-Up) X/Y/Z coordinates Th...
void geodeticToGeocentric(const TGeodeticCoords &in_coords, TGeocentricCoords &out_point, const TEllipsoid &ellip)
Coordinates transformation from longitude/latitude/height to geocentric X/Y/Z coordinates (with an sp...
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
Definition: data_types.h:24
TEST(TopographyConversion, GeodeticToGeocentricToGeodetic)
This base provides a set of functions for maths stuff.
TCoords lon
Longitude (in degrees)
Definition: data_types.h:209
void geocentricToGeodetic(const TGeocentricCoords &in_point, TGeodeticCoords &out_coords, const TEllipsoid &ellip=TEllipsoid::Ellipsoid_WGS84())
Coordinates transformation from geocentric X/Y/Z coordinates to longitude/latitude/height.
T x
X,Y,Z coordinates.
Definition: TPoint3D.h:23
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double height
Geodetic height (in meters)
Definition: data_types.h:211
EXPECT_NEAR(out.cam_params.rightCameraPose.x, 0.1194, 0.005)
This namespace provides topography helper functions, coordinate transformations.
Definition: conversions.h:21
TCoords lat
Latitude (in degrees)
Definition: data_types.h:207
void do_test_geodetic_geocentric(const TGeodeticCoords c1)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 5ec5114f2 Thu Feb 20 07:54:08 2020 +0100 at jue feb 20 08:00:10 CET 2020