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-2017, 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::utils;
15 using namespace mrpt::math;
16 using namespace mrpt::topography;
17 using namespace std;
18 
20 {
21  TGeocentricCoords geo1;
23  c1, geo1, TEllipsoid::Ellipsoid_WGS84());
24 
25  TGeodeticCoords c2;
27  geo1, c2, TEllipsoid::Ellipsoid_WGS84());
28 
29  EXPECT_NEAR(c1.lat, c2.lat, 1e-8);
30  EXPECT_NEAR(c1.lon, c2.lon, 1e-8);
31  EXPECT_NEAR(c1.height, c2.height, 1e-4);
32 }
33 
34 TEST(TopographyConversion, GeodeticToGeocentricToGeodetic)
35 {
37  TGeodeticCoords(TCoords(36, 1, 30), TCoords(3, 2, 40), 20));
39  TGeodeticCoords(TCoords(-36, 1, 30), TCoords(3, 2, 40), 20));
41  TGeodeticCoords(TCoords(36, 1, 30), TCoords(-3, 2, 40), 20));
43  TGeodeticCoords(TCoords(-36, 1, 30), TCoords(-3, 2, 40), 20));
44 }
45 
46 TEST(TopographyConversion, geodeticToENU_WGS84)
47 {
48  // A test of GPS WGS84 -> ENU Cartessian coordinates with known solution
50  gps_point.lon = -4.475828390;
51  gps_point.lat = 36.716411055;
52  gps_point.height = 48.243;
53 
55  gps_ref.lon = -4.4789588283333330;
56  gps_ref.lat = 36.714459075;
57  gps_ref.height = 38.8887;
58 
59  TPoint3D P;
60  mrpt::topography::geodeticToENU_WGS84(gps_point, P, gps_ref);
61 
62  TPoint3D P_true(279.679067794, 216.621954, 9.34448);
63  EXPECT_NEAR(P.x, P_true.x, 3e-3); // Precision should be *much* better than
64  // 1mm, but don't be so hard...
65  EXPECT_NEAR(P.y, P_true.y, 3e-3);
66  EXPECT_NEAR(P.z, P_true.z, 3e-3);
67 
68  // 2nd test: just modify the height and verify that ENU coordinates only
69  // change in Z:
70  mrpt::topography::TGeodeticCoords gps_point2 = gps_ref;
71  const double A_height = 15.0;
72  gps_point2.height += A_height;
73 
74  mrpt::topography::geodeticToENU_WGS84(gps_point2, P, gps_ref);
75 
76  EXPECT_NEAR(P.x, 0, 0.1e-3); // Precision: 0.1mm
77  EXPECT_NEAR(P.y, 0, 0.1e-3);
78  EXPECT_NEAR(P.z, A_height, 0.1e-3);
79 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
A set of geodetic coordinates: latitude, longitude and height, defined over a given geoid (typically...
Definition: data_types.h:196
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:28
TEST(TopographyConversion, GeodeticToGeocentricToGeodetic)
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
TCoords lon
Longitude (in degrees)
Definition: data_types.h:213
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.
double x
X,Y,Z coordinates.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
double height
Geodetic height (in meters)
Definition: data_types.h:215
Lightweight 3D point.
This namespace provides topography helper functions, coordinate transformations.
Definition: conversions.h:23
TCoords lat
Latitude (in degrees)
Definition: data_types.h:211
void do_test_geodetic_geocentric(const TGeodeticCoords c1)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019