ISEarth.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright (c) 2014-2020 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef ISEARTH_H_
14 #define ISEARTH_H_
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <stdbool.h>
21 
22 #include "ISMatrix.h"
23 #include "ISConstants.h"
24 #include "ISPose.h"
25 
26 #define DEG2RAD_EARTH_RADIUS_F 111120.0f // = DEG2RAD * earth_radius_in_meters
27 #define INV_DEG2RAD_EARTH_RADIUS_F 8.99928005759539236861e-6f // = 1 / ( DEG2RAD * earth_radius_in_meters )
28 
29 #define EARTH_RADIUS_F 6366707.01949371f // = earth_radius_in_meters
30 #define INV_EARTH_RADIUS_F 1.5706706731410E-07f // = 1 / earth_radius_in_meters
31 
32 #if 0
33 typedef Vector2 Vector2_t;
34 typedef Vector3 Vector3_t;
35 typedef Vector4 Vector4_t;
36 typedef Vector3_t Euler_t; // phi, theta, psi (roll, pitch, yaw)
37 typedef Vector4_t Quat_t; // w, x, y, z
38 typedef Matrix2 Matrix2_t;
39 typedef Matrix3 Matrix3_t;
40 typedef Matrix4 Matrix4_t;
41 #else
42 
43 #endif
44 
45 
46 #if (!defined (__cplusplus) && (!defined (inline)))
47 # define inline __inline // allow "inline" keyword to work in windows w/ c program
48 #endif
49 
50 
51 //_____ G L O B A L S ______________________________________________________
52 
53 //_____ P R O T O T Y P E S ________________________________________________
54 
55 /*
56  * Coordinate transformation from ECEF coordinates to latitude/longitude/altitude
57  */
58 void ecef2lla(const double *Pe, double *LLA, const int Niter);
59 
60 /*
61  * Coordinate transformation from latitude/longitude/altitude to ECEF coordinates
62  */
63 void lla2ecef(const double *LLA, double *Pe);
64 
65 /*
66  * Find NED (north, east, down) from LLAref to LLA
67  *
68  * lla[0] = latitude (rad)
69  * lla[1] = longitude (rad)
70  * lla[2] = msl altitude (m)
71  */
72 void lla2ned( Vector3_t llaRef, Vector3_t lla, Vector3_t result );
73 void lla2ned_d( double llaRef[3], double lla[3], Vector3_t result ); // double precision
74 
75 /*
76  * Find NED (north, east, down) from LLAref to LLA
77  *
78  * lla[0] = latitude (degrees)
79  * lla[1] = longitude (degrees)
80  * lla[2] = msl altitude (m)
81  */
82 void llaDeg2ned_d(double llaRef[3], double lla[3], Vector3_t result);
83 
84 /*
85  * Find LLA of NED (north, east, down) from LLAref
86  *
87  * lla[0] = latitude (rad)
88  * lla[1] = longitude (rad)
89  * lla[2] = msl altitude (m)
90  */
91 void ned2lla( Vector3_t ned, Vector3_t llaRef, Vector3_t result );
92 void ned2lla_d( Vector3_t ned, double llaRef[3], double result[3] ); // double precision
93 
94 /*
95 * Find LLA of NED (north, east, down) from LLAref (WGS-84 standard)
96 *
97 * lla[0] = latitude (degrees)
98 * lla[1] = longitude (degrees)
99 * lla[2] = msl altitude (m)
100 */
101 void ned2llaDeg_d(Vector3_t ned, double llaRef[3], double result[3]);
102 
103 /*
104  * Find Delta LLA of NED (north, east, down) from LLAref
105  *
106  * lla[0] = latitude (rad)
107  * lla[1] = longitude (rad)
108  * lla[2] = msl altitude (m)
109  */
110 void ned2DeltaLla(Vector3_t ned, Vector3 llaRef, Vector3 deltaLLA);
111 void ned2DeltaLla_d(Vector3_t ned, double llaRef[3], double deltaLLA[3]);
112 
113 /*
114 * Find Delta LLA of NED (north, east, down) from LLAref
115 *
116 * lla[0] = latitude (degrees)
117 * lla[1] = longitude (degrees)
118 * lla[2] = msl altitude (m)
119 */
120 void ned2DeltaLlaDeg_d(Vector3_t ned, double llaRef[3], double deltaLLA[3]);
121 
122 // Convert LLA from radians to degrees
123 void lla_Rad2Deg_d(double result[3], double lla[3]);
124 
125 // Convert LLA from degrees to radians
126 void lla_Deg2Rad_d(double result[3], double lla[3]);
127 void lla_Deg2Rad_d2(double result[3], double lat, double lon, double alt);
128 
129 /*
130  * Find msl altitude based on barometric pressure
131  * https://en.wikipedia.org/wiki/Atmospheric_pressure
132  *
133  * baroKPa = (kPa) barometric pressure in kilopascals
134  * return = (m) MSL altitude in meters
135  */
136 f_t baro2msl( f_t pKPa );
137 
138 /*
139  * Find linear distance between lat,lon,alt (rad,rad,m) coordinates.
140  *
141  * return = (m) distance in meters
142  */
143 f_t llaRadDistance( double lla1[3], double lla2[3] );
144 f_t llaDegDistance( double lla1[3], double lla2[3] );
145 
146 /*
147  * Check if lat,lon,alt (deg,deg,m) coordinates are valid.
148  *
149  * return 0 on success, -1 on failure.
150  */
151 int llaDegValid( double lla[3] );
152 
153 /*
154  * IGF-80 gravity model with WGS-84 ellipsoid refinement
155 */
156 float gravity_igf80(double lat, double alt);
157 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* ISEARTH_H_ */
void lla2ned_d(double llaRef[3], double lla[3], Vector3_t result)
Definition: ISEarth.c:147
void lla_Deg2Rad_d(double result[3], double lla[3])
Definition: ISEarth.c:318
float f_t
Definition: ISConstants.h:786
float gravity_igf80(double lat, double alt)
Definition: ISEarth.c:352
void ned2llaDeg_d(Vector3_t ned, double llaRef[3], double result[3])
Definition: ISEarth.c:232
f_t llaRadDistance(double lla1[3], double lla2[3])
Definition: ISEarth.c:265
f_t Vector2[2]
Definition: ISConstants.h:789
void lla2ned(Vector3_t llaRef, Vector3_t lla, Vector3_t result)
Definition: ISEarth.c:123
Vector4 Vector4_t
Definition: ISPose.h:34
void lla_Deg2Rad_d2(double result[3], double lat, double lon, double alt)
Definition: ISEarth.c:325
f_t Matrix2[4]
Definition: ISConstants.h:798
void ned2lla(Vector3_t ned, Vector3_t llaRef, Vector3_t result)
Definition: ISEarth.c:194
Matrix3 Matrix3_t
Definition: ISPose.h:39
Matrix4 Matrix4_t
Definition: ISPose.h:40
void lla2ecef(const double *LLA, double *Pe)
Definition: ISEarth.c:91
f_t Matrix4[16]
Definition: ISConstants.h:800
Vector3_t Euler_t
Definition: ISPose.h:35
f_t Vector4[4]
Definition: ISConstants.h:793
void lla_Rad2Deg_d(double result[3], double lla[3])
Definition: ISEarth.c:310
Vector4_t Quat_t
Definition: ISPose.h:36
Matrix2 Matrix2_t
Definition: ISPose.h:38
Vector3 Vector3_t
Definition: ISPose.h:33
void llaDeg2ned_d(double llaRef[3], double lla[3], Vector3_t result)
Definition: ISEarth.c:170
f_t Matrix3[9]
Definition: ISConstants.h:799
void ned2DeltaLla_d(Vector3_t ned, double llaRef[3], double deltaLLA[3])
Definition: ISEarth.c:295
void ned2lla_d(Vector3_t ned, double llaRef[3], double result[3])
Definition: ISEarth.c:213
void ecef2lla(const double *Pe, double *LLA, const int Niter)
Definition: ISEarth.c:54
f_t baro2msl(f_t pKPa)
Definition: ISEarth.c:251
Vector2 Vector2_t
Definition: ISPose.h:32
void ned2DeltaLlaDeg_d(Vector3_t ned, double llaRef[3], double deltaLLA[3])
Definition: ISEarth.c:302
int llaDegValid(double lla[3])
Definition: ISEarth.c:337
f_t llaDegDistance(double lla1[3], double lla2[3])
Definition: ISEarth.c:279
void ned2DeltaLla(Vector3_t ned, Vector3 llaRef, Vector3 deltaLLA)
Definition: ISEarth.c:288


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:04