31 #include "message_pragmas.h"
34 #ifndef AHRS_MADGWICK_OUTPUT_ENABLED
35 #define AHRS_MADGWICK_OUTPUT_ENABLED TRUE
47 #if PERIODIC_TELEMETRY
50 static void send_att(
struct transport_tx *trans,
struct link_device *
dev)
67 pprz_msg_send_AHRS_EULER_INT(trans, dev, AC_ID,
84 if (t_diff > 50000) { mde = 5; }
85 pprz_msg_send_STATE_FILTER_STATUS(trans, dev, AC_ID, &
ahrs_madgwick_id, &mde, &val);
94 #ifndef AHRS_MADGWICK_IMU_ID
95 #define AHRS_MADGWICK_IMU_ID ABI_BROADCAST
100 #ifndef AHRS_MADGWICK_MAG_ID
101 #define AHRS_MADGWICK_MAG_ID AHRS_MADGWICK_IMU_ID
121 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
127 float dt = (float)(stamp - last_stamp) * 1e-6;
133 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS Madgwick propagation.")
142 ahrs_madgwick_last_stamp = stamp;
146 uint32_t stamp __attribute__((unused)),
157 uint32_t stamp __attribute__((unused)),
159 struct Int32Vect3 *lp_mag __attribute__((unused)))
180 ahrs_madgwick_output_enabled = enable;
189 if (ahrs_madgwick_output_enabled) {
217 #if PERIODIC_TELEMETRY
static bool ahrs_madgwick_output_enabled
if TRUE with push the estimation results to the state interface
#define AHRS_MADGWICK_IMU_ID
IMU (gyro, accel)
int32_t psi
in rad with INT32_ANGLE_FRAC
Event structure to store callbacks in a linked list.
void float_quat_comp_inv(struct FloatQuat *a2b, struct FloatQuat *a2c, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.
void ahrs_madgwick_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel)
void ahrs_madgwick_propagate(struct FloatRates *gyro, float dt)
Dispatcher to register actual AHRS implementations.
void ahrs_madgwick_update_accel(struct FloatVect3 *accel)
#define AHRS_PROPAGATE_FREQUENCY
#define EULERS_BFP_OF_REAL(_ei, _ef)
Periodic telemetry system header (includes downlink utility and generated code).
static abi_event accel_ev
int32_t theta
in rad with INT32_ANGLE_FRAC
#define AHRS_MADGWICK_MAG_ID
magnetometer
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
Call ahrs_madgwick_propagate on new gyro measurements.
Main include for ABI (AirBorneInterface).
static abi_event aligner_ev
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
struct AhrsMadgwick ahrs_madgwick
#define AHRS_MADGWICK_OUTPUT_ENABLED
bool is_aligned
aligned flag
static void send_filter_status(struct transport_tx *trans, struct link_device *dev)
struct FloatQuat quat
Estimated attitude (quaternion)
#define RATES_FLOAT_OF_BFP(_rf, _ri)
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
Architecture independent timing functions.
struct FloatRates rates
Measured gyro rates.
static void send_att(struct transport_tx *trans, struct link_device *dev)
static uint8_t ahrs_madgwick_id
static void compute_body_orientation_and_rates(void)
Compute body orientation and rates from imu orientation and rates.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define DefaultPeriodic
Set default periodic telemetry.
void ahrs_madgwick_register(void)
void ahrs_madgwick_set_body_to_imu_quat(struct FloatQuat *q_b2i)
Paparazzi specific wrapper to run Madgwick ahrs filter.
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
static const struct usb_device_descriptor dev
#define AHRS_COMP_ID_MADGWICK
int32_t phi
in rad with INT32_ANGLE_FRAC
API to get/set the generic vehicle states.
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static uint32_t ahrs_madgwick_last_stamp
last gyro msg timestamp
static abi_event body_to_imu_ev
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
void ahrs_madgwick_init(void)
static void aligner_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
static bool ahrs_madgwick_enable_output(bool enable)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
struct OrientationReps body_to_imu
body_to_imu rotation