38 #ifndef IMU_POWER_GPIO_ON
39 #define IMU_POWER_GPIO_ON gpio_set
43 #if PERIODIC_TELEMETRY
48 pprz_msg_send_IMU_ACCEL_RAW(trans, dev, AC_ID,
54 pprz_msg_send_IMU_ACCEL_SCALED(trans, dev, AC_ID,
58 static void send_accel(
struct transport_tx *trans,
struct link_device *
dev)
62 pprz_msg_send_IMU_ACCEL(trans, dev, AC_ID,
63 &accel_float.
x, &accel_float.
y, &accel_float.
z);
68 pprz_msg_send_IMU_GYRO_RAW(trans, dev, AC_ID,
74 pprz_msg_send_IMU_GYRO_SCALED(trans, dev, AC_ID,
78 static void send_gyro(
struct transport_tx *trans,
struct link_device *
dev)
82 pprz_msg_send_IMU_GYRO(trans, dev, AC_ID,
83 &gyro_float.
p, &gyro_float.
q, &gyro_float.
r);
88 pprz_msg_send_IMU_MAG_RAW(trans, dev, AC_ID,
94 pprz_msg_send_IMU_MAG_SCALED(trans, dev, AC_ID,
98 static void send_mag(
struct transport_tx *trans,
struct link_device *
dev)
102 pprz_msg_send_IMU_MAG(trans, dev, AC_ID,
103 &mag_float.
x, &mag_float.
y, &mag_float.
z);
113 #ifdef IMU_POWER_GPIO
123 #if defined IMU_MAG_X_NEUTRAL && defined IMU_MAG_Y_NEUTRAL && defined IMU_MAG_Z_NEUTRAL
126 #if USE_MAGNETOMETER && (!defined MAG_CALIB_UKF_H)
127 INFO(
"Magnetometer neutrals are set to zero, you should calibrate!")
136 #if PERIODIC_TELEMETRY
155 body_to_imu_eulers.phi =
phi;
164 body_to_imu_eulers.theta =
theta;
173 body_to_imu_eulers.psi =
psi;
230 #if !defined SITL && defined IMU_MAG_X_CURRENT_COEF && defined IMU_MAG_Y_CURRENT_COEF && defined IMU_MAG_Z_CURRENT_COEF
245 #elif USE_MAGNETOMETER
#define IMU_GYRO_Q_SENS_DEN
int32_t current
current in milliamps
#define IMU_BODY_TO_IMU_THETA
void WEAK imu_scale_gyro(struct Imu *_imu)
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
#define IMU_MAG_Z_SENS_DEN
Periodic telemetry system header (includes downlink utility and generated code).
struct Int32Vect3 accel_neutral
static accelerometer bias from calibration in raw/unscaled units
struct Int32Rates gyro_prev
previous gyroscope measurements
Some architecture independent helper functions for GPIOs.
#define VECT3_COPY(_a, _b)
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define RATES_ASSIGN(_ra, _p, _q, _r)
static void send_accel(struct transport_tx *trans, struct link_device *dev)
Main include for ABI (AirBorneInterface).
bool b2i_set_current
flag for adjusting body_to_imu via settings.
void WEAK imu_scale_accel(struct Imu *_imu)
static void send_mag_raw(struct transport_tx *trans, struct link_device *dev)
#define IMU_GYRO_Q_SENS_NUM
void imu_SetBodyToImuPhi(float phi)
#define IMU_GYRO_P_SENS_NUM
void WEAK imu_scale_mag(struct Imu *_imu)
#define IMU_ACCEL_Y_SENS_DEN
struct Imu imu
global IMU state
#define IMU_GYRO_R_SENS_NUM
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
#define IMU_GYRO_P_NEUTRAL
static void send_mag(struct transport_tx *trans, struct link_device *dev)
static void send_gyro_scaled(struct transport_tx *trans, struct link_device *dev)
struct Int32Rates gyro_neutral
static gyroscope bias from calibration in raw/unscaled units
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
int32_t r
in rad/s with INT32_RATE_FRAC
static void send_accel_raw(struct transport_tx *trans, struct link_device *dev)
#define IMU_MAG_Y_SENS_NUM
#define IMU_MAG_X_SENS_NUM
static void send_gyro(struct transport_tx *trans, struct link_device *dev)
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
#define IMU_GYRO_P_SENS_DEN
#define RATES_FLOAT_OF_BFP(_rf, _ri)
static bool stateIsAttitudeValid(void)
Test if attitudes are valid.
Interface for electrical status: supply voltage, current, battery status, etc.
struct Int32Vect3 mag_neutral
magnetometer neutral readings (bias) in raw/unscaled units
#define DefaultPeriodic
Set default periodic telemetry.
static void send_gyro_raw(struct transport_tx *trans, struct link_device *dev)
#define IMU_ACCEL_Z_SENS_DEN
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Inertial Measurement Unit interface.
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
struct OrientationReps body_to_imu
rotation from body to imu frame
#define IMU_MAG_X_SENS_DEN
static const struct usb_device_descriptor dev
#define IMU_ACCEL_Z_NEUTRAL
#define INT_VECT3_ZERO(_v)
void imu_SetBodyToImuCurrent(float set)
API to get/set the generic vehicle states.
#define IMU_ACCEL_X_SENS_DEN
static struct FloatEulers * orientationGetEulers_f(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (float).
#define IMU_MAG_Z_SENS_NUM
struct Int32Vect3 accel_prev
previous accelerometer measurements
void imu_SetBodyToImuPsi(float psi)
int32_t p
in rad/s with INT32_RATE_FRAC
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
#define MAGS_FLOAT_OF_BFP(_ef, _ei)
#define IMU_ACCEL_Y_NEUTRAL
struct Electrical electrical
#define RATES_COPY(_a, _b)
abstract IMU interface providing fixed point interface
#define IMU_ACCEL_Y_SENS_NUM
#define IMU_BODY_TO_IMU_PSI
#define IMU_GYRO_R_SENS_DEN
static void send_mag_scaled(struct transport_tx *trans, struct link_device *dev)
#define IMU_GYRO_Q_NEUTRAL
#define IMU_ACCEL_Z_SENS_NUM
int32_t q
in rad/s with INT32_RATE_FRAC
#define IMU_GYRO_R_NEUTRAL
#define IMU_BODY_TO_IMU_PHI
#define IMU_ACCEL_X_NEUTRAL
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
void imu_SetBodyToImuTheta(float theta)
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
#define IMU_ACCEL_X_SENS_NUM
static void send_accel_scaled(struct transport_tx *trans, struct link_device *dev)
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
#define IMU_MAG_Y_SENS_DEN
static void orientationSetEulers_f(struct OrientationReps *orientation, struct FloatEulers *eulers)
Set vehicle body attitude from euler angles (float).