|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
44 #include "generated/settings.h"
49 #error "PRIMARY_GPS not set!"
55 PRINT_CONFIG_VAR(SECONDARY_GPS)
61 #ifndef GPS_POWER_GPIO_ON
62 #define GPS_POWER_GPIO_ON gpio_set
66 #define MSEC_PER_WEEK (1000*60*60*24*7)
67 #define TIME_TO_SWITCH 5000 //ten s in ms
81 #if PERIODIC_TELEMETRY
88 pprz_msg_send_SVINFO(trans,
dev, AC_ID, &svid,
124 static void send_gps(
struct transport_tx *trans,
struct link_device *
dev)
130 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
132 struct pprzlink_msg
msg;
135 msg.sender_id = AC_ID;
136 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
137 msg.component_id = 0;
138 pprzlink_msg_send_GPS(&
msg,
140 pprz_msg_send_GPS(trans,
dev, AC_ID,
152 pprz_msg_send_GPS_RTK(trans,
dev, AC_ID,
166 pprz_msg_send_GPS_RXMRTCM(trans,
dev, AC_ID,
177 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
179 struct pprzlink_msg
msg;
182 msg.sender_id = AC_ID;
183 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
184 msg.component_id = 0;
185 pprzlink_msg_send_GPS_INT(&
msg,
187 pprz_msg_send_GPS_INT(trans,
dev, AC_ID,
208 #if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
210 struct pprzlink_msg
msg;
213 msg.sender_id = AC_ID;
214 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
215 msg.component_id = 0;
216 pprzlink_msg_send_GPS_LLA(&
msg,
218 pprz_msg_send_GPS_LLA(trans,
dev, AC_ID,
236 static uint32_t time_since_last_gps_switch = 0;
241 return GpsId(SECONDARY_GPS);
250 current_gps_id = gps_s->
comp_id;
259 return current_gps_id;
271 current_gps_id = gps_multi_switch(gps_s);
272 if (gps_s->
comp_id == current_gps_id) {
283 uint32_t stamp __attribute__((unused)),
292 current_gps_id = gps_multi_switch(gps_s);
293 if (gps_s->
comp_id == current_gps_id) {
325 #ifdef GPS_POWER_GPIO
335 #if PERIODIC_TELEMETRY
381 uint8_t *data __attribute__((unused)))
406 utm.
alt = gps_s->hmsl / 1000.;
428 utm.
alt = gps_s->hmsl;
445 { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
446 { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
455 uint16_t leap_year = (gps_years % 4 == 0) ? 1 : 0;
459 return gps_years * 365 + ((gps_years - 1) / 4) + 1 + day_of_year;
int32_t lon
in degrees*1e7
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
int32_t alt
in millimeters above WGS84 reference ellipsoid
static const uint16_t month_days[2][13]
GPS week number roll-over workaround application note.
int16_t azim
azimuth in deg
Paparazzi generic macros for geodetic calculations.
static void send_gps_rxmrtcm(struct transport_tx *trans, struct link_device *dev)
int32_t north
in centimeters
void gps_init(void)
initialize the global GPS state
uint8_t flags
bitfield with GPS receiver specific flags
uint32_t tow
GPS time of week in ms.
void utm_of_lla_i(struct UtmCoor_i *utm, struct LlaCoor_i *lla)
Convert a LLA to UTM.
uint8_t qi
quality bitfield (GPS receiver specific)
uint32_t t0_tow
GPS time of week in ms from last message.
static void send_gps_rtk(struct transport_tx *trans, struct link_device *dev)
uint8_t nb_channels
Number of scanned satellites.
static int32_t wgs84_ellipsoid_to_geoid_i(int32_t lat, int32_t lon)
Get WGS84 ellipsoid/geoid separation.
data structure for GPS information
static void send_svinfo(struct transport_tx *trans, struct link_device *dev)
send SVINFO message (regardless of state)
Event structure to store callbacks in a linked list.
uint32_t pacc
position accuracy in cm
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.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
uint32_t sacc
speed accuracy in cm/s
uint32_t vacc
vertical accuracy in cm
#define UTM_COPY(_u1, _u2)
#define GPS_TIMEOUT
GPS timeout in seconds.
struct NedCoor_i ned_vel
speed NED in cm/s
static void send_gps_lla(struct transport_tx *trans, struct link_device *dev)
#define GPS_VALID_POS_LLA_BIT
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
int32_t lat
in degrees*1e7
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
int32_t east
in centimeters
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
uint32_t hacc
horizontal accuracy in cm
uint16_t gps_week_number(uint16_t year, uint8_t month, uint8_t day)
Number of weeks since navigation epoch (6 January 1980)
Device independent GPS code (interface)
static void send_svinfo_id(struct transport_tx *trans, struct link_device *dev, uint8_t svid)
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
uint8_t zone
UTM zone number.
data structure for GPS time sync
static const struct usb_device_descriptor dev
#define GPS_VALID_POS_UTM_BIT
uint8_t svid
Satellite ID.
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint16_t gspeed
norm of 2d ground speed in cm/s
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
data structures for GPS with RTK capabilities
static void send_gps(struct transport_tx *trans, struct link_device *dev)
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
void gps_periodic_check(struct GpsState *gps_s)
Periodic GPS check.
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
uint8_t comp_id
id of current gps
arch independent LED (Light Emitting Diodes) API
static void send_gps_int(struct transport_tx *trans, struct link_device *dev)
static void send_svinfo_available(struct transport_tx *trans, struct link_device *dev)
send SVINFO message if updated.
static void send_gps_sol(struct transport_tx *trans, struct link_device *dev)
uint16_t gps_day_number(uint16_t year, uint8_t month, uint8_t day)
Number of days since navigation epoch (6 January 1980)
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
uint32_t last_msg_time
cpu time in sec at last received GPS message
struct EcefCoor_i ecef_pos
position in ECEF in cm
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
struct GpsRelposNED gps_relposned
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
void WEAK gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
Default parser for GPS injected data.
position in UTM coordinates Units: meters
uint8_t num_sv
number of sat in fix
int32_t hmsl
height above mean sea level (MSL) in mm
uint32_t t0_ticks
hw clock ticks when GPS message is received
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
#define GPS_MODE_SECONDARY
int8_t elev
elevation in deg
uint16_t pdop
position dilution of precision scaled by 100
position in UTM coordinates
uint32_t cacc
course accuracy in rad*1e7
volatile uint32_t nb_sec
full seconds since startup
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
#define ABI_BROADCAST
Broadcast address.
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
struct GpsState gps
global GPS state
#define GPS_FIX_NONE
No GPS fix.
#define GPS_FIX_3D
3D GPS fix
#define DefaultPeriodic
Set default periodic telemetry.
#define GPS_VALID_HMSL_BIT
static uint32_t msec_of_sys_time_ticks(uint32_t ticks)
struct GpsTimeSync gps_time_sync
#define UTM_FLOAT_OF_BFP(_o, _i)
uint8_t zone
UTM zone number.