Paparazzi UAS
v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
|
Device independent GPS code. More...
#include "subsystems/abi.h"
#include "subsystems/gps.h"
#include "led.h"
#include "subsystems/settings.h"
#include "generated/settings.h"
#include "math/pprz_geodetic_wgs84.h"
#include "math/pprz_geodetic.h"
#include "subsystems/datalink/telemetry.h"
#include "state.h"
Go to the source code of this file.
Macros | |
#define | MSEC_PER_WEEK (1000*60*60*24*7) |
#define | TIME_TO_SWITCH 5000 |
Functions | |
static void | send_svinfo_id (struct transport_tx *trans, struct link_device *dev, uint8_t svid) |
static void | send_svinfo (struct transport_tx *trans, struct link_device *dev) |
send SVINFO message (regardless of state) More... | |
static void | send_svinfo_available (struct transport_tx *trans, struct link_device *dev) |
send SVINFO message if updated. More... | |
static void | send_gps (struct transport_tx *trans, struct link_device *dev) |
static void | send_gps_rtk (struct transport_tx *trans, struct link_device *dev) |
static void | send_gps_rxmrtcm (struct transport_tx *trans, struct link_device *dev) |
static void | send_gps_int (struct transport_tx *trans, struct link_device *dev) |
static void | send_gps_lla (struct transport_tx *trans, struct link_device *dev) |
static void | send_gps_sol (struct transport_tx *trans, struct link_device *dev) |
void | gps_periodic_check (struct GpsState *gps_s) |
Periodic GPS check. More... | |
static void | gps_cb (uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s) |
void | gps_init (void) |
initialize the global GPS state More... | |
uint32_t | gps_tow_from_sys_ticks (uint32_t sys_ticks) |
Convert time in sys_time ticks to GPS time of week. More... | |
void WEAK | gps_inject_data (uint8_t packet_id, uint8_t length, uint8_t *data) |
Default parser for GPS injected data. More... | |
struct UtmCoor_f | utm_float_from_gps (struct GpsState *gps_s, uint8_t zone) |
Convenience functions to get utm position from GPS state. More... | |
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. More... | |
uint16_t | gps_day_number (uint16_t year, uint8_t month, uint8_t day) |
Number of days since navigation epoch (6 January 1980) More... | |
uint16_t | gps_week_number (uint16_t year, uint8_t month, uint8_t day) |
Number of weeks since navigation epoch (6 January 1980) More... | |
Variables | |
struct GpsState | gps |
global GPS state More... | |
struct GpsTimeSync | gps_time_sync |
struct GpsRelposNED | gps_relposned |
struct RtcmMan | rtcm_man |
uint8_t | multi_gps_mode |
static abi_event | gps_ev |
static const uint16_t | month_days [2][13] |
GPS week number roll-over workaround application note. More... | |
Device independent GPS code.
This provides some general GPS functions and handles the selection of the currently active GPS (if multiple ones are used).
Each GPS implementation sends a GPS message via ABI for each new measurement, which can be received by any other part (either from all or only one specific GPS).
To make it easy to switch to the currently best (or simply the preferred) GPS at runtime, the multi_gps_mode can be set to GPS_MODE_PRIMARY, GPS_MODE_SECONDARY or GPS_MODE_AUTO. This re-sends the GPS message of the "selected" GPS with GPS_MULTI_ID as sender id. In the (default) GPS_MODE_AUTO mode, the GPS with the best fix is selected.
The global gps struct is also updated from the "selected" GPS and used to send the normal GPS telemetry messages.
Definition in file gps.c.
#define MSEC_PER_WEEK (1000*60*60*24*7) |
Definition at line 66 of file gps.c.
Referenced by gps_tow_from_sys_ticks().
Definition at line 282 of file gps.c.
References GpsState::comp_id, get_sys_time_usec(), gps, GPS_MULTI_ID, gps_time_sync, sys_time::nb_tick, GpsTimeSync::t0_ticks, GpsTimeSync::t0_tow, and GpsState::tow.
Referenced by gps_init().
Number of days since navigation epoch (6 January 1980)
[in] | year | current year |
[in] | month | current month |
[in] | day | current day |
Definition at line 452 of file gps.c.
Referenced by gps_week_number().
void gps_init | ( | void | ) |
initialize the global GPS state
Definition at line 308 of file gps.c.
References ABI_BROADCAST, GpsState::cacc, RtcmMan::Cnt105, RtcmMan::Cnt177, RtcmMan::Cnt187, RtcmMan::Crc105, RtcmMan::Crc177, RtcmMan::Crc187, DefaultPeriodic, GpsState::fix, gpio_setup_output(), gps, gps_cb(), GPS_FIX_NONE, GPS_POWER_GPIO, GpsState::hacc, GpsState::last_3dfix_ticks, GpsState::last_3dfix_time, GpsState::last_msg_ticks, GpsState::last_msg_time, LED_OFF, MULTI_GPS_MODE, register_periodic_telemetry(), rtcm_man, send_gps(), send_gps_int(), send_gps_lla(), send_gps_rtk(), send_gps_rxmrtcm(), send_gps_sol(), send_svinfo(), GpsState::tow, GpsState::vacc, GpsState::valid_fields, and GpsState::week.
Default parser for GPS injected data.
GPS packet injection (default empty)
Definition at line 380 of file gps.c.
References gps_piksi_write(), and sbp_state.
void gps_periodic_check | ( | struct GpsState * | gps_s | ) |
Periodic GPS check.
Marks GPS as lost when no GPS message was received for GPS_TIMEOUT seconds
Definition at line 264 of file gps.c.
References GpsState::comp_id, GpsState::fix, gps, GPS_FIX_NONE, GPS_TIMEOUT, GpsState::last_msg_time, and sys_time::nb_sec.
Referenced by dw1000_arduino_periodic(), and intermcu_periodic().
Convert time in sys_time ticks to GPS time of week.
The resolution is sys_time.resolution
Definition at line 355 of file gps.c.
References gps_time_sync, msec_of_sys_time_ticks(), MSEC_PER_WEEK, GpsTimeSync::t0_ticks, and GpsTimeSync::t0_tow.
Referenced by acInfoSetPositionEnu_f(), acInfoSetPositionEnu_i(), acInfoSetPositionLla_f(), acInfoSetPositionLla_i(), acInfoSetPositionUtm_f(), acInfoSetPositionUtm_i(), acInfoSetVelocityEnu_f(), acInfoSetVelocityEnu_i(), parse_acinfo_dl(), trigger_ext_periodic(), and windturbine_periodic().
Number of weeks since navigation epoch (6 January 1980)
[in] | year | current year |
[in] | month | current month |
[in] | day | current day |
Definition at line 462 of file gps.c.
References gps_day_number().
Referenced by gps_ubx_parse_nav_pvt().
|
static |
Definition at line 124 of file gps.c.
References course, GpsState::course, dev, UtmCoor_i::east, GpsState::fix, gps, GpsState::gspeed, GpsState::hmsl, GpsState::ned_vel, UtmCoor_i::north, send_svinfo_available(), GpsState::tow, utm_int_from_gps(), GpsState::week, NedCoor_i::z, and UtmCoor_i::zone.
Referenced by gps_init().
|
static |
Definition at line 175 of file gps.c.
References LlaCoor_i::alt, GpsState::comp_id, dev, GpsState::ecef_pos, GpsState::ecef_vel, GpsState::fix, gps, GpsState::hmsl, LlaCoor_i::lat, GpsState::lla_pos, LlaCoor_i::lon, GpsState::num_sv, GpsState::pacc, GpsState::pdop, GpsState::sacc, send_svinfo_available(), GpsState::tow, EcefCoor_i::x, EcefCoor_i::y, and EcefCoor_i::z.
Referenced by gps_init().
|
static |
Definition at line 203 of file gps.c.
References LlaCoor_i::alt, course, GpsState::course, dev, GpsState::fix, gps, GpsState::gspeed, GpsState::hmsl, LlaCoor_i::lat, GpsState::lla_pos, LlaCoor_i::lon, GpsState::ned_vel, GpsState::tow, GpsState::week, and NedCoor_i::z.
Referenced by gps_init().
|
static |
Definition at line 150 of file gps.c.
References GpsRelposNED::accD, GpsRelposNED::accE, GpsRelposNED::accN, GpsRelposNED::carrSoln, GpsRelposNED::diffSoln, GpsRelposNED::gnssFixOK, gps_relposned, GpsRelposNED::iTOW, GpsRelposNED::refStationId, GpsRelposNED::relPosD, GpsRelposNED::relPosE, GpsRelposNED::relPosHPD, GpsRelposNED::relPosHPE, GpsRelposNED::relPosHPN, GpsRelposNED::relPosN, and GpsRelposNED::relPosValid.
Referenced by gps_init().
|
static |
Definition at line 164 of file gps.c.
References RtcmMan::Cnt105, RtcmMan::Cnt177, RtcmMan::Cnt187, RtcmMan::Crc105, RtcmMan::Crc177, RtcmMan::Crc187, and rtcm_man.
Referenced by gps_init().
|
static |
Definition at line 226 of file gps.c.
References gps, GpsState::num_sv, GpsState::pacc, GpsState::pdop, and GpsState::sacc.
Referenced by gps_init().
|
static |
send SVINFO message (regardless of state)
Definition at line 96 of file gps.c.
References gps, GpsState::nb_channels, and send_svinfo_id().
Referenced by gps_init().
|
inlinestatic |
send SVINFO message if updated.
send SVINFO for all satellites while no GPS fix, after 3D fix, send avialable sats only when there is new information
Definition at line 108 of file gps.c.
References SVinfo::cno, GpsState::fix, gps, GPS_FIX_3D, GPS_NB_CHANNELS, GpsState::nb_channels, send_svinfo_id(), and GpsState::svinfos.
Referenced by send_gps(), and send_gps_int().
|
static |
Definition at line 84 of file gps.c.
References SVinfo::azim, SVinfo::cno, SVinfo::elev, SVinfo::flags, gps, GPS_NB_CHANNELS, SVinfo::qi, SVinfo::svid, and GpsState::svinfos.
Referenced by send_svinfo(), and send_svinfo_available().
Convenience functions to get utm position from GPS state.
Convenience function to get utm position in float from GPS structure.
Definition at line 390 of file gps.c.
References UtmCoor_f::alt, UtmCoor_f::east, GPS_VALID_HMSL_BIT, GPS_VALID_POS_LLA_BIT, GPS_VALID_POS_UTM_BIT, UTM_FLOAT_OF_BFP, utm_of_lla_i(), wgs84_ellipsoid_to_geoid_i(), UtmCoor_f::zone, and UtmCoor_i::zone.
Referenced by gps_cb(), ins_alt_float_update_gps(), ins_float_invariant_update_gps(), and ins_reset_local_origin().
Convenience function to get utm position in int from GPS structure.
Beware that altitude is initialized to zero but not set to the correct value
[in] | gps_s | pointer to the gps structure |
[in] | zone | set the utm zone in which the position should be computed, 0 to try to get it automatically from lla position |
Definition at line 415 of file gps.c.
References UtmCoor_i::alt, UtmCoor_i::east, GPS_VALID_HMSL_BIT, GPS_VALID_POS_LLA_BIT, GPS_VALID_POS_UTM_BIT, UTM_COPY, utm_of_lla_i(), wgs84_ellipsoid_to_geoid_i(), and UtmCoor_i::zone.
Referenced by send_gps().
struct GpsState gps |
global GPS state
Definition at line 69 of file gps.c.
Referenced by airspeed_ets_read_event(), alt_filter_periodic(), apogee_baro_event(), ArduIMU_periodicGPS(), baro_sim_periodic(), dc_send_shot_position(), e_identification_fr_periodic(), error_output(), formation_flight(), generic_com_periodic(), geo_mag_event(), get_fix_mode(), gps_cb(), gps_init(), gps_periodic_check(), gps_sim_hitl_event(), gps_sim_hitl_init(), gps_sim_init(), gps_sim_publish(), gps_vectornav_init(), gsm_send_report_continue(), gx3_packet_read_message(), hff_update_gps(), humid_sht_periodic(), ins_reset_altitude_ref(), ins_reset_local_origin(), ins_reset_utm_zone(), ins_vectornav_monitor(), ins_vectornav_propagate(), ins_vectornav_set_pacc(), ins_vectornav_set_sacc(), mavlink_send_gps_raw_int(), mavlink_send_gps_status(), meteo_stick_periodic(), mf_daq_send_report(), mf_ptu_periodic(), parse_xsens_msg(), potential_task(), push_gps_to_vision(), put_alt(), send_fp_min(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_sol(), send_status(), send_svinfo(), send_svinfo_available(), send_svinfo_id(), sim_use_gps_pos(), snav_on_time(), tcas_periodic_task_1Hz(), temod_event(), thd_startlog(), and update_geoid_height().
struct GpsRelposNED gps_relposned |
Definition at line 71 of file gps.c.
Referenced by gps_ubx_parse_nav_relposned(), and send_gps_rtk().
struct GpsTimeSync gps_time_sync |
Definition at line 70 of file gps.c.
Referenced by gps_cb(), and gps_tow_from_sys_ticks().
|
static |
struct RtcmMan rtcm_man |
Definition at line 72 of file gps.c.
Referenced by gps_init(), gps_ubx_parse_rxm_rtcm(), and send_gps_rxmrtcm().