Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_xsens.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 Pascal Brisset, Antoine Drouin
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  *
21  */
22 
28 #include "imu_xsens.h"
29 #include "xsens.h"
30 #include "xsens_common.h"
31 
32 #include "generated/airframe.h"
33 
34 #include "mcu_periph/sys_time.h"
35 #include "subsystems/abi.h"
36 
37 static void handle_ins_msg(void);
38 
39 void imu_xsens_init(void)
40 {
41  xsens_init();
42 }
43 
44 void imu_xsens_event(void)
45 {
46  xsens_event();
47  if (xsens.msg_received) {
51  }
52 }
53 
54 static void handle_ins_msg(void)
55 {
56  uint32_t now_ts = get_sys_time_usec();
57 #ifdef XSENS_BACKWARDS
58  if (xsens.gyro_available) {
62  AbiSendMsgIMU_GYRO_INT32(IMU_XSENS_ID, now_ts, &imu.gyro);
63  }
64  if (xsens.accel_available) {
68  AbiSendMsgIMU_ACCEL_INT32(IMU_XSENS_ID, now_ts, &imu.accel);
69  }
70  if (xsens.mag_available) {
74  AbiSendMsgIMU_MAG_INT32(IMU_XSENS_ID, now_ts, &imu.mag);
75  }
76 #else
77  if (xsens.gyro_available) {
81  AbiSendMsgIMU_GYRO_INT32(IMU_XSENS_ID, now_ts, &imu.gyro);
82  }
83  if (xsens.accel_available) {
87  AbiSendMsgIMU_ACCEL_INT32(IMU_XSENS_ID, now_ts, &imu.accel);
88  }
89  if (xsens.mag_available) {
93  AbiSendMsgIMU_MAG_INT32(IMU_XSENS_ID, now_ts, &imu.mag);
94  }
95 #endif /* XSENS_BACKWARDS */
96 }
void xsens_init(void)
Definition: xsens.c:114
#define RATES_BFP_OF_REAL(_ri, _rf)
Definition: pprz_algebra.h:709
void imu_xsens_init(void)
Definition: imu_xsens.c:39
bool accel_available
Definition: xsens.h:67
float r
in rad/s
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:124
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:329
void parse_xsens_msg(void)
Definition: xsens.c:185
Main include for ABI (AirBorneInterface).
#define IMU_XSENS_ID
void xsens_event(void)
Definition: xsens_common.c:44
void imu_xsens_event(void)
Definition: imu_xsens.c:44
struct Imu imu
global IMU state
Definition: imu.c:108
float q
in rad/s
float p
in rad/s
static void handle_ins_msg(void)
Definition: imu_xsens.c:54
#define FALSE
Definition: std.h:5
struct FloatVect3 accel
Definition: xsens.h:54
#define ACCELS_BFP_OF_REAL(_ef, _ei)
Definition: pprz_algebra.h:745
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
struct Xsens xsens
Definition: xsens.c:110
#define MAGS_BFP_OF_REAL(_ef, _ei)
Definition: pprz_algebra.h:757
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:39
#define MAG_BFP_OF_REAL(_af)
Architecture independent timing functions.
unsigned long uint32_t
Definition: types.h:18
bool mag_available
Definition: xsens.h:68
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:40
void imu_scale_gyro(struct Imu *_imu)
Definition: imu_vectornav.c:43
Parser for the Xsens protocol.
struct FloatVect3 mag
Definition: xsens.h:55
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
volatile bool msg_received
Definition: xsens.h:63
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
void imu_scale_accel(struct Imu *_imu)
Definition: imu_vectornav.c:44
Parser for the Xsens protocol.
XSENS to just provide IMU measurements.
struct FloatRates gyro
Definition: xsens.h:53
#define ACCEL_BFP_OF_REAL(_af)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:68
bool gyro_available
Definition: xsens.h:66
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:38
#define RATE_BFP_OF_REAL(_af)