Main MRPT website > C++ reference for MRPT 1.9.9
conversions_unittest.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include <mrpt/topography.h>
11 #include <gtest/gtest.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 }
do_test_geodetic_geocentric
void do_test_geodetic_geocentric(const TGeodeticCoords c1)
Definition: conversions_unittest.cpp:18
mrpt::topography::geodeticToENU_WGS84
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...
Definition: conversions.cpp:126
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
topography.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::topography::TGeodeticCoords::lon
TCoords lon
Longitude (in degrees)
Definition: data_types.h:212
TEST
TEST(TopographyConversion, GeodeticToGeocentricToGeodetic)
Definition: conversions_unittest.cpp:33
mrpt::topography::TGeodeticCoords
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically,...
Definition: data_types.h:195
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::topography::TGeodeticCoords::height
double height
Geodetic height (in meters)
Definition: data_types.h:214
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::topography
This namespace provides topography helper functions, coordinate transformations.
Definition: conversions.h:22
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
mrpt::topography::geocentricToGeodetic
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.
Definition: conversions.cpp:259
mrpt::topography::geodeticToGeocentric
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...
Definition: conversions.cpp:228
mrpt::topography::TCoords
A coordinate that is stored as a simple "decimal" angle in degrees, but can be retrieved/set in the f...
Definition: data_types.h:27
mrpt::topography::TGeodeticCoords::lat
TCoords lat
Latitude (in degrees)
Definition: data_types.h:210



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST