40 #include "generated/flight_plan.h"
42 #include <libsbp/sbp.h>
43 #include <libsbp/navigation.h>
44 #include <libsbp/observation.h>
45 #include <libsbp/tracking.h>
46 #include <libsbp/system.h>
47 #include <libsbp/settings.h>
48 #include <libsbp/piksi.h>
50 #define SBP_FIX_MODE_SPP 0X00
51 #define SBP_FIX_MODE_FLOAT 0X02
52 #define SPB_FIX_MODE_FIXED 0X01
54 #define POS_ECEF_TIMEOUT 1000
64 #if PERIODIC_TELEMETRY
69 pprz_msg_send_PIKSI_HEARTBEAT(trans, dev, AC_ID,
78 #if USE_PIKSI_EXT_ANTENNA
79 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""External";
80 #elif USE_PIKSI_AUTO_ANTENNA
81 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""Auto";
83 static const char SBP_ANT_SET[] =
"frontend""\x00""antenna_selection""\x00""Patch";
90 static const char SBP_UART_SET1[] =
"uart_uarta""\x00""mode""\x00""SBP";
91 static const char SBP_UART_SET2[] =
"uart_uarta""\x00""sbp_message_mask""\x00""784";
92 static const char SBP_UART_SET3[] =
"uart_uarta""\x00""configure_telemetry_radio_on_boot""\x00""False";
94 static const char SBP_UART_SET1[] =
"uart_uartb""\x00""mode""\x00""SBP";
95 static const char SBP_UART_SET2[] =
"uart_uartb""\x00""sbp_message_mask""\x00""784";
96 static const char SBP_UART_SET3[] =
"uart_uartb""\x00""configure_telemetry_radio_on_boot""\x00""False";
132 uint8_t len __attribute__((unused)),
134 void *context __attribute__((unused)))
137 msg_pos_ecef_t pos_ecef = *(msg_pos_ecef_t *)msg;
158 uint8_t len __attribute__((unused)),
160 void *context __attribute__((unused)))
162 msg_vel_ecef_t vel_ecef = *(msg_vel_ecef_t *)msg;
174 uint8_t len __attribute__((unused)),
176 void *context __attribute__((unused)))
179 msg_pos_llh_t pos_llh = *(msg_pos_llh_t *)msg;
182 if (pos_llh.flags > 0 || last_flags == 0) {
191 if (bit_is_set(pos_llh.flags, 3)) {
202 last_flags = pos_llh.flags;
206 uint8_t len __attribute__((unused)),
208 void *context __attribute__((unused)))
210 msg_vel_ned_t vel_ned = *(msg_vel_ned_t *)msg;
222 uint8_t len __attribute__((unused)),
224 void *context __attribute__((unused)))
226 msg_dops_t dops = *(msg_dops_t *)msg;
231 uint8_t len __attribute__((unused)),
233 void *context __attribute__((unused)))
235 msg_gps_time_t gps_time = *(msg_gps_time_t *)msg;
243 void *context __attribute__((unused)))
245 uint8_t channels_cnt = len/
sizeof(tracking_channel_state_t);
246 msg_tracking_state_t *tracking_state = (msg_tracking_state_t *)msg;
248 for(
uint8_t i = 0; i < channels_cnt; i++) {
249 if(tracking_state->states[i].state == 1) {
259 void *context __attribute__((unused)))
261 uint8_t channels_cnt = len/
sizeof(tracking_channel_state_dep_a_t);
262 msg_tracking_state_dep_a_t *tracking_state = (msg_tracking_state_dep_a_t *)msg;
264 for(
uint8_t i = 0; i < channels_cnt; i++) {
265 if(tracking_state->states[i].state == 1) {
273 uint8_t len __attribute__((unused)),
274 uint8_t msg[] __attribute__((unused)),
275 void *context __attribute__((unused)))
285 static uint8_t n_since_last_rtk = 0;
288 if ( n_since_last_rtk > 2 ) {
294 n_since_last_rtk = 0;
297 n_since_last_rtk = 0;
341 #if PERIODIC_TELEMETRY
383 for (i = 0; i < n; i++) {
399 for (i = 0; i < n; i++) {
static uint8_t get_fix_mode(uint8_t flags)
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 heartbeat_node
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)
uint8_t nb_channels
Number of scanned satellites.
#define GPS_VALID_VEL_NED_BIT
Periodic telemetry system header (includes downlink utility and generated code).
uint8_t uart_getch(struct uart_periph *p)
uint32_t get_sys_time_msec(void)
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
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[]
static void sbp_pos_llh_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
void gps_piksi_init(void)
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
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
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
#define GPS_VALID_COURSE_BIT
#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)
struct GpsState gps_piksi
int32_t hmsl
height above mean sea level (MSL) in mm
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
static void send_piksi_heartbeat(struct transport_tx *trans, struct link_device *dev)
struct GpsTimeSync gps_piksi_time_sync
sbp_msg_callbacks_node_t pos_ecef_node
data structure for GPS information
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
static uint32_t time_since_last_heartbeat
#define GPS_VALID_HMSL_BIT
uint32_t int32_sqrt(uint32_t in)
#define DefaultPeriodic
Set default periodic telemetry.
int32_t lon
in degrees*1e7
Driver for Piksi modules from Swift-Nav.
sbp_msg_callbacks_node_t tracking_state_node
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)
static const struct usb_device_descriptor dev
void uart_put_byte(struct uart_periph *p, long fd, uint8_t data)
Uart transmit implementation.
#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
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)
uint8_t comp_id
id of current gps
static const char SBP_UART_SET2[]
volatile uint32_t nb_sec
full seconds since startup
static uint32_t time_since_last_pos_update
#define GPS_VALID_POS_ECEF_BIT
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
#define GPS_VALID_POS_LLA_BIT
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
data structure for GPS time sync
#define GPS_VALID_VEL_ECEF_BIT
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)
static void spb_heartbeat_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
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)
sbp_msg_callbacks_node_t vel_ned_node
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
#define SBP_FIX_MODE_FLOAT