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;
456 uint16_t day_of_year = month_days[leap_year][month - 1] + day;
459 return gps_years * 365 + ((gps_years - 1) / 4) + 1 + day_of_year;
uint8_t qi
quality bitfield (GPS receiver specific)
static void send_gps_int(struct transport_tx *trans, struct link_device *dev)
Event structure to store callbacks in a linked list.
uint32_t t0_tow
GPS time of week in ms from last message.
int32_t north
in centimeters
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
int16_t azim
azimuth in deg
uint32_t pacc
position accuracy in cm
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
static void send_svinfo_id(struct transport_tx *trans, struct link_device *dev, uint8_t svid)
uint8_t nb_channels
Number of scanned satellites.
uint32_t t0_ticks
hw clock ticks when GPS message is received
Periodic telemetry system header (includes downlink utility and generated code).
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
uint32_t hacc
horizontal accuracy in cm
Some architecture independent helper functions for GPIOs.
static uint32_t msec_of_sys_time_ticks(uint32_t ticks)
Main include for ABI (AirBorneInterface).
uint32_t vacc
vertical accuracy in cm
static void send_gps_sol(struct transport_tx *trans, struct link_device *dev)
static void send_gps(struct transport_tx *trans, struct link_device *dev)
#define UTM_FLOAT_OF_BFP(_o, _i)
position in UTM coordinates Units: meters
int32_t east
in centimeters
uint8_t svid
Satellite ID.
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
#define GPS_FIX_3D
3D GPS fix
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
int8_t elev
elevation in deg
int32_t alt
in millimeters above WGS84 reference ellipsoid
uint32_t sacc
speed accuracy in cm/s
uint32_t last_msg_time
cpu time in sec at last received GPS message
uint32_t cacc
course accuracy in rad*1e7
uint8_t zone
UTM zone number.
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.
static void send_svinfo_available(struct transport_tx *trans, struct link_device *dev)
send SVINFO message if updated.
int32_t hmsl
height above mean sea level (MSL) in mm
void WEAK gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
Default parser for GPS injected data.
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
data structure for GPS information
static void send_gps_lla(struct transport_tx *trans, struct link_device *dev)
uint32_t tow
GPS time of week in ms.
#define GPS_FIX_NONE
No GPS fix.
Device independent GPS code (interface)
uint16_t pdop
position dilution of precision scaled by 100
static void send_gps_rxmrtcm(struct transport_tx *trans, struct link_device *dev)
struct EcefCoor_i ecef_pos
position in ECEF in cm
#define GPS_VALID_HMSL_BIT
#define DefaultPeriodic
Set default periodic telemetry.
int32_t lon
in degrees*1e7
uint16_t gps_week_number(uint16_t year, uint8_t month, uint8_t day)
Number of weeks since navigation epoch (6 January 1980)
uint16_t gps_day_number(uint16_t year, uint8_t month, uint8_t day)
Number of days since navigation epoch (6 January 1980)
void utm_of_lla_i(struct UtmCoor_i *utm, struct LlaCoor_i *lla)
Convert a LLA to UTM.
uint8_t zone
UTM zone number.
struct GpsRelposNED gps_relposned
static const struct usb_device_descriptor dev
static void send_gps_rtk(struct transport_tx *trans, struct link_device *dev)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
Paparazzi generic macros for geodetic calculations.
static void send_svinfo(struct transport_tx *trans, struct link_device *dev)
send SVINFO message (regardless of state)
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
API to get/set the generic vehicle states.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Persistent settings interface.
uint8_t comp_id
id of current gps
volatile uint32_t nb_sec
full seconds since startup
#define GPS_MODE_SECONDARY
data structures for GPS with RTK capabilities
uint8_t flags
bitfield with GPS receiver specific flags
struct GpsTimeSync gps_time_sync
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
#define GPS_VALID_POS_LLA_BIT
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
uint8_t num_sv
number of sat in fix
arch independent LED (Light Emitting Diodes) API
#define ABI_BROADCAST
Broadcast address.
uint16_t gspeed
norm of 2d ground speed in cm/s
static const uint16_t month_days[2][13]
GPS week number roll-over workaround application note.
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
data structure for GPS time sync
#define GPS_TIMEOUT
GPS timeout in seconds.
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
int32_t lat
in degrees*1e7
#define GPS_VALID_POS_UTM_BIT
struct NedCoor_i ned_vel
speed NED in cm/s
struct GpsState gps
global GPS state
void gps_init(void)
initialize the global GPS state
static int32_t wgs84_ellipsoid_to_geoid_i(int32_t lat, int32_t lon)
Get WGS84 ellipsoid/geoid separation.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void gps_periodic_check(struct GpsState *gps_s)
Periodic GPS check.
position in UTM coordinates
#define UTM_COPY(_u1, _u2)