41 #include "generated/flight_plan.h"
44 #include <libsbp/sbp.h>
45 #include <libsbp/navigation.h>
46 #include <libsbp/observation.h>
47 #include <libsbp/tracking.h>
48 #include <libsbp/settings.h>
49 #include <libsbp/piksi.h>
51 #define SBP_FIX_MODE_SPP 0X00
52 #define SBP_FIX_MODE_FLOAT 0X02
53 #define SPB_FIX_MODE_FIXED 0X01
55 #define POS_ECEF_TIMEOUT 1000
60 #if USE_PIKSI_EXT_ANTENNA
61 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""External";
62 #elif USE_PIKSI_AUTO_ANTENNA
63 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""Auto";
65 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""Patch";
72 static const char SBP_UART_SET1[] =
"uart_uarta""\x00""mode""\x00""SBP";
73 static const char SBP_UART_SET2[] =
"uart_uarta""\x00""sbp_message_mask""\x00""784";
74 static const char SBP_UART_SET3[] =
"uart_uarta""\x00""configure_telemetry_radio_on_boot""\x00""False";
76 static const char SBP_UART_SET1[] =
"uart_uartb""\x00""mode""\x00""SBP";
77 static const char SBP_UART_SET2[] =
"uart_uartb""\x00""sbp_message_mask""\x00""784";
78 static const char SBP_UART_SET3[] =
"uart_uartb""\x00""configure_telemetry_radio_on_boot""\x00""False";
113 uint8_t len __attribute__((unused)),
115 void *context __attribute__((unused)))
118 msg_pos_ecef_t pos_ecef = *(msg_pos_ecef_t *)msg;
138 uint8_t len __attribute__((unused)),
140 void *context __attribute__((unused)))
142 msg_vel_ecef_t vel_ecef = *(msg_vel_ecef_t *)msg;
153 uint8_t len __attribute__((unused)),
155 void *context __attribute__((unused)))
158 msg_pos_llh_t pos_llh = *(msg_pos_llh_t *)msg;
161 if(pos_llh.flags > 0 || last_flags == 0) {
182 if (bit_is_set(pos_llh.flags, 3)) {
195 last_flags = pos_llh.flags;
199 uint8_t len __attribute__((unused)),
201 void *context __attribute__((unused)))
203 msg_vel_ned_t vel_ned = *(msg_vel_ned_t *)msg;
214 uint8_t len __attribute__((unused)),
216 void *context __attribute__((unused)))
218 msg_dops_t dops = *(msg_dops_t *)msg;
223 uint8_t len __attribute__((unused)),
225 void *context __attribute__((unused)))
227 msg_gps_time_t gps_time = *(msg_gps_time_t *)msg;
235 void *context __attribute__((unused)))
237 uint8_t channels_cnt = len/
sizeof(tracking_channel_state_t);
238 msg_tracking_state_t *tracking_state = (msg_tracking_state_t *)msg;
240 for(
uint8_t i = 0; i < channels_cnt; i++) {
241 if(tracking_state->states[i].state == 1) {
251 void *context __attribute__((unused)))
253 uint8_t channels_cnt = len/
sizeof(tracking_channel_state_dep_a_t);
254 msg_tracking_state_dep_a_t *tracking_state = (msg_tracking_state_dep_a_t *)msg;
256 for(
uint8_t i = 0; i < channels_cnt; i++) {
257 if(tracking_state->states[i].state == 1) {
269 static uint8_t n_since_last_rtk = 0;
272 if ( n_since_last_rtk > 2 ) {
278 n_since_last_rtk = 0;
281 n_since_last_rtk = 0;
359 for (i = 0; i < n; i++) {
375 for (i = 0; i < n; i++) {
static uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
static uint8_t get_fix_mode(uint8_t flags)
int32_t north
in centimeters
uint32_t gps_piksi_read(uint8_t *buff, uint32_t n, void *context)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
uint32_t gps_piksi_write(uint8_t *buff, uint32_t n, void *context)
sbp_msg_callbacks_node_t vel_ecef_node
sbp_msg_callbacks_node_t tracking_state_dep_a_node
uint32_t pacc
position accuracy in cm
sbp_msg_callbacks_node_t gps_time_node
static void sbp_tracking_state_dep_a_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
float alt
in meters above WGS84 reference ellipsoid
uint8_t nb_channels
Number of scanned satellites.
uint16_t uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Main include for ABI (AirBorneInterface).
static const char SBP_ANT_SET[]
void gps_impl_init(void)
GPS initialization.
static void sbp_pos_llh_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
position in UTM coordinates Units: meters
int32_t east
in centimeters
sbp_msg_callbacks_node_t dops_node
uint8_t svid
Satellite ID.
#define GPS_FIX_3D
3D GPS fix
sbp_msg_callbacks_node_t pos_llh_node
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
void gps_piksi_event(void)
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
int32_t alt
in millimeters above WGS84 reference ellipsoid
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
uint32_t sacc
speed accuracy in cm/s
static void gps_piksi_publish(void)
#define SPB_FIX_MODE_FIXED
Paparazzi double-precision floating point math for geodetic calculations.
uint32_t last_msg_time
cpu time in sec at last received GPS message
uint8_t zone
UTM zone number.
Paparazzi floating point math for geodetic calculations.
vector in Latitude, Longitude and Altitude
#define GPS_FIX_DGPS
DGPS fix.
static void sbp_tracking_state_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
static void sbp_dops_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
int32_t hmsl
height above mean sea level in mm
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
sbp_msg_callbacks_node_t pos_ecef_node
uint32_t tow
GPS time of week in ms.
#define GPS_FIX_NONE
No GPS fix.
Device independent GPS code (interface)
uint16_t pdop
position dilution of precision scaled by 100
static const char SBP_UART_SET3[]
struct EcefCoor_i ecef_pos
position in ECEF in cm
uint32_t int32_sqrt(uint32_t in)
int32_t lon
in degrees*1e7
Driver for Piksi modules from Swift-Nav.
sbp_msg_callbacks_node_t tracking_state_node
uint8_t zone
UTM zone number.
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
static void sbp_vel_ecef_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint8_t uart_getch(struct uart_periph *p)
#define GPS_FIX_RTK
RTK GPS fix.
static const char SBP_UART_SET1[]
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
int32_t alt
in millimeters above WGS84 reference ellipsoid
static void sbp_pos_ecef_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
static const char SBP_UART_SET2[]
volatile uint32_t nb_sec
full seconds since startup
static uint32_t time_since_last_pos_update
static void sbp_gps_time_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
uint8_t num_sv
number of sat in fix
uint16_t gspeed
norm of 2d ground speed in cm/s
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
void gps_inject_data(uint8_t packet_id, uint8_t length, uint8_t *data)
Override the default GPS packet injector to inject the data trough UART.
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
int32_t lat
in degrees*1e7
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
struct NedCoor_i ned_vel
speed NED in cm/s
struct GpsState gps
global GPS state
static void sbp_vel_ned_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint8_t buff[25]
Buffer used for general comunication over SPI (in buffer)
#define LLA_FLOAT_OF_BFP(_o, _i)
void uart_put_byte(struct uart_periph *periph, uint8_t data)
sbp_msg_callbacks_node_t vel_ned_node
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)
#define SBP_FIX_MODE_FLOAT