MAV'RIC
coord_conventions.h
1 /*******************************************************************************
2  * Copyright (c) 2009-2014, MAV'RIC Development Team
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its contributors
16  * may be used to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  ******************************************************************************/
31 
32 /*******************************************************************************
33  * \file coord_conventions.h
34  *
35  * \author MAV'RIC Team
36  * \author Julien Lecoeur
37  *
38  * \brief Coordinate conventions
39  *
40  ******************************************************************************/
41 
42 
43 #ifndef COORD_CONVENTIONS_H_
44 #define COORD_CONVENTIONS_H_
45 
46 #ifdef __cplusplus
47 extern "C"
48 {
49 #endif
50 
51 #include <stdint.h>
52 #include "quaternions.h"
53 
54 #define EARTH_RADIUS 6378137.0f
55 
56 
60 typedef struct
61 {
62  double longitude;
63  double latitude;
64  float altitude;
65  float heading;
66  uint32_t timestamp_ms;
68 
69 
73 typedef struct
74 {
75  float pos[3];
76  float heading;
78  uint32_t timestamp_ms;
80 
81 
82 /*
83  * \brief Attitude with aeronautics convention
84  *
85  * \details Expressed with the NED frame: X front, Y right, Z down.
86  * The rotations are done in the following order:
87  * - first around the local yaw axis,
88  * - then around new local pitch axis,
89  * - and finally around the new roll axis
90 */
91 typedef struct
92 {
93  float rpy[3];
95 
96 
105 global_position_t coord_conventions_local_to_global_position(local_coordinates_t input);
106 
107 
116 local_coordinates_t coord_conventions_global_to_local_position(global_position_t position, global_position_t origin);
117 
118 
126 aero_attitude_t coord_conventions_quat_to_aero(quat_t qe);
127 
128 
136 quat_t coord_conventions_quaternion_from_aero(aero_attitude_t aero);
137 
138 
146 float coord_conventions_get_yaw(quat_t qe);
147 
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
153 #endif /* STABILISATION_H_ */
double longitude
Current longitude.
Definition: coord_conventions.h:62
global_position_t origin
Global coordinates of the local frame's origin (ie. local (0, 0, 0) expressed in the global frame) ...
Definition: coord_conventions.h:77
float altitude
Current altitude.
Definition: coord_conventions.h:64
double latitude
Current latitude.
Definition: coord_conventions.h:63
uint32_t timestamp_ms
Timestamp (milliseconds)
Definition: coord_conventions.h:66
Unit quaternion.
Definition: quaternions.h:62
Global position structure.
Definition: coord_conventions.h:60
float heading
Current heading.
Definition: coord_conventions.h:65
Local coordinates structure.
Definition: coord_conventions.h:73
uint32_t timestamp_ms
Timestamp (milliseconds)
Definition: coord_conventions.h:78
float heading
Current heading (equal to heading in global frame)
Definition: coord_conventions.h:76
Definition: coord_conventions.h:91