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)
64 pprz_msg_send_AHRS_EULER_INT(trans,
dev, AC_ID,
81 if (t_diff > 50000) { mde = 5; }
91 #ifndef AHRS_MADGWICK_IMU_ID
92 #define AHRS_MADGWICK_IMU_ID ABI_BROADCAST
97 #ifndef AHRS_MADGWICK_MAG_ID
98 #define AHRS_MADGWICK_MAG_ID AHRS_MADGWICK_IMU_ID
117 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
123 float dt = (float)(stamp - last_stamp) * 1e-6;
129 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS Madgwick propagation.")
142 uint32_t stamp __attribute__((unused)),
153 uint32_t stamp __attribute__((unused)),
155 struct Int32Vect3 *lp_mag __attribute__((unused)))
202 #if PERIODIC_TELEMETRY
Main include for ABI (AirBorneInterface).
#define ABI_BROADCAST
Broadcast address.
Event structure to store callbacks in a linked list.
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
Dispatcher to register actual AHRS implementations.
#define AHRS_COMP_ID_MADGWICK
struct AhrsMadgwick ahrs_madgwick
void ahrs_madgwick_propagate(struct FloatRates *gyro, float dt)
void ahrs_madgwick_update_accel(struct FloatVect3 *accel)
void ahrs_madgwick_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel)
void ahrs_madgwick_init(void)
bool is_aligned
aligned flag
struct FloatRates rates
Measured gyro rates.
struct FloatQuat quat
Estimated attitude (quaternion)
static void compute_body_orientation_and_rates(void)
Compute body orientation and rates from imu orientation and rates.
#define AHRS_MADGWICK_IMU_ID
IMU (gyro, accel)
static uint8_t ahrs_madgwick_id
static abi_event accel_ev
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
Call ahrs_madgwick_propagate on new gyro measurements.
static uint32_t ahrs_madgwick_last_stamp
last gyro msg timestamp
static abi_event aligner_ev
static void send_filter_status(struct transport_tx *trans, struct link_device *dev)
#define AHRS_MADGWICK_MAG_ID
magnetometer
static bool ahrs_madgwick_enable_output(bool enable)
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
void ahrs_madgwick_register(void)
static void aligner_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
#define AHRS_MADGWICK_OUTPUT_ENABLED
static void send_att(struct transport_tx *trans, struct link_device *dev)
static bool ahrs_madgwick_output_enabled
if TRUE with push the estimation results to the state interface
Paparazzi specific wrapper to run Madgwick ahrs filter.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
#define EULERS_BFP_OF_REAL(_ei, _ef)
#define RATES_FLOAT_OF_BFP(_rf, _ri)
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
int32_t phi
in rad with INT32_ANGLE_FRAC
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t theta
in rad with INT32_ANGLE_FRAC
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
#define AHRS_PROPAGATE_FREQUENCY
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
API to get/set the generic vehicle states.
static const struct usb_device_descriptor dev
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
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.