33 #ifndef AHRS_MLKF_OUTPUT_ENABLED
34 #define AHRS_MLKF_OUTPUT_ENABLED TRUE
45 #if PERIODIC_TELEMETRY
49 static void send_euler(
struct transport_tx *trans,
struct link_device *
dev)
53 pprz_msg_send_AHRS_EULER(trans, dev, AC_ID,
54 <p_to_imu_euler.
phi,
55 <p_to_imu_euler.
theta,
56 <p_to_imu_euler.
psi,
60 static void send_bias(
struct transport_tx *trans,
struct link_device *
dev)
64 pprz_msg_send_AHRS_GYRO_BIAS_INT(trans, dev, AC_ID,
70 pprz_msg_send_GEO_MAG(trans, dev, AC_ID,
81 if (t_diff > 50000) { mde = 5; }
82 pprz_msg_send_STATE_FILTER_STATUS(trans, dev, AC_ID, &
ahrs_mlkf_id, &mde, &val);
90 #ifndef AHRS_MLKF_IMU_ID
91 #define AHRS_MLKF_IMU_ID ABI_BROADCAST
97 #ifndef AHRS_MLKF_MAG_ID
98 #define AHRS_MLKF_MAG_ID AHRS_MLKF_IMU_ID
112 ahrs_mlkf_last_stamp = stamp;
116 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
122 float dt = (float)(stamp - last_stamp) * 1e-6;
128 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_MLKF propagation.")
139 uint32_t stamp __attribute__((unused)),
151 uint32_t stamp __attribute__((unused)),
163 uint32_t stamp __attribute__((unused)),
195 ahrs_mlkf_output_enabled = enable;
204 if (ahrs_mlkf_output_enabled) {
238 #if PERIODIC_TELEMETRY
static void send_geo_mag(struct transport_tx *trans, struct link_device *dev)
static void send_bias(struct transport_tx *trans, struct link_device *dev)
void ahrs_mlkf_propagate(struct FloatRates *gyro, float dt)
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.
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
#define RATES_BFP_OF_REAL(_ri, _rf)
Dispatcher to register actual AHRS implementations.
static void send_filter_status(struct transport_tx *trans, struct link_device *dev)
#define AHRS_MLKF_IMU_ID
ABI binding for IMU data.
#define AHRS_PROPAGATE_FREQUENCY
static abi_event body_to_imu_ev
#define AHRS_MLKF_OUTPUT_ENABLED
Periodic telemetry system header (includes downlink utility and generated code).
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
Paparazzi specific wrapper to run MLKF filter.
struct FloatRates imu_rate
Rotational velocity in IMU frame.
static abi_event accel_ev
Main include for ABI (AirBorneInterface).
static void aligner_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
static void mag_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *mag)
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
void ahrs_mlkf_update_accel(struct FloatVect3 *accel)
static void send_euler(struct transport_tx *trans, struct link_device *dev)
struct FloatRates gyro_bias
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
enum AhrsMlkfStatus status
static void set_body_state_from_quat(void)
Compute body orientation and rates from imu orientation and rates.
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static abi_event geo_mag_ev
static uint32_t ahrs_mlkf_last_stamp
static abi_event aligner_ev
static bool ahrs_mlkf_enable_output(bool enable)
bool ahrs_mlkf_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
int32_t r
in rad/s with INT32_RATE_FRAC
#define RATES_FLOAT_OF_BFP(_rf, _ri)
void ahrs_mlkf_update_mag(struct FloatVect3 *mag)
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
Architecture independent timing functions.
void ahrs_mlkf_set_body_to_imu_quat(struct FloatQuat *q_b2i)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define DefaultPeriodic
Set default periodic telemetry.
void ahrs_mlkf_init(void)
#define AHRS_COMP_ID_MLKF
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
static const struct usb_device_descriptor dev
struct AhrsMlkf ahrs_mlkf
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
API to get/set the generic vehicle states.
void float_rmat_transp_ratemult(struct FloatRates *rb, struct FloatRMat *m_b2a, struct FloatRates *ra)
rotate anglular rates by transposed rotation matrix.
static bool ahrs_mlkf_output_enabled
if TRUE with push the estimation results to the state interface
struct OrientationReps body_to_imu
body_to_imu rotation
static uint8_t ahrs_mlkf_id
struct FloatQuat ltp_to_imu_quat
Rotation from LocalTangentPlane to IMU frame as unit quaternion.
int32_t p
in rad/s with INT32_RATE_FRAC
#define AHRS_MLKF_MAG_ID
ABI binding for magnetometer data.
#define ABI_BROADCAST
Broadcast address.
#define MAGS_FLOAT_OF_BFP(_ef, _ei)
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'
int32_t q
in rad/s with INT32_RATE_FRAC
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).
static void geo_mag_cb(uint8_t sender_id, struct FloatVect3 *h)
void ahrs_mlkf_register(void)