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



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020