Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
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 | __GpsId(_x) _x ## _ID |
#define | _GpsId(_x) __GpsId(_x) |
#define | GpsId(_x) _GpsId(_x) |
#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_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... | |
Variables | |
struct GpsState | gps |
global GPS state More... | |
struct GpsTimeSync | gps_time_sync |
uint8_t | multi_gps_mode |
static abi_event | gps_ev |
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 72 of file gps.c.
Referenced by gps_tow_from_sys_ticks().
Definition at line 227 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().
void gps_init | ( | void | ) |
initialize the global GPS state
Definition at line 254 of file gps.c.
References ABI_BROADCAST, GpsState::cacc, DefaultPeriodic, GpsState::fix, gpio_setup_output(), gps, gps_cb(), GPS_FIX_NONE, GPS_POWER_GPIO, GpsState::last_3dfix_ticks, GpsState::last_3dfix_time, GpsState::last_msg_ticks, GpsState::last_msg_time, LED_OFF, MULTI_GPS_MODE, register_periodic_telemetry(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_sol(), send_svinfo(), GpsState::tow, GpsState::valid_fields, and GpsState::week.
Default parser for GPS injected data.
GPS packet injection (default empty)
Definition at line 313 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 209 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.
Convert time in sys_time ticks to GPS time of week.
The resolution is sys_time.resolution
Definition at line 288 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().
|
static |
Definition at line 129 of file gps.c.
References course, GpsState::course, 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 143 of file gps.c.
References LlaCoor_i::alt, GpsState::comp_id, 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 160 of file gps.c.
References LlaCoor_i::alt, course, GpsState::course, 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 172 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 101 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 113 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 89 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 321 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 347 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 75 of file gps.c.
Referenced by airspeed_ets_read_event(), alt_filter_periodic(), apogee_baro_event(), ArduIMU_periodicGPS(), b2_hff_update_gps(), baro_sim_periodic(), dc_send_shot_position(), 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(), humid_sht_periodic(), ins_reset_altitude_ref(), ins_reset_local_origin(), ins_reset_utm_zone(), ins_vectornav_propagate(), ins_vectornav_read_message(), 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(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_sol(), send_status(), send_svinfo(), send_svinfo_available(), send_svinfo_id(), send_vn_info(), sim_use_gps_pos(), snav_on_time(), tcas_periodic_task_1Hz(), temod_event(), thd_startlog(), update_geoid_height(), and vertical_ctrl_module_run().
struct GpsTimeSync gps_time_sync |
Definition at line 77 of file gps.c.
Referenced by gps_cb(), and gps_tow_from_sys_ticks().