Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 
31 #include "generated/airframe.h"
32 
33 #include "mcu_periph/sys_time.h"
34 #include "subsystems/abi.h"
35 
36 static void handle_ins_msg(void);
37 
38 void imu_xsens_init(void)
39 {
40  xsens_init();
41 }
42 
43 void imu_xsens_event(void)
44 {
50  }
51 }
52 
53 static void handle_ins_msg(void)
54 {
55  uint32_t now_ts = get_sys_time_usec();
56 #ifdef XSENS_BACKWARDS
57  if (xsens.gyro_available) {
61  AbiSendMsgIMU_GYRO_INT32(IMU_XSENS_ID, now_ts, &imu.gyro);
62  }
63  if (xsens.accel_available) {
67  AbiSendMsgIMU_ACCEL_INT32(IMU_XSENS_ID, now_ts, &imu.accel);
68  }
69  if (xsens.mag_available) {
73  AbiSendMsgIMU_MAG_INT32(IMU_XSENS_ID, now_ts, &imu.mag);
74  }
75 #else
76  if (xsens.gyro_available) {
80  AbiSendMsgIMU_GYRO_INT32(IMU_XSENS_ID, now_ts, &imu.gyro);
81  }
82  if (xsens.accel_available) {
86  AbiSendMsgIMU_ACCEL_INT32(IMU_XSENS_ID, now_ts, &imu.accel);
87  }
88  if (xsens.mag_available) {
92  AbiSendMsgIMU_MAG_INT32(IMU_XSENS_ID, now_ts, &imu.mag);
93  }
94 #endif /* XSENS_BACKWARDS */
95 }
Imu::gyro_unscaled
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
Xsens::mag_available
bool mag_available
Definition: xsens.h:71
handle_ins_msg
static void handle_ins_msg(void)
Definition: imu_xsens.c:53
xsens_parser_event
void xsens_parser_event(struct XsensParser *xsensparser)
Definition: xsens_parser.c:35
parse_xsens_msg
void parse_xsens_msg(void)
Definition: xsens.c:184
xsens
struct Xsens xsens
Definition: xsens.c:109
Xsens::mag
struct FloatVect3 mag
Definition: xsens.h:58
imu_xsens_event
void imu_xsens_event(void)
Definition: imu_xsens.c:43
abi.h
Imu::accel
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:39
Xsens::gyro_available
bool gyro_available
Definition: xsens.h:69
uint32_t
unsigned long uint32_t
Definition: types.h:18
Xsens::accel_available
bool accel_available
Definition: xsens.h:70
xsens_init
void xsens_init(void)
Definition: xsens.c:113
RATE_BFP_OF_REAL
#define RATE_BFP_OF_REAL(_af)
Definition: pprz_algebra_int.h:208
Imu::accel_unscaled
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
XsensParser::msg_received
volatile uint8_t msg_received
Definition: xsens_parser.h:47
get_sys_time_usec
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:68
RATES_ASSIGN
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:330
ACCELS_BFP_OF_REAL
#define ACCELS_BFP_OF_REAL(_ef, _ei)
Definition: pprz_algebra.h:801
Xsens::accel
struct FloatVect3 accel
Definition: xsens.h:57
MAG_BFP_OF_REAL
#define MAG_BFP_OF_REAL(_af)
Definition: pprz_algebra_int.h:222
RATES_BFP_OF_REAL
#define RATES_BFP_OF_REAL(_ri, _rf)
Definition: pprz_algebra.h:765
imu_xsens.h
sys_time.h
Architecture independent timing functions.
ACCEL_BFP_OF_REAL
#define ACCEL_BFP_OF_REAL(_af)
Definition: pprz_algebra_int.h:220
imu_scale_gyro
void imu_scale_gyro(struct Imu *_imu)
Definition: imu_vectornav.c:43
FloatRates::r
float r
in rad/s
Definition: pprz_algebra_float.h:96
Xsens::parser
struct XsensParser parser
Definition: xsens.h:66
imu
struct Imu imu
global IMU state
Definition: imu.c:108
FloatRates::q
float q
in rad/s
Definition: pprz_algebra_float.h:95
xsens.h
IMU_XSENS_ID
#define IMU_XSENS_ID
Definition: abi_sender_ids.h:331
Xsens::gyro
struct FloatRates gyro
Definition: xsens.h:56
imu_scale_mag
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:352
Imu::mag
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:40
Imu::mag_unscaled
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
FALSE
#define FALSE
Definition: std.h:5
VECT3_ASSIGN
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:125
imu_xsens_init
void imu_xsens_init(void)
Definition: imu_xsens.c:38
FloatRates::p
float p
in rad/s
Definition: pprz_algebra_float.h:94
imu_scale_accel
void imu_scale_accel(struct Imu *_imu)
Definition: imu_vectornav.c:44
MAGS_BFP_OF_REAL
#define MAGS_BFP_OF_REAL(_ef, _ei)
Definition: pprz_algebra.h:813
Imu::gyro
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:38