Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
imu.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2022 The Paparazzi Team
3  * Freek van Tienen <freek.v.tienen@gmail.com>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
28 #ifndef IMU_H
29 #define IMU_H
30 
31 #include "math/pprz_algebra_int.h"
34 #include "generated/airframe.h"
35 
36 #ifndef IMU_MAX_SENSORS
37 #define IMU_MAX_SENSORS 3
38 #endif
39 
40 struct imu_calib_t {
41  bool neutral: 1;
42  bool scale: 1;
43  bool rotation: 1;
44  bool current: 1;
45 };
46 
47 struct imu_gyro_t {
51  struct Int32Rates scaled;
53  float temperature;
55  struct Int32Rates scale[2];
57 };
58 
59 struct imu_accel_t {
63  struct Int32Vect3 scaled;
65  float temperature;
67  struct Int32Vect3 scale[2];
69 };
70 
71 struct imu_mag_t {
74  struct Int32Vect3 scaled;
77  struct Int32Vect3 scale[2];
80 };
81 
82 
84 struct Imu {
85  bool initialized;
90 
95 };
96 
98 extern struct Imu imu;
99 
101 extern void imu_init(void);
102 
103 extern void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct Int32Rates *scale);
104 extern void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale);
105 extern void imu_set_defaults_mag(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale);
106 
107 extern struct imu_gyro_t *imu_get_gyro(uint8_t sender_id, bool create);
108 extern struct imu_accel_t *imu_get_accel(uint8_t sender_id, bool create);
109 extern struct imu_mag_t *imu_get_mag(uint8_t sender_id, bool create);
110 
111 extern void imu_SetBodyToImuPhi(float phi);
112 extern void imu_SetBodyToImuTheta(float theta);
113 extern void imu_SetBodyToImuPsi(float psi);
114 extern void imu_SetBodyToImuCurrent(float set);
115 extern void imu_ResetBodyToImu(float reset);
116 
117 #endif /* IMU_H */
imu_gyro_t::last_stamp
uint32_t last_stamp
Last measurement timestamp for integration.
Definition: imu.h:49
OrientationReps
Definition: pprz_orientation_conversion.h:79
uint32_t
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
Int32RMat
rotation matrix
Definition: pprz_algebra_int.h:159
imu_calib_t::neutral
bool neutral
Neutral values calibrated.
Definition: imu.h:41
imu_accel_t::calibrated
struct imu_calib_t calibrated
Calibration bitmask.
Definition: imu.h:62
imu_mag_t::unscaled
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition: imu.h:75
Int32Rates
angular rates
Definition: pprz_algebra_int.h:179
Imu::gyros
struct imu_gyro_t gyros[IMU_MAX_SENSORS]
The gyro sensors.
Definition: imu.h:86
scale
static const float scale[]
Definition: dw1000_arduino.c:200
imu_accel_t::abi_id
uint8_t abi_id
ABI sensor ID.
Definition: imu.h:60
imu_SetBodyToImuPhi
void imu_SetBodyToImuPhi(float phi)
Definition: imu.c:756
Imu::b2i_set_current
bool b2i_set_current
flag for adjusting body_to_imu via settings.
Definition: imu.h:94
imu_mag_t::scaled
struct Int32Vect3 scaled
Last scaled values in body frame.
Definition: imu.h:74
imu_get_accel
struct imu_accel_t * imu_get_accel(uint8_t sender_id, bool create)
Find or create the accel in the imu structure.
Definition: imu.c:681
Imu::body_to_imu
struct OrientationReps body_to_imu
Rotation from body to imu (all sensors) frame.
Definition: imu.h:89
Imu::accels
struct imu_accel_t accels[IMU_MAX_SENSORS]
The accelerometer sensors.
Definition: imu.h:87
imu_SetBodyToImuCurrent
void imu_SetBodyToImuCurrent(float set)
Definition: imu.c:780
Imu::initialized
bool initialized
Check if the IMU is initialized.
Definition: imu.h:85
imu_get_mag
struct imu_mag_t * imu_get_mag(uint8_t sender_id, bool create)
Find or create the mag in the imu structure.
Definition: imu.c:705
pprz_algebra_float.h
Paparazzi floating point algebra.
imu_accel_t::neutral
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
Definition: imu.h:66
imu_gyro_t::calibrated
struct imu_calib_t calibrated
Calibration bitmask.
Definition: imu.h:50
reset
static uint8_t reset[3]
Definition: baro_MS5534A.c:83
imu_SetBodyToImuPsi
void imu_SetBodyToImuPsi(float psi)
Definition: imu.c:772
pprz_algebra_int.h
Paparazzi fixed point algebra.
FloatVect3
Definition: pprz_algebra_float.h:54
Imu
abstract IMU interface providing fixed point interface
Definition: imu.h:84
imu_accel_t::scale
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
Definition: imu.h:67
imu_accel_t::last_stamp
uint32_t last_stamp
Last measurement timestamp for integration.
Definition: imu.h:61
imu_mag_t::abi_id
uint8_t abi_id
ABI sensor ID.
Definition: imu.h:72
imu_gyro_t::body_to_sensor
struct Int32RMat body_to_sensor
Rotation from body to sensor frame (body to imu combined with imu to sensor)
Definition: imu.h:56
imu
struct Imu imu
global IMU state
Definition: imu.c:274
imu_calib_t::current
bool current
Current calibrated.
Definition: imu.h:44
imu_mag_t
Definition: imu.h:71
Int32Vect3
Definition: pprz_algebra_int.h:88
IMU_MAX_SENSORS
#define IMU_MAX_SENSORS
Definition: imu.h:37
imu_mag_t::scale
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
Definition: imu.h:77
imu_mag_t::calibrated
struct imu_calib_t calibrated
Calibration bitmask.
Definition: imu.h:73
imu_get_gyro
struct imu_gyro_t * imu_get_gyro(uint8_t sender_id, bool create)
Find or create the gyro in the imu structure.
Definition: imu.c:658
imu_gyro_t::temperature
float temperature
Temperature in degrees celcius.
Definition: imu.h:53
imu_gyro_t::abi_id
uint8_t abi_id
ABI sensor ID.
Definition: imu.h:48
imu_gyro_t::scale
struct Int32Rates scale[2]
Scaling, first is numerator and second denominator.
Definition: imu.h:55
imu_set_defaults_accel
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Definition: imu.c:440
imu_set_defaults_gyro
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct Int32Rates *scale)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Definition: imu.c:410
imu_calib_t::scale
bool scale
Scale calibrated.
Definition: imu.h:42
imu_mag_t::neutral
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
Definition: imu.h:76
imu_accel_t
Definition: imu.h:59
imu_accel_t::body_to_sensor
struct Int32RMat body_to_sensor
Rotation from body to sensor frame (body to imu combined with imu to sensor)
Definition: imu.h:68
imu_init
void imu_init(void)
External functions.
Definition: imu.c:281
pprz_orientation_conversion.h
Imu::mags
struct imu_mag_t mags[IMU_MAX_SENSORS]
The magnetometer sensors.
Definition: imu.h:88
imu_gyro_t::unscaled
struct Int32Rates unscaled
Last unscaled values in sensor frame.
Definition: imu.h:52
imu_mag_t::body_to_sensor
struct Int32RMat body_to_sensor
Rotation from body to sensor frame (body to imu combined with imu to sensor)
Definition: imu.h:79
imu_gyro_t::scaled
struct Int32Rates scaled
Last scaled values in body frame.
Definition: imu.h:51
imu_SetBodyToImuTheta
void imu_SetBodyToImuTheta(float theta)
Definition: imu.c:764
imu_accel_t::scaled
struct Int32Vect3 scaled
Last scaled values in body frame.
Definition: imu.h:63
imu_gyro_t
Definition: imu.h:47
imu_ResetBodyToImu
void imu_ResetBodyToImu(float reset)
imu_calib_t
Definition: imu.h:40
imu_accel_t::unscaled
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition: imu.h:64
imu_accel_t::temperature
float temperature
Temperature in degrees celcius.
Definition: imu.h:65
imu_calib_t::rotation
bool rotation
Rotation calibrated.
Definition: imu.h:43
imu_set_defaults_mag
void imu_set_defaults_mag(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale)
Set the defaults for a mag sensor WARNING: Should be called before sensor is publishing messages to e...
Definition: imu.c:470
imu_gyro_t::neutral
struct Int32Rates neutral
Neutral values, compensation on unscaled->scaled.
Definition: imu.h:54
imu_mag_t::current_scale
struct FloatVect3 current_scale
Current scaling multiplying.
Definition: imu.h:78