Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Device independent GPS code. More...
#include "modules/core/abi.h"
#include "modules/gps/gps.h"
#include "led.h"
#include "modules/core/settings.h"
#include "generated/settings.h"
#include "math/pprz_geodetic_wgs84.h"
#include "math/pprz_geodetic.h"
#include "modules/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_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... | |
bool | gps_fix_valid (void) |
Check if GPS fix is valid. 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... | |
void | gps_parse_GPS_INJECT (uint8_t *buf) |
void | gps_parse_RTCM_INJECT (uint8_t *buf) |
struct LlaCoor_f | lla_float_from_gps (struct GpsState *gps_s) |
Get GPS lla (float) Converted on the fly if not available. More... | |
struct LlaCoor_i | lla_int_from_gps (struct GpsState *gps_s) |
Get GPS lla (integer) Converted on the fly if not available. More... | |
struct EcefCoor_f | ecef_float_from_gps (struct GpsState *gps_s) |
Get GPS ecef pos (float) Converted on the fly if not available. More... | |
struct EcefCoor_i | ecef_int_from_gps (struct GpsState *gps_s) |
Get GPS ecef pos (integer) Converted on the fly if not available. More... | |
struct EcefCoor_f | ecef_vel_float_from_gps (struct GpsState *gps_s) |
Get GPS ecef velocity (float) Converted on the fly if not available. More... | |
struct EcefCoor_i | ecef_vel_int_from_gps (struct GpsState *gps_s) |
Get GPS ecef velocity (integer) Converted on the fly if not available. More... | |
struct NedCoor_f | ned_vel_float_from_gps (struct GpsState *gps_s) |
Get GPS ned velocity (float) Converted on the fly if not available. More... | |
struct NedCoor_i | ned_vel_int_from_gps (struct GpsState *gps_s) |
Get GPS ned velocity (integer) Converted on the fly if not available. 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 |
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.
struct EcefCoor_f ecef_float_from_gps | ( | struct GpsState * | gps_s | ) |
Get GPS ecef pos (float) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
References gps_inject_data().
struct EcefCoor_i ecef_int_from_gps | ( | struct GpsState * | gps_s | ) |
Get GPS ecef pos (integer) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
Referenced by gps_cb(), ins_float_invariant_update_gps(), ins_int_update_gps(), and ins_reset_local_origin().
struct EcefCoor_f ecef_vel_float_from_gps | ( | struct GpsState * | gps_s | ) |
Get GPS ecef velocity (float) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
Referenced by gps_cb(), and ins_float_invariant_update_gps().
struct EcefCoor_i ecef_vel_int_from_gps | ( | struct GpsState * | gps_s | ) |
Get GPS ecef velocity (integer) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
Referenced by gps_cb(), and ins_int_update_gps().
Definition at line 295 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 611 of file gps.c.
References month_days.
Referenced by gps_week_number().
bool gps_fix_valid | ( | void | ) |
Check if GPS fix is valid.
If GPS_FIX_TIMEOUT is configured, check for 3D fix with timeout, otherwise, returns the last value from GPS module
Definition at line 282 of file gps.c.
References GpsState::fix, get_sys_time_float(), gps, GPS_FIX_3D, and gps_time_since_last_3dfix().
void gps_init | ( | void | ) |
initialize the global GPS state
Definition at line 321 of file gps.c.
References ABI_BROADCAST, GpsState::cacc, DefaultPeriodic, GpsState::fix, gpio_setup_output(), gps, gps_cb(), gps_ev, GPS_FIX_NONE, GPS_POWER_GPIO, gps_relposned, GpsState::hacc, GpsState::last_3dfix_ticks, GpsState::last_3dfix_time, GpsState::last_msg_ticks, GpsState::last_msg_time, LED_OFF, multi_gps_mode, MULTI_GPS_MODE, preflight_check_register(), register_periodic_telemetry(), GpsRelposNED::relPosHeading, send_gps(), send_gps_int(), send_gps_lla(), send_gps_rtk(), 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 390 of file gps.c.
Referenced by ecef_float_from_gps(), and gps_parse_GPS_INJECT().
void gps_parse_GPS_INJECT | ( | uint8_t * | buf | ) |
Definition at line 396 of file gps.c.
References gps_inject_data().
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 266 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 gps_ubx_periodic_check().
Convert time in sys_time ticks to GPS time of week.
The resolution is sys_time.resolution
Definition at line 365 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(), target_parse_target_pos(), 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 621 of file gps.c.
References gps_day_number().
Referenced by gps_ubx_parse_nav_pvt().
Get GPS lla (integer) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
Referenced by gps_cb(), ins_reset_altitude_ref(), and ins_reset_local_origin().
Get GPS ned velocity (float) Converted on the fly if not available.
[in] | gps_s | pointer to the gps structure |
Definition at line 409 of file gps.c.
Referenced by gps_cb(), ins_alt_float_update_gps(), and ins_float_invariant_update_gps().
|
static |
Definition at line 137 of file gps.c.
References GpsState::course, course, dev, UtmCoor_i::east, GpsState::fix, gps, GpsState::gspeed, GpsState::hmsl, msg, 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 177 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, msg, 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 205 of file gps.c.
References LlaCoor_i::alt, GpsState::course, course, dev, GpsState::fix, gps, GpsState::gspeed, GpsState::hmsl, LlaCoor_i::lat, GpsState::lla_pos, LlaCoor_i::lon, msg, GpsState::ned_vel, GpsState::tow, GpsState::week, and NedCoor_i::z.
Referenced by gps_init().
|
static |
Definition at line 163 of file gps.c.
References GpsRelposNED::accD, GpsRelposNED::accE, GpsRelposNED::accN, GpsRelposNED::carrSoln, dev, 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 228 of file gps.c.
References dev, 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 109 of file gps.c.
References dev, 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 121 of file gps.c.
References SVinfo::cno, dev, 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 97 of file gps.c.
References SVinfo::azim, SVinfo::cno, dev, 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 409 of file gps.c.
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 409 of file gps.c.
Referenced by send_gps().
struct GpsState gps |
global GPS state
Definition at line 1 of file gps.c.
Referenced by airspeed_ets_read_event(), alt_filter_periodic(), apogee_baro_event(), ArduIMU_periodicGPS(), autopilot_failsafe_checks(), baro_sim_periodic(), calculate_new_heading(), cloud_sensor_callback(), dc_send_shot_position(), draw_osd(), error_output(), formation_flight(), generic_com_periodic(), geo_mag_event(), get_fix_mode(), gps_cb(), gps_fix_valid(), gps_init(), gps_periodic_check(), gps_sim_init(), gps_sim_publish(), gps_time_since_last_3dfix(), gps_vectornav_init(), gsm_send_report_continue(), hff_update_gps(), home_direction(), 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_send_data(), mf_daq_send_report(), mf_ptu_periodic(), nps_sensor_gps_init(), nps_sensor_gps_run_step(), parse_xsens_msg(), potential_task(), push_gps_to_vision(), put_alt(), send_cloud_sensor_data(), send_fp_min(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_sol(), send_minimal_com(), send_status(), send_svinfo(), send_svinfo_available(), send_svinfo_id(), snav_on_time(), tcas_periodic_task_1Hz(), temod_event(), thd_startlog(), and update_geoid_height().
|
static |
Definition at line 294 of file gps.c.
Referenced by gps_init().
struct GpsRelposNED gps_relposned |
Definition at line 1 of file gps.c.
Referenced by gps_cb(), gps_init(), gps_ubx_parse_nav_relposned(), and send_gps_rtk().
struct GpsTimeSync gps_time_sync |
Definition at line 1 of file gps.c.
Referenced by gps_cb(), and gps_tow_from_sys_ticks().
|
static |
GPS week number roll-over workaround application note.
Definition at line 603 of file gps.c.
Referenced by gps_day_number().
uint8_t multi_gps_mode |
Definition at line 77 of file gps.c.
Referenced by gps_init().