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)),
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++) {
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
struct GpsState gps
global GPS state
Device independent GPS code (interface)
uint32_t tow
GPS time of week in ms.
int32_t hmsl
height above mean sea level (MSL) in mm
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t sacc
speed accuracy in cm/s
#define GPS_FIX_DGPS
DGPS fix.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
#define GPS_VALID_VEL_ECEF_BIT
#define GPS_VALID_VEL_NED_BIT
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
struct EcefCoor_i ecef_pos
position in ECEF in cm
#define GPS_VALID_POS_LLA_BIT
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
uint16_t pdop
position dilution of precision scaled by 100
#define GPS_FIX_NONE
No GPS fix.
#define GPS_VALID_POS_ECEF_BIT
#define GPS_VALID_HMSL_BIT
struct NedCoor_i ned_vel
speed NED in cm/s
uint32_t last_msg_time
cpu time in sec at last received GPS message
uint8_t svid
Satellite ID.
uint8_t nb_channels
Number of scanned satellites.
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
uint32_t pacc
position accuracy in cm
uint16_t gspeed
norm of 2d ground speed in cm/s
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
uint8_t comp_id
id of current gps
#define GPS_FIX_3D
3D GPS fix
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
#define GPS_FIX_RTK
RTK GPS fix.
#define GPS_VALID_COURSE_BIT
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
uint8_t num_sv
number of sat in fix
data structure for GPS information
data structure for GPS time sync
static void sbp_vel_ned_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint32_t gps_piksi_write(uint8_t *buff, uint32_t n, void *context)
static void sbp_tracking_state_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
void gps_piksi_event(void)
static void sbp_tracking_state_dep_a_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
static const char SBP_UART_SET1[]
void gps_piksi_init(void)
sbp_msg_callbacks_node_t vel_ned_node
static void sbp_dops_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
#define SPB_FIX_MODE_FIXED
struct GpsState gps_piksi
static uint32_t time_since_last_heartbeat
static const char SBP_ANT_SET[]
sbp_msg_callbacks_node_t gps_time_node
static void sbp_gps_time_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
uint32_t gps_piksi_read(uint8_t *buff, uint32_t n, void *context)
sbp_msg_callbacks_node_t pos_llh_node
static void spb_heartbeat_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
static uint32_t time_since_last_pos_update
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.
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
sbp_msg_callbacks_node_t tracking_state_node
static const char SBP_UART_SET3[]
sbp_msg_callbacks_node_t vel_ecef_node
static void gps_piksi_publish(void)
static const char SBP_UART_SET2[]
static void sbp_pos_llh_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
static void sbp_pos_ecef_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
#define SBP_FIX_MODE_FLOAT
static uint8_t get_fix_mode(uint8_t flags)
sbp_msg_callbacks_node_t tracking_state_dep_a_node
sbp_msg_callbacks_node_t dops_node
sbp_msg_callbacks_node_t heartbeat_node
static void sbp_vel_ecef_callback(uint16_t sender_id, uint8_t len, uint8_t msg[], void *context)
Driver for Piksi modules from Swift-Nav.
uint8_t u8
Unsigned 8-bit integer.
uint32_t int32_sqrt(uint32_t in)
int32_t lat
in degrees*1e7
int32_t alt
in millimeters above WGS84 reference ellipsoid
int32_t lon
in degrees*1e7
uint8_t msg[10]
Buffer used for general comunication over SPI (out buffer)
uint8_t buff[25]
Buffer used for general comunication over SPI (in buffer)
void uart_put_byte(struct uart_periph *periph, long fd, uint8_t data)
int uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
uint8_t uart_getch(struct uart_periph *p)
Paparazzi double-precision floating point math for geodetic calculations.
static const struct usb_device_descriptor dev
volatile uint32_t nb_sec
full seconds since startup
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.