Paparazzi UAS  v5.15_devel-46-gd23ed71
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gps.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2011 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
27 #ifndef GPS_H
28 #define GPS_H
29 
30 
31 #include "std.h"
32 #include "math/pprz_geodetic_int.h"
34 
35 #include "mcu_periph/sys_time.h"
36 
37 #define GPS_FIX_NONE 0x00
38 #define GPS_FIX_2D 0x02
39 #define GPS_FIX_3D 0x03
40 #define GPS_FIX_DGPS 0x04
41 #define GPS_FIX_RTK 0x05
42 
43 #define GpsFixValid() (gps.fix >= GPS_FIX_3D)
44 #if USE_GPS
45 #define GpsIsLost() !GpsFixValid()
46 #endif
47 
48 #define GPS_VALID_POS_ECEF_BIT 0
49 #define GPS_VALID_POS_LLA_BIT 1
50 #define GPS_VALID_POS_UTM_BIT 2
51 #define GPS_VALID_VEL_ECEF_BIT 3
52 #define GPS_VALID_VEL_NED_BIT 4
53 #define GPS_VALID_HMSL_BIT 5
54 #define GPS_VALID_COURSE_BIT 6
55 
56 #ifndef GPS_NB_CHANNELS
57 #define GPS_NB_CHANNELS 16
58 #endif
59 
60 #define GPS_MODE_AUTO 0
61 #define GPS_MODE_PRIMARY 1
62 #define GPS_MODE_SECONDARY 2
63 
64 #ifndef MULTI_GPS_MODE
65 #define MULTI_GPS_MODE GPS_MODE_AUTO
66 #endif
67 
68 extern uint8_t multi_gps_mode;
69 
71 struct SVinfo {
78 };
79 
81 struct GpsState {
84 
86  struct LlaCoor_i lla_pos;
87  struct UtmCoor_i utm_pos;
90  struct NedCoor_i ned_vel;
104 
107 
113 };
114 
116 struct GpsTimeSync {
120 };
121 
123 struct GpsRelposNED {
139 };
140 
141 struct RtcmMan {
143  uint16_t MsgType; // Counter variables to count the number of Rtcm msgs in the input stream(for each msg type)
146  uint32_t Cnt187; // Counter variables to count the number of messages that failed Crc Check
150 };
151 
153 extern struct GpsState gps;
154 
155 #ifdef GPS_TYPE_H
156 #include GPS_TYPE_H
157 #endif
158 #ifdef GPS_SECONDARY_TYPE_H
159 #include GPS_SECONDARY_TYPE_H
160 #endif
161 
163 extern void gps_init(void);
164 
166 extern void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data);
167 
169 #ifndef GPS_TIMEOUT
170 #define GPS_TIMEOUT 2
171 #endif
172 
173 static inline bool gps_has_been_good(void)
174 {
175  static bool gps_had_valid_fix = false;
176  if (GpsFixValid()) {
177  gps_had_valid_fix = true;
178  }
179  return gps_had_valid_fix;
180 }
181 
182 
186 extern void gps_periodic_check(struct GpsState *gps_s);
187 
188 
189 /*
190  * For GPS time synchronizaiton...
191  */
192 extern struct GpsTimeSync gps_time_sync;
193 
199 extern uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks);
200 
208 extern struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone);
209 
217 extern struct UtmCoor_i utm_int_from_gps(struct GpsState *gps_s, uint8_t zone);
218 
219 #endif /* GPS_H */
uint8_t qi
quality bitfield (GPS receiver specific)
Definition: gps.h:74
unsigned short uint16_t
Definition: types.h:16
uint32_t t0_tow
GPS time of week in ms from last message.
Definition: gps.h:117
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
Definition: gps.c:362
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
Definition: gps.h:106
int16_t azim
azimuth in deg
Definition: gps.h:77
uint32_t pacc
position accuracy in cm
Definition: gps.h:94
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:105
uint32_t Cnt187
Definition: gps.h:146
uint32_t t0_ticks
hw clock ticks when GPS message is received
Definition: gps.h:119
vector in EarthCenteredEarthFixed coordinates
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
Definition: gps.h:82
uint8_t carrSoln
Definition: gps.h:135
uint32_t hacc
horizontal accuracy in cm
Definition: gps.h:95
uint16_t week
GPS week.
Definition: gps.h:102
#define GPS_NB_CHANNELS
Definition: gps.h:57
void gps_init(void)
initialize the global GPS state
Definition: gps.c:315
struct UtmCoor_i utm_int_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience function to get utm position in int from GPS structure.
Definition: gps.c:421
int32_t relPosE
Definition: gps.h:127
uint32_t vacc
vertical accuracy in cm
Definition: gps.h:96
void gps_periodic_check(struct GpsState *gps_s)
Periodic GPS check.
Definition: gps.c:270
uint16_t reset
hotstart, warmstart, coldstart
Definition: gps.h:112
position in UTM coordinates Units: meters
int8_t relPosHPD
Definition: gps.h:131
uint8_t svid
Satellite ID.
Definition: gps.h:72
vector in Latitude, Longitude and Altitude
uint16_t speed_3d
norm of 3d speed in cm/s
Definition: gps.h:92
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over MSL)
Definition: gps.h:87
uint8_t diffSoln
Definition: gps.h:137
uint32_t Crc187
Definition: gps.h:149
void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
GPS packet injection (default empty)
Definition: gps_piksi.c:408
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
Definition: gps.h:108
int8_t elev
elevation in deg
Definition: gps.h:76
struct GpsState gps
global GPS state
Definition: gps.c:75
uint32_t accN
Definition: gps.h:132
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:97
static bool gps_has_been_good(void)
Definition: gps.h:173
uint32_t last_msg_time
cpu time in sec at last received GPS message
Definition: gps.h:111
uint32_t cacc
course accuracy in rad*1e7
Definition: gps.h:98
struct GpsTimeSync gps_time_sync
Definition: gps.c:77
uint8_t zone
UTM zone number.
Paparazzi floating point math for geodetic calculations.
int8_t relPosHPE
Definition: gps.h:130
uint32_t Crc105
Definition: gps.h:147
int32_t hmsl
height above mean sea level (MSL) in mm
Definition: gps.h:88
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:75
Architecture independent timing functions.
data structure for GPS information
Definition: gps.h:81
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience function to get utm position in float from GPS structure.
Definition: gps.c:395
uint32_t tow
GPS time of week in ms.
Definition: gps.h:103
data structure for Space Vehicle Information of a single satellite
Definition: gps.h:71
uint32_t Cnt177
Definition: gps.h:145
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:99
Definition: gps.h:141
unsigned long uint32_t
Definition: types.h:18
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:85
signed short int16_t
Definition: types.h:17
uint32_t iTOW
Definition: gps.h:124
Paparazzi fixed point math for geodetic calculations.
int32_t relPosD
Definition: gps.h:128
uint8_t zone
UTM zone number.
int32_t relPosN
Definition: gps.h:126
signed long int32_t
Definition: types.h:19
uint8_t relPosValid
Definition: gps.h:136
int8_t relPosHPN
Definition: gps.h:129
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
Definition: gps.h:109
uint32_t accE
Definition: gps.h:133
unsigned char uint8_t
Definition: types.h:14
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition: gps.h:93
uint16_t MsgType
Definition: gps.h:143
uint8_t comp_id
id of current gps
Definition: gps.h:83
vector in North East Down coordinates
int32_t t0_tow_frac
fractional ns remainder of tow [ms], range -500000 .. 500000
Definition: gps.h:118
data structures for GPS with RTK capabilities
Definition: gps.h:123
uint32_t accD
Definition: gps.h:134
uint8_t flags
bitfield with GPS receiver specific flags
Definition: gps.h:73
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
Definition: gps.h:110
uint8_t num_sv
number of sat in fix
Definition: gps.h:100
uint8_t gnssFixOK
Definition: gps.h:138
uint32_t Cnt105
Definition: gps.h:144
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:91
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:89
data structure for GPS time sync
Definition: gps.h:116
uint32_t Crc177
Definition: gps.h:148
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:86
signed char int8_t
Definition: types.h:15
uint8_t fix
status of fix
Definition: gps.h:101
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:90
uint16_t RefStation
Definition: gps.h:142
uint8_t multi_gps_mode
Definition: gps.c:85
uint16_t refStationId
Definition: gps.h:125
position in UTM coordinates
#define GpsFixValid()
Definition: gps.h:43