|
Paparazzi UAS v7.1_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 | GPS_RELPOS_MAX 3 |
| #define | MSEC_PER_WEEK (1000*60*60*24*7) |
| #define | TIME_TO_SWITCH 5000 |
Functions | |
| void | gps_periodic_fix_counter (void) |
| Increment periodic counter. | |
| 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) | |
| static void | send_svinfo_available (struct transport_tx *trans, struct link_device *dev) |
| send SVINFO message if updated. | |
| static void | send_gps (struct transport_tx *trans, struct link_device *dev) |
| static void | send_gps_relpos (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. | |
| bool | gps_fix_valid (void) |
| Check if GPS fix is valid. | |
| static void | gps_cb (uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s) |
| static void | gps_relpos_cb (uint8_t sender_id, uint32_t stamp, struct RelPosNED *relpos) |
| void | gps_init (void) |
| initialize the global GPS state | |
| uint32_t | gps_tow_from_sys_ticks (uint32_t sys_ticks) |
| Convert time in sys_time ticks to GPS time of week. | |
| void WEAK | gps_inject_data (uint8_t packet_id, uint8_t length, uint8_t *data) |
| Default parser for GPS injected data. | |
| 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. | |
| struct LlaCoor_i | lla_int_from_gps (struct GpsState *gps_s) |
| Get GPS lla (integer) Converted on the fly if not available. | |
| struct EcefCoor_f | ecef_float_from_gps (struct GpsState *gps_s) |
| Get GPS ecef pos (float) Converted on the fly if not available. | |
| struct EcefCoor_i | ecef_int_from_gps (struct GpsState *gps_s) |
| Get GPS ecef pos (integer) Converted on the fly if not available. | |
| struct EcefCoor_f | ecef_vel_float_from_gps (struct GpsState *gps_s) |
| Get GPS ecef velocity (float) Converted on the fly if not available. | |
| struct EcefCoor_i | ecef_vel_int_from_gps (struct GpsState *gps_s) |
| Get GPS ecef velocity (integer) Converted on the fly if not available. | |
| struct NedCoor_f | ned_vel_float_from_gps (struct GpsState *gps_s) |
| Get GPS ned velocity (float) Converted on the fly if not available. | |
| struct NedCoor_i | ned_vel_int_from_gps (struct GpsState *gps_s) |
| Get GPS ned velocity (integer) Converted on the fly if not available. | |
| struct UtmCoor_f | utm_float_from_gps (struct GpsState *gps_s, uint8_t zone) |
| Convenience functions to get utm position from GPS state. | |
| 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. | |
| uint16_t | gps_day_number (uint16_t year, uint8_t month, uint8_t day) |
| Number of days since navigation epoch (6 January 1980). | |
| uint16_t | gps_week_number (uint16_t year, uint8_t month, uint8_t day) |
| Number of weeks since navigation epoch (6 January 1980). | |
Variables | |
| struct GpsState | gps = {0} |
| global GPS state | |
| static struct RelPosNED | gps_relposned [GPS_RELPOS_MAX] |
| uint8_t | multi_gps_mode |
| int | gps_disable_fix = 0 |
| Disable fix. | |
| static abi_event | gps_ev |
| static abi_event | gps_relpos_ev |
| static const uint16_t | month_days [2][13] |
| GPS week number roll-over workaround application note. | |
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 GPS_RELPOS_MAX 3 |
Definition at line 68 of file gps.c.
Referenced by gps_relpos_cb(), and send_gps_relpos().
| #define MSEC_PER_WEEK (1000*60*60*24*7) |
Definition at line 71 of file gps.c.
Referenced by gps_tow_from_sys_ticks().
| 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 494 of file gps.c.
References ecef_float_from_gps(), ECEF_FLOAT_OF_BFP, and ecef_int_from_gps().
Referenced by ecef_float_from_gps().
| 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 507 of file gps.c.
References ecef_int_from_gps(), ecef_of_lla_i(), GpsState::ecef_pos, GPS_VALID_POS_ECEF_BIT, GPS_VALID_POS_LLA_BIT, GpsState::lla_pos, and GpsState::valid_fields.
Referenced by ecef_float_from_gps(), ecef_int_from_gps(), gps_cb(), gps_cb(), gps_cb(), gps_cb(), ins_float_invariant_reset_ref(), ins_float_invariant_update_gps(), ins_int_update_gps(), ins_module_update_gps(), reset_cb(), reset_cb(), reset_ref(), reset_ref(), reset_ref(), and send_gps_int().
| 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 523 of file gps.c.
References ECEF_FLOAT_OF_BFP, ecef_vel_float_from_gps(), and ecef_vel_int_from_gps().
Referenced by ecef_vel_float_from_gps(), 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 536 of file gps.c.
References ecef_of_ned_vect_i(), GpsState::ecef_pos, GpsState::ecef_vel, ecef_vel_int_from_gps(), GPS_VALID_POS_LLA_BIT, GPS_VALID_VEL_ECEF_BIT, GPS_VALID_VEL_NED_BIT, GpsState::lla_pos, ltp_def_from_ecef_i(), ltp_def_from_lla_i(), GpsState::ned_vel, and GpsState::valid_fields.
Referenced by ecef_vel_float_from_gps(), ecef_vel_int_from_gps(), gps_cb(), gps_cb(), gps_cb(), ins_int_update_gps(), and send_gps_int().
Definition at line 321 of file gps.c.
References GpsState::comp_id, GpsState::fix, get_sys_time_usec(), gps, gps_disable_fix, GPS_FIX_3D, GPS_FIX_NONE, GPS_MULTI_ID, and sys_time_sync_gps().
Number of days since navigation epoch (6 January 1980).
| [in] | year | current year |
| [in] | month | current month |
| [in] | day | current day |
Definition at line 653 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 308 of file gps.c.
References 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 377 of file gps.c.
References ABI_BROADCAST, DefaultPeriodic, gpio_setup_output(), gps, gps_cb(), gps_disable_fix, gps_ev, GPS_FIX_NONE, gps_relpos_cb(), gps_relpos_ev, LED_OFF, MULTI_GPS_MODE, multi_gps_mode, preflight_check_register(), register_periodic_telemetry(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_relpos(), send_gps_sol(), and send_svinfo().
Default parser for GPS injected data.
GPS packet injection (default empty).
Definition at line 432 of file gps.c.
Referenced by gps_parse_GPS_INJECT(), and gps_parse_RTCM_INJECT().
| void gps_parse_GPS_INJECT | ( | uint8_t * | buf | ) |
Definition at line 438 of file gps.c.
References gps_inject_data().
| void gps_parse_RTCM_INJECT | ( | uint8_t * | buf | ) |
Definition at line 451 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 292 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 gps_ubx_periodic_check(), and uwb_positioning_periodic().
| void gps_periodic_fix_counter | ( | void | ) |
Definition at line 361 of file gps.c.
References GPS_RELPOS_MAX, gps_relposned, and RelPosNED::reference_id.
Referenced by gps_init().
Convert time in sys_time ticks to GPS time of week.
The resolution is sys_time.resolution, see also get_sys_time_tow()
Definition at line 421 of file gps.c.
References get_sys_time_tow(), MSEC_PER_WEEK, sys_time::nb_tick, and sys_time::ticks_per_sec.
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 663 of file gps.c.
References gps_day_number().
Referenced by gps_ubx_parse_nav_pvt().
Get GPS lla (float) Converted on the fly if not available.
| [in] | gps_s | pointer to the gps structure |
Definition at line 465 of file gps.c.
References lla_float_from_gps(), LLA_FLOAT_OF_BFP, and lla_int_from_gps().
Referenced by lla_float_from_gps().
Get GPS lla (integer) Converted on the fly if not available.
| [in] | gps_s | pointer to the gps structure |
Definition at line 478 of file gps.c.
References GpsState::ecef_pos, GPS_VALID_POS_ECEF_BIT, GPS_VALID_POS_LLA_BIT, lla_int_from_gps(), lla_of_ecef_i(), GpsState::lla_pos, and GpsState::valid_fields.
Referenced by gps_cb(), ins_float_invariant_reset_ref(), lla_float_from_gps(), lla_int_from_gps(), reset_ref(), reset_ref(), reset_ref(), reset_ref(), reset_vertical_ref(), and reset_vertical_ref().
Get GPS ned velocity (float) Converted on the fly if not available.
| [in] | gps_s | pointer to the gps structure |
Definition at line 558 of file gps.c.
References ned_vel_float_from_gps(), ned_vel_int_from_gps(), and VECT3_FLOAT_OF_CM.
Referenced by gps_cb(), gps_cb(), gps_cb(), gps_cb(), gps_cb(), ins_alt_float_update_gps(), ins_float_invariant_update_gps(), and ned_vel_float_from_gps().
Get GPS ned velocity (integer) Converted on the fly if not available.
| [in] | gps_s | pointer to the gps structure |
Definition at line 571 of file gps.c.
References GpsState::ecef_pos, GpsState::ecef_vel, GPS_VALID_POS_LLA_BIT, GPS_VALID_VEL_ECEF_BIT, GPS_VALID_VEL_NED_BIT, GpsState::lla_pos, ltp_def_from_ecef_i(), ltp_def_from_lla_i(), ned_of_ecef_vect_i(), GpsState::ned_vel, ned_vel_int_from_gps(), and GpsState::valid_fields.
Referenced by ned_vel_float_from_gps(), and ned_vel_int_from_gps().
|
static |
Definition at line 152 of file gps.c.
References course, dev, UtmCoor_i::east, gps, gps_disable_fix, UtmCoor_i::north, send_svinfo_available(), utm_int_from_gps(), and UtmCoor_i::zone.
Referenced by gps_init().
|
static |
Definition at line 200 of file gps.c.
References dev, ecef_int_from_gps(), ecef_vel_int_from_gps(), gps, send_svinfo_available(), EcefCoor_i::x, EcefCoor_i::y, and EcefCoor_i::z.
Referenced by gps_init().
|
static |
|
static |
Definition at line 178 of file gps.c.
References dev, GPS_RELPOS_MAX, gps_relposned, and idx.
Referenced by gps_init().
|
static |
Definition at line 254 of file gps.c.
Referenced by gps_init().
|
static |
send SVINFO message (regardless of state)
Definition at line 124 of file gps.c.
References dev, gps, 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 136 of file gps.c.
References dev, gps, GPS_FIX_3D, GPS_NB_CHANNELS, and send_svinfo_id().
Referenced by send_gps(), and send_gps_int().
|
static |
Definition at line 112 of file gps.c.
References dev, gps, and GPS_NB_CHANNELS.
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 591 of file gps.c.
References UtmCoor_f::alt, GPS_VALID_HMSL_BIT, GPS_VALID_POS_LLA_BIT, GPS_VALID_POS_UTM_BIT, utm_float_from_gps(), UTM_FLOAT_OF_BFP, utm_of_lla_i(), wgs84_ellipsoid_to_geoid_i(), UtmCoor_f::zone, and UtmCoor_i::zone.
Referenced by gps_cb(), gps_cb(), gps_cb(), gps_cb(), ins_alt_float_update_gps(), ins_float_invariant_reset_ref(), ins_float_invariant_update_gps(), reset_ref(), reset_ref(), reset_ref(), and utm_float_from_gps().
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 616 of file gps.c.
References UtmCoor_i::alt, GPS_VALID_HMSL_BIT, GPS_VALID_POS_LLA_BIT, GPS_VALID_POS_UTM_BIT, UTM_COPY, utm_int_from_gps(), utm_of_lla_i(), wgs84_ellipsoid_to_geoid_i(), and UtmCoor_i::zone.
Referenced by send_gps(), and utm_int_from_gps().
| struct GpsState gps = {0} |
global GPS state
Definition at line 74 of file gps.c.
Referenced by airspeed_ets_read_event(), alt_filter_periodic(), ArduIMU_periodicGPS(), autopilot_failsafe_checks(), baro_apogee_event(), baro_sim_periodic(), build_nmea_sentence(), calculate_new_heading(), cloud_sensor_callback(), draw_osd(), error_output(), formation_flight(), generic_com_periodic(), geo_mag_event(), get_fix_mode(), gps_cb(), gps_fix_valid(), gps_init(), gps_nmea_get_system_date_str(), 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_float_invariant_reset_ref(), ins_float_invariant_reset_vertical_ref(), 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(), nav_reset_utm_zone(), nps_sensor_gps_init(), nps_sensor_gps_run_step(), parse_acinfo_dl(), parse_xsens_msg(), potential_task(), push_gps_to_vision(), put_alt(), recover_gps_data(), reset_cb(), reset_ref(), reset_ref(), reset_ref(), reset_ref(), reset_ref(), reset_ref(), reset_vertical_ref(), reset_vertical_ref(), reset_vertical_ref(), reset_vertical_ref(), reset_vertical_ref(), reset_vertical_ref(), send_acinfo_lla(), 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(), sim_overwrite_lidar(), snav_on_time(), tcas_periodic_task_1Hz(), temod_event(), and update_geoid_height().
| int gps_disable_fix = 0 |
Disable fix.
Definition at line 82 of file gps.c.
Referenced by gps_cb(), gps_init(), gps_periodic_fix_counter(), and send_gps().
|
static |
Definition at line 360 of file gps.c.
Referenced by gps_init().
|
static |
Definition at line 75 of file gps.c.
Referenced by gps_relpos_cb(), and send_gps_relpos().
|
static |
GPS week number roll-over workaround application note.
Definition at line 645 of file gps.c.
Referenced by gps_day_number().
| uint8_t multi_gps_mode |
Definition at line 81 of file gps.c.
Referenced by gps_init().