Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
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
27
28#ifndef IMU_H
29#define IMU_H
30
35#include "generated/airframe.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41#ifndef IMU_MAX_SENSORS
42#define IMU_MAX_SENSORS 4
43#endif
44
46 bool neutral: 1;
47 bool scale: 1;
48 bool scale_f: 1;
49 bool rotation: 1;
50 bool rot_euler: 1;
51 bool current: 1;
52 bool filter: 1;
53};
54
63
83
102
116
117
134
136extern struct Imu imu;
137
139extern void imu_init(void);
140
141extern void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct FloatRates *scale_f);
142extern void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f);
143extern void imu_set_defaults_mag(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f);
144
145extern struct imu_gyro_t *imu_get_gyro(uint8_t sender_id, bool create);
146extern struct imu_accel_t *imu_get_accel(uint8_t sender_id, bool create);
147extern struct imu_mag_t *imu_get_mag(uint8_t sender_id, bool create);
148
149extern void imu_SetBodyToImuPhi(float phi);
150extern void imu_SetBodyToImuTheta(float theta);
151extern void imu_SetBodyToImuPsi(float psi);
152extern void imu_SetBodyToImuCurrent(bool set);
153extern void imu_ResetBodyToImu(float reset);
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* IMU_H */
static uint8_t reset[3]
euler angles
angular rates
rotation matrix
angular rates
struct Imu imu
global IMU state
Definition imu.c:465
uint32_t last_stamp
Last measurement timestamp for integration.
Definition imu.h:66
struct Int32Rates scaled
Last scaled values in body frame.
Definition imu.h:68
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
Definition imu.h:94
struct imu_calib_t calibrated
Calibration bitmask.
Definition imu.h:105
float strength
Earth field strength where it was calibrated (gauss), the scaled values are 1 there; 0 if unknown.
Definition imu.h:114
float sample_freq
Calibrated sample frequency (Hz) for the filter, and reference of the measured integration rate (the ...
Definition imu.h:77
struct FloatVect3 current_scale
Current scaling multiplying.
Definition imu.h:111
struct imu_accel_t accels[IMU_MAX_SENSORS]
The accelerometer sensors.
Definition imu.h:122
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
Definition imu.h:95
uint8_t abi_id
ABI sensor ID.
Definition imu.h:65
bool scale
Scale calibrated.
Definition imu.h:47
float temperature
Temperature in degrees celcius.
Definition imu.h:70
Butterworth2LowPass filter[3]
Lowpass filter optional.
Definition imu.h:98
float filter_freq
Lowpass filter cutoff frequency (Hz).
Definition imu.h:96
struct FloatVect3 last_delta_alpha
Last integrated sample delta angle in sensor frame for the coning correction (IMU_INTEGRATION).
Definition imu.h:80
struct imu_rate_est_t rate_est
Measured sample rate for the integration (IMU_INTEGRATION).
Definition imu.h:81
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct FloatRates *scale_f)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Definition imu.c:842
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:1170
struct FloatRates scale_f
Scaling.
Definition imu.h:73
uint32_t last_stamp
Last measurement timestamp for integration.
Definition imu.h:86
float rate
Filtered measured sample rate (Hz), 0 until the first window.
Definition imu.h:59
void imu_SetBodyToImuCurrent(bool set)
Definition imu.c:1292
struct FloatVect3 scale_f
Scaling.
Definition imu.h:110
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
Definition imu.h:108
uint8_t mag_abi_send_id
Filter out and send only a specific ABI id in telemetry for the magnetometer.
Definition imu.h:127
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:1193
struct OrientationReps body_to_imu
Rotation from body to imu (all sensors) frame.
Definition imu.h:124
bool filter
Enable the lowpass filter (gyro and accel only, ignored for the mag).
Definition imu.h:52
struct FloatVect3 last_sample
Last scaled sample in sensor frame for the integration (IMU_INTEGRATION).
Definition imu.h:79
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition imu.h:89
void imu_SetBodyToImuTheta(float theta)
Definition imu.c:1276
bool rot_euler
Rotation calibrated with floating point eulers.
Definition imu.h:50
float temperature
Temperature in degrees celcius.
Definition imu.h:90
struct Int32Rates neutral
Neutral values, compensation on unscaled->scaled.
Definition imu.h:71
bool current
Current calibrated.
Definition imu.h:51
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
Definition imu.h:112
bool initialized
Check if the IMU is initialized.
Definition imu.h:120
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Definition imu.c:871
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
Definition imu.h:113
Butterworth2LowPass filter[3]
Lowpass filter optional.
Definition imu.h:78
struct imu_calib_t calibrated
Calibration bitmask.
Definition imu.h:87
struct FloatVect3 scale_f
Scaling.
Definition imu.h:93
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
Definition imu.h:109
uint32_t samples
Samples received since the window start.
Definition imu.h:58
bool scale_f
Scale calibrated with floating point.
Definition imu.h:48
bool rejected
A window was rejected (out of bounds), only warned once.
Definition imu.h:61
struct Int32Rates scale[2]
Scaling, first is numerator and second denominator.
Definition imu.h:72
uint16_t windows
Accepted windows, up to IMU_RATE_EST_REPORT when the rate is reported.
Definition imu.h:60
struct Int32Vect3 scaled
Last scaled values in body frame.
Definition imu.h:88
struct imu_gyro_t gyros[IMU_MAX_SENSORS]
The gyro sensors.
Definition imu.h:121
void imu_init(void)
External functions.
Definition imu.c:645
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
Definition imu.h:74
void imu_SetBodyToImuPsi(float psi)
Definition imu.c:1284
struct Int32Rates unscaled
Last unscaled values in sensor frame.
Definition imu.h:69
uint8_t abi_id
ABI sensor ID.
Definition imu.h:104
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:1217
float sample_freq
Calibrated sample frequency (Hz) for the filter, and reference of the measured integration rate (the ...
Definition imu.h:97
struct imu_mag_t mags[IMU_MAX_SENSORS]
The magnetometer sensors.
Definition imu.h:123
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
Definition imu.h:92
bool neutral
Neutral values calibrated.
Definition imu.h:46
bool b2i_set_current
flag for adjusting body_to_imu via settings.
Definition imu.h:132
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
Definition imu.h:75
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
Definition imu.h:91
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
Definition imu.h:107
float filter_freq
Lowpass filter cutoff frequency (Hz).
Definition imu.h:76
struct FloatVect3 last_sample
Last scaled sample in sensor frame for the integration (IMU_INTEGRATION).
Definition imu.h:99
void imu_SetBodyToImuPhi(float phi)
Definition imu.c:1268
#define IMU_MAX_SENSORS
Definition imu.h:42
struct imu_rate_est_t rate_est
Measured sample rate for the integration (IMU_INTEGRATION).
Definition imu.h:100
void imu_ResetBodyToImu(float reset)
struct imu_calib_t calibrated
Calibration bitmask.
Definition imu.h:67
uint8_t accel_abi_send_id
Filter out and send only a specific ABI id in telemetry for the accelerometer.
Definition imu.h:126
uint32_t start
Timestamp of the current window start (us).
Definition imu.h:57
struct Int32Vect3 scaled
Last scaled values in body frame.
Definition imu.h:106
bool rotation
Rotation calibrated.
Definition imu.h:49
uint8_t gyro_abi_send_id
Filter out and send only a specific ABI id in telemetry for the gyro.
Definition imu.h:125
uint8_t abi_id
ABI sensor ID.
Definition imu.h:85
void imu_set_defaults_mag(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f)
Set the defaults for a mag sensor WARNING: Should be called before sensor is publishing messages to e...
Definition imu.c:900
abstract IMU interface providing fixed point interface
Definition imu.h:119
Measured sample rate of a sensor, counted against the timestamps.
Definition imu.h:56
Simple first order low pass filter with bilinear transform.
struct SecondOrderLowPass Butterworth2LowPass
Second order Butterworth low pass filter.
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
Generic orientation representation and conversions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.