Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
|
Device independent GPS code (interface) More...
#include "std.h"
#include "math/pprz_geodetic_int.h"
#include "math/pprz_geodetic_float.h"
#include "math/pprz_geodetic_double.h"
#include "mcu_periph/sys_time.h"
#include "generated/airframe.h"
Go to the source code of this file.
Data Structures | |
struct | SVinfo |
data structure for Space Vehicle Information of a single satellite More... | |
struct | GpsState |
data structure for GPS information More... | |
struct | GpsTimeSync |
data structure for GPS time sync More... | |
struct | RelPosNED |
Macros | |
#define | GPS_FIX_NONE 0x00 |
No GPS fix. More... | |
#define | GPS_FIX_2D 0x02 |
2D GPS fix More... | |
#define | GPS_FIX_3D 0x03 |
3D GPS fix More... | |
#define | GPS_FIX_DGPS 0x04 |
DGPS fix. More... | |
#define | GPS_FIX_RTK 0x05 |
RTK GPS fix. More... | |
#define | GPS_VALID_POS_ECEF_BIT 0 |
#define | GPS_VALID_POS_LLA_BIT 1 |
#define | GPS_VALID_POS_UTM_BIT 2 |
#define | GPS_VALID_VEL_ECEF_BIT 3 |
#define | GPS_VALID_VEL_NED_BIT 4 |
#define | GPS_VALID_HMSL_BIT 5 |
#define | GPS_VALID_COURSE_BIT 6 |
#define | GPS_NB_CHANNELS 40 |
#define | GPS_MODE_AUTO 0 |
#define | GPS_MODE_PRIMARY 1 |
#define | GPS_MODE_SECONDARY 2 |
#define | MULTI_GPS_MODE GPS_MODE_AUTO |
#define | __GpsId(_x) _x ## _ID |
#define | _GpsId(_x) __GpsId(_x) |
#define | GpsId(_x) _GpsId(_x) |
#define | GpsFixValid() gps_fix_valid() |
#define | GpsIsLost() !GpsFixValid() |
#define | GPS_TIMEOUT 2 |
GPS timeout in seconds in case of communication loss with GPS module. More... | |
Functions | |
void | gps_init (void) |
initialize the global GPS state More... | |
void | gps_inject_data (uint8_t packet_id, uint8_t length, uint8_t *data) |
GPS packet injection (default empty) More... | |
void | gps_parse_GPS_INJECT (uint8_t *buf) |
void | gps_parse_RTCM_INJECT (uint8_t *buf) |
bool | gps_fix_valid (void) |
Check if GPS fix is valid. More... | |
void | gps_periodic_check (struct GpsState *gps_s) |
Periodic GPS check. More... | |
static bool | gps_has_been_good (void) |
static float | gps_time_since_last_3dfix (void) |
Returns the time since last 3D fix in seconds (float) More... | |
uint32_t | gps_tow_from_sys_ticks (uint32_t sys_ticks) |
Convert time in sys_time ticks to GPS time of week. More... | |
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 function to get utm position in float from GPS structure. 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 | |
uint8_t | multi_gps_mode |
struct GpsState | gps |
global GPS state More... | |
struct GpsTimeSync | gps_time_sync |
Device independent GPS code (interface)
Definition in file gps.h.
struct SVinfo |
data structure for Space Vehicle Information of a single satellite
Data Fields | ||
---|---|---|
int16_t | azim | azimuth in deg |
uint8_t | cno | Carrier to Noise Ratio (Signal Strength) in dbHz. |
int8_t | elev | elevation in deg |
uint8_t | flags | bitfield with GPS receiver specific flags |
uint8_t | qi | quality bitfield (GPS receiver specific) |
uint8_t | svid | Satellite ID. |
struct GpsState |
Data Fields | ||
---|---|---|
uint32_t | cacc | course accuracy in rad*1e7 |
uint8_t | comp_id | id of current gps |
int32_t | course | GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north) |
struct EcefCoor_i | ecef_pos | position in ECEF in cm |
struct EcefCoor_i | ecef_vel | speed ECEF in cm/s |
uint8_t | fix | status of fix |
uint16_t | gspeed | norm of 2d ground speed in cm/s |
uint32_t | hacc | horizontal accuracy in cm |
int32_t | hmsl | height above mean sea level (MSL) in mm |
uint32_t | last_3dfix_ticks | cpu time ticks at last valid 3D fix |
uint32_t | last_3dfix_time | cpu time in sec at last valid 3D fix |
uint32_t | last_msg_ticks | cpu time ticks at last received GPS message |
uint32_t | last_msg_time | cpu time in sec at last received GPS message |
struct LlaCoor_i | lla_pos | position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid) |
uint8_t | nb_channels | Number of scanned satellites. |
struct NedCoor_i | ned_vel | speed NED in cm/s |
uint8_t | num_sv | number of sat in fix |
uint32_t | pacc | position accuracy in cm |
uint16_t | pdop | position dilution of precision scaled by 100 |
uint16_t | reset | hotstart, warmstart, coldstart |
uint32_t | sacc | speed accuracy in cm/s |
uint16_t | speed_3d | norm of 3d speed in cm/s |
struct SVinfo | svinfos[GPS_NB_CHANNELS] | holds information from the Space Vehicles (Satellites) |
uint32_t | tow | GPS time of week in ms. |
struct UtmCoor_i | utm_pos | position in UTM (north,east: cm; alt: mm over MSL) |
uint32_t | vacc | vertical accuracy in cm |
uint8_t | valid_fields | bitfield indicating valid fields (GPS_VALID_x_BIT) |
uint16_t | week | GPS week. |
struct GpsTimeSync |
struct RelPosNED |
Data Fields | ||
---|---|---|
double | distance | Relative distance to the reference station in meters. |
float | distance_acc | Distance accuracy in meters. |
float | heading | Relative heading to the reference station in radians. |
float | heading_acc | Heading accuracy in radians. |
struct NedCoor_d | pos | Relative postion to the reference station in meters. |
struct NedCoor_f | pos_acc | Position accuracy in meters. |
uint16_t | reference_id | Reference station identification. |
uint32_t | tow | Time of week (GPS) in ms. |
#define GPS_TIMEOUT 2 |
#define GpsFixValid | ( | ) | gps_fix_valid() |
#define GpsIsLost | ( | ) | !GpsFixValid() |
#define MULTI_GPS_MODE GPS_MODE_AUTO |
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 437 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 437 of file gps.c.
Referenced by gps_cb(), ins_float_invariant_reset_ref(), ins_float_invariant_update_gps(), ins_int_update_gps(), and reset_ref().
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 437 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 437 of file gps.c.
Referenced by gps_cb(), and ins_int_update_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 639 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 295 of file gps.c.
References GpsState::fix, get_sys_time_float(), gps, GPS_FIX_3D, and gps_time_since_last_3dfix().
|
inlinestatic |
Definition at line 186 of file gps.h.
References GpsFixValid.
void gps_init | ( | void | ) |
initialize the global GPS state
Definition at line 350 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_relpos_cb(), gps_relpos_ev, 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(), send_gps(), send_gps_int(), send_gps_lla(), send_gps_relpos(), send_gps_sol(), send_svinfo(), GpsState::tow, GpsState::vacc, GpsState::valid_fields, and GpsState::week.
GPS packet injection (default empty)
GPS packet injection (default empty)
Definition at line 418 of file gps.c.
References gps_piksi_write(), and sbp_state.
Referenced by ecef_float_from_gps(), and gps_parse_GPS_INJECT().
void gps_parse_GPS_INJECT | ( | uint8_t * | buf | ) |
Definition at line 424 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 279 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().
|
inlinestatic |
Returns the time since last 3D fix in seconds (float)
Definition at line 196 of file gps.h.
References sys_time::cpu_ticks_per_sec, gps, GpsState::last_3dfix_ticks, and GpsState::last_3dfix_time.
Referenced by gps_fix_valid().
Convert time in sys_time ticks to GPS time of week.
The resolution is sys_time.resolution
Definition at line 393 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 649 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 437 of file gps.c.
Referenced by gps_cb(), ins_float_invariant_reset_ref(), reset_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 437 of file gps.c.
Referenced by gps_cb(), ins_alt_float_update_gps(), and ins_float_invariant_update_gps().
Convenience function to get utm position in float 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 |
Convenience function to get utm position in float from GPS structure.
Definition at line 437 of file gps.c.
Referenced by gps_cb(), ins_alt_float_update_gps(), ins_float_invariant_reset_ref(), ins_float_invariant_update_gps(), and reset_ref().
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 437 of file gps.c.
Referenced by send_gps().
|
extern |
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_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_xsens_msg(), potential_task(), push_gps_to_vision(), put_alt(), reset_cb(), reset_ref(), reset_vertical_ref(), 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().
|
extern |
Definition at line 1 of file gps.c.
Referenced by gps_cb(), and gps_tow_from_sys_ticks().
|
extern |
Definition at line 82 of file gps.c.
Referenced by gps_init().