34 #include "generated/airframe.h"
42 #error "USE_GPS needs to be 1 to use the Xsens GPS!"
94 #define XsensInitCheksum() { send_ck = 0; }
95 #define XsensUpdateChecksum(c) { send_ck += c; }
97 #define XsensSend1(c) { uint8_t i8=c; InsUartSend1(i8); XsensUpdateChecksum(i8); }
98 #define XsensSend1ByAddr(x) { XsensSend1(*x); }
99 #define XsensSend2ByAddr(x) { XsensSend1(*(x+1)); XsensSend1(*x); }
100 #define XsensSend4ByAddr(x) { XsensSend1(*(x+3)); XsensSend1(*(x+2)); XsensSend1(*(x+1)); XsensSend1(*x); }
102 #define XsensHeader(msg_id, len) { \
103 InsUartSend1(XSENS_START); \
104 XsensInitCheksum(); \
105 XsensSend1(XSENS_BID); \
106 XsensSend1(msg_id); \
109 #define XsensTrailer() { uint8_t i8=0x100-send_ck; InsUartSend1(i8); }
112 #include "xsens_protocol.h"
115 #define XSENS_MAX_PAYLOAD 254
125 #define GOT_CHECKSUM 6
129 #include "messages.h"
178 void ins_xsens_update_gps(
struct GpsState *gps_s);
180 void ins_xsens_init(
void)
194 static void gps_cb(
uint8_t sender_id __attribute__((unused)),
195 uint32_t stamp __attribute__((unused)),
198 ins_xsens_update_gps(gps_s);
201 void ins_xsens_register(
void)
207 void ins_xsens_update_gps(
struct GpsState *gps_s)
213 utm.alt = gps_s->
hmsl / 1000.;
234 static void gps_xsens_publish(
void)
303 #ifdef GPS_IMU_LEVER_ARM_X
304 #pragma message "Sending XSens GPS Arm."
305 XSENS_SetLeverArmGps(GPS_IMU_LEVER_ARM_X, GPS_IMU_LEVER_ARM_Y, GPS_IMU_LEVER_ARM_Z);
310 XSENS_SetBaudrate(baud);
315 XSENS_GoToMeasurment();
330 static inline void update_state_interface(
void)
365 update_state_interface();
377 float fcourse = atan2f((
float)ins_vy, (
float)
ins_vx);
379 #endif // USE_GPS_XSENS
385 if (
xsens_id == XSENS_ReqLeverArmGpsAck_ID) {
392 }
else if (
xsens_id == XSENS_Error_ID) {
394 }
else if (
xsens_id == XSENS_MTData2_ID) {
405 }
else if (code2 == 0x20) {
411 }
else if (code1 == 0x20) {
421 }
else if (code1 == 0x40) {
428 }
else if (code1 == 0x80) {
435 }
else if (code1 == 0x30) {
439 }
else if (code1 == 0xE0) {
454 }
else if (code1 == 0x88) {
461 }
else if (code2 == 0xA0) {
483 }
else if (code1 == 0x50) {
486 }
else if (code2 == 0x20) {
495 }
else if (code2 == 0x40) {
518 }
else if (code1 == 0xD0) {
530 if (subpacklen < 0) {
533 offset += subpacklen;
572 if (c != XSENS_START) {
579 if (c != XSENS_BID) {
uint8_t qi
quality bitfield (GPS receiver specific)
Event structure to store callbacks in a linked list.
int32_t north
in centimeters
static void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (float).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
uint32_t pacc
position accuracy in cm
static void xsens_ask_message_rate(uint8_t c1, uint8_t c2, uint8_t freq)
uint8_t nb_channels
Number of scanned satellites.
void gps_impl_init(void)
GPS initialization.
#define XsensSend1ByAddr(x)
Main include for ABI (AirBorneInterface).
#define XSENS_MAX_PAYLOAD
Includes macros generated from xsens_MTi-G.xml.
Integrated Navigation System interface.
position in UTM coordinates Units: meters
int32_t east
in centimeters
uint8_t svid
Satellite ID.
uint16_t speed_3d
norm of 3d speed in cm/s
#define GPS_FIX_3D
3D GPS fix
#define INS_ROLL_NEUTRAL_DEFAULT
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
uint32_t sacc
speed accuracy in cm/s
uint32_t last_msg_time
cpu time in sec at last received GPS message
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
uint8_t zone
UTM zone number.
Paparazzi floating point math for geodetic calculations.
vector in Latitude, Longitude and Altitude
uint32_t xsens_msg_statusword
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
void parse_ins_buffer(uint8_t c)
int32_t hmsl
height above mean sea level in mm
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
vector in North East Down coordinates Units: meters
volatile int xsens_configured
Architecture independent timing functions.
data structure for GPS information
uint32_t tow
GPS time of week in ms.
void xsens_periodic(void)
#define GPS_FIX_NONE
No GPS fix.
#define GPS_FIX_2D
2D GPS fix
uint32_t xsens_output_settings
Device independent GPS code (interface)
uint16_t pdop
position dilution of precision scaled by 100
volatile uint8_t ins_msg_received
#define INS_PITCH_NEUTRAL_DEFAULT
uint8_t zone
UTM zone number.
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
#define DefaultChannel
SITL.
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static float wgs84_ellipsoid_to_geoid(float lat, float lon)
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
int32_t alt
in millimeters above WGS84 reference ellipsoid
API to get/set the generic vehicle states.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
volatile uint8_t new_ins_attitude
volatile uint32_t nb_sec
full seconds since startup
static uint8_t xsens_msg_idx
static uint8_t xsens_status
Common code for AP and FBW telemetry.
uint8_t flags
bitfield with GPS receiver specific flags
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
uint8_t num_sv
number of sat in fix
void handle_ins_msg(void)
#define ABI_BROADCAST
Broadcast address.
uint16_t gspeed
norm of 2d ground speed in cm/s
uint8_t xsens_msg_buf[XSENS_MAX_PAYLOAD]
uint16_t xsens_output_mode
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
void ins_register_impl(InsInit init)
struct NedCoor_i ned_vel
speed NED in cm/s
uint16_t xsens_time_stamp
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
struct GpsState gps
global GPS state
Device independent INS code.
#define XsensHeader(msg_id, len)
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)