Paparazzi UAS  v5.8.2_stable-0-g6260b7c
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"
33 
34 #include "mcu_periph/sys_time.h"
35 
36 /* GPS model specific implementation or sim */
37 #ifdef GPS_TYPE_H
38 #include GPS_TYPE_H
39 #endif
40 
41 #define GPS_FIX_NONE 0x00
42 #define GPS_FIX_2D 0x02
43 #define GPS_FIX_3D 0x03
44 #define GPS_FIX_DGPS 0x04
45 #define GPS_FIX_RTK 0x05
46 
47 #define GpsFixValid() (gps.fix >= GPS_FIX_3D)
48 #if USE_GPS
49 #define GpsIsLost() !GpsFixValid()
50 #endif
51 
52 #ifndef GPS_NB_CHANNELS
53 #define GPS_NB_CHANNELS 1
54 #endif
55 
57 struct SVinfo {
64 };
65 
67 struct GpsState {
69  struct LlaCoor_i lla_pos;
70  struct UtmCoor_i utm_pos;
73  struct NedCoor_i ned_vel;
85 
88 
94 };
95 
97 struct GpsTimeSync {
101 };
102 
104 extern struct GpsState gps;
105 
107 extern void gps_init(void);
108 
110 extern void gps_impl_init(void);
111 
113 extern void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data);
114 
116 #ifndef GPS_TIMEOUT
117 #define GPS_TIMEOUT 2
118 #endif
119 
120 static inline bool_t gps_has_been_good(void)
121 {
122  static bool_t gps_had_valid_fix = FALSE;
123  if (GpsFixValid()) {
124  gps_had_valid_fix = TRUE;
125  }
126  return gps_had_valid_fix;
127 }
128 
129 
133 extern void gps_periodic_check(void);
134 
139 #define gps_Reset(_val) { \
140  }
141 
142 
143 /*
144  * For GPS time synchronizaiton...
145  */
146 extern struct GpsTimeSync gps_time_sync;
147 
153 extern uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks);
154 
155 #endif /* GPS_H */
uint8_t qi
quality bitfield (GPS receiver specific)
Definition: gps.h:60
unsigned short uint16_t
Definition: types.h:16
uint32_t t0_tow
GPS time of week in ms from last message.
Definition: gps.h:98
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:173
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
Definition: gps.h:87
int16_t azim
azimuth in deg
Definition: gps.h:63
uint32_t pacc
position accuracy in cm
Definition: gps.h:77
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:86
uint32_t t0_ticks
hw clock ticks when GPS message is received
Definition: gps.h:100
vector in EarthCenteredEarthFixed coordinates
void gps_impl_init(void)
GPS model specific init implementation.
Definition: gps_datalink.c:62
uint16_t week
GPS week.
Definition: gps.h:83
void gps_periodic_check(void)
Periodic GPS check.
Definition: gps.c:166
#define GPS_NB_CHANNELS
Definition: gps.h:53
void gps_init(void)
initialize the global GPS state
Definition: gps.c:135
uint16_t reset
hotstart, warmstart, coldstart
Definition: gps.h:93
static bool_t gps_has_been_good(void)
Definition: gps.h:120
uint8_t svid
Satellite ID.
Definition: gps.h:58
vector in Latitude, Longitude and Altitude
uint16_t speed_3d
norm of 3d speed in cm/s
Definition: gps.h:75
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:70
void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
GPS packet injection (default empty)
Definition: gps_piksi.c:384
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
Definition: gps.h:89
int8_t elev
elevation in deg
Definition: gps.h:62
struct GpsState gps
global GPS state
Definition: gps.c:41
#define FALSE
Definition: std.h:5
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:78
uint32_t last_msg_time
cpu time in sec at last received GPS message
Definition: gps.h:92
uint32_t cacc
course accuracy in rad*1e7
Definition: gps.h:79
struct GpsTimeSync gps_time_sync
Definition: gps.c:43
#define TRUE
Definition: std.h:4
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:71
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:61
Architecture independent timing functions.
data structure for GPS information
Definition: gps.h:67
uint32_t tow
GPS time of week in ms.
Definition: gps.h:84
data structure for Space Vehicle Information of a single satellite
Definition: gps.h:57
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:80
unsigned long uint32_t
Definition: types.h:18
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:68
signed short int16_t
Definition: types.h:17
Paparazzi fixed point math for geodetic calculations.
signed long int32_t
Definition: types.h:19
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
Definition: gps.h:90
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:76
vector in North East Down coordinates
int32_t t0_tow_frac
fractional ns remainder of tow [ms], range -500000 .. 500000
Definition: gps.h:99
uint8_t flags
bitfield with GPS receiver specific flags
Definition: gps.h:59
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
Definition: gps.h:91
uint8_t num_sv
number of sat in fix
Definition: gps.h:81
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:74
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:72
data structure for GPS time sync
Definition: gps.h:97
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:69
signed char int8_t
Definition: types.h:15
uint8_t fix
status of fix
Definition: gps.h:82
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:73
position in UTM coordinates
#define GpsFixValid()
Definition: gps.h:47