35#include "generated/airframe.h"
41#ifndef IMU_MAX_SENSORS
42#define IMU_MAX_SENSORS 4
struct Imu imu
global IMU state
uint32_t last_stamp
Last measurement timestamp for integration.
struct Int32Rates scaled
Last scaled values in body frame.
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
struct imu_calib_t calibrated
Calibration bitmask.
float strength
Earth field strength where it was calibrated (gauss), the scaled values are 1 there; 0 if unknown.
float sample_freq
Calibrated sample frequency (Hz) for the filter, and reference of the measured integration rate (the ...
struct FloatVect3 current_scale
Current scaling multiplying.
struct imu_accel_t accels[IMU_MAX_SENSORS]
The accelerometer sensors.
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
uint8_t abi_id
ABI sensor ID.
bool scale
Scale calibrated.
float temperature
Temperature in degrees celcius.
Butterworth2LowPass filter[3]
Lowpass filter optional.
float filter_freq
Lowpass filter cutoff frequency (Hz).
struct FloatVect3 last_delta_alpha
Last integrated sample delta angle in sensor frame for the coning correction (IMU_INTEGRATION).
struct imu_rate_est_t rate_est
Measured sample rate for the integration (IMU_INTEGRATION).
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 ...
struct imu_gyro_t * imu_get_gyro(uint8_t sender_id, bool create)
Find or create the gyro in the imu structure.
struct FloatRates scale_f
Scaling.
uint32_t last_stamp
Last measurement timestamp for integration.
float rate
Filtered measured sample rate (Hz), 0 until the first window.
void imu_SetBodyToImuCurrent(bool set)
struct FloatVect3 scale_f
Scaling.
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
uint8_t mag_abi_send_id
Filter out and send only a specific ABI id in telemetry for the magnetometer.
struct imu_accel_t * imu_get_accel(uint8_t sender_id, bool create)
Find or create the accel in the imu structure.
struct OrientationReps body_to_imu
Rotation from body to imu (all sensors) frame.
bool filter
Enable the lowpass filter (gyro and accel only, ignored for the mag).
struct FloatVect3 last_sample
Last scaled sample in sensor frame for the integration (IMU_INTEGRATION).
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
void imu_SetBodyToImuTheta(float theta)
bool rot_euler
Rotation calibrated with floating point eulers.
float temperature
Temperature in degrees celcius.
struct Int32Rates neutral
Neutral values, compensation on unscaled->scaled.
bool current
Current calibrated.
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
bool initialized
Check if the IMU is initialized.
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...
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
Butterworth2LowPass filter[3]
Lowpass filter optional.
struct imu_calib_t calibrated
Calibration bitmask.
struct FloatVect3 scale_f
Scaling.
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
uint32_t samples
Samples received since the window start.
bool scale_f
Scale calibrated with floating point.
bool rejected
A window was rejected (out of bounds), only warned once.
struct Int32Rates scale[2]
Scaling, first is numerator and second denominator.
uint16_t windows
Accepted windows, up to IMU_RATE_EST_REPORT when the rate is reported.
struct Int32Vect3 scaled
Last scaled values in body frame.
struct imu_gyro_t gyros[IMU_MAX_SENSORS]
The gyro sensors.
void imu_init(void)
External functions.
struct Int32RMat body_to_sensor
Rotation from body to sensor frame, set as imu to sensor in the airframe calibration and combined wit...
void imu_SetBodyToImuPsi(float psi)
struct Int32Rates unscaled
Last unscaled values in sensor frame.
uint8_t abi_id
ABI sensor ID.
struct imu_mag_t * imu_get_mag(uint8_t sender_id, bool create)
Find or create the mag in the imu structure.
float sample_freq
Calibrated sample frequency (Hz) for the filter, and reference of the measured integration rate (the ...
struct imu_mag_t mags[IMU_MAX_SENSORS]
The magnetometer sensors.
struct Int32Vect3 scale[2]
Scaling, first is numerator and second denominator.
bool neutral
Neutral values calibrated.
bool b2i_set_current
flag for adjusting body_to_imu via settings.
struct FloatEulers body_to_sensor_f
Rotation from imu to sensor frame in eulers (airframe calibration, only used at init).
struct Int32Vect3 neutral
Neutral values, compensation on unscaled->scaled.
struct Int32Vect3 unscaled
Last unscaled values in sensor frame.
float filter_freq
Lowpass filter cutoff frequency (Hz).
struct FloatVect3 last_sample
Last scaled sample in sensor frame for the integration (IMU_INTEGRATION).
void imu_SetBodyToImuPhi(float phi)
struct imu_rate_est_t rate_est
Measured sample rate for the integration (IMU_INTEGRATION).
void imu_ResetBodyToImu(float reset)
struct imu_calib_t calibrated
Calibration bitmask.
uint8_t accel_abi_send_id
Filter out and send only a specific ABI id in telemetry for the accelerometer.
uint32_t start
Timestamp of the current window start (us).
struct Int32Vect3 scaled
Last scaled values in body frame.
bool rotation
Rotation calibrated.
uint8_t gyro_abi_send_id
Filter out and send only a specific ABI id in telemetry for the gyro.
uint8_t abi_id
ABI sensor ID.
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...
abstract IMU interface providing fixed point interface
Measured sample rate of a sensor, counted against the timestamps.
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.