32 #include "message_pragmas.h"
35 #ifndef AHRS_FINV_OUTPUT_ENABLED
36 #define AHRS_FINV_OUTPUT_ENABLED TRUE
38 PRINT_CONFIG_VAR(AHRS_INV_OUTPUT_ENABLED)
48 #if PERIODIC_TELEMETRY
51 static void send_att(
struct transport_tx *trans,
struct link_device *
dev)
68 pprz_msg_send_AHRS_EULER_INT(trans, dev, AC_ID,
80 pprz_msg_send_GEO_MAG(trans, dev, AC_ID,
93 if (t_diff > 50000) { mde = 5; }
94 pprz_msg_send_STATE_FILTER_STATUS(trans, dev, AC_ID, &
ahrs_finv_id, &mde, &val);
103 #ifndef AHRS_FINV_IMU_ID
104 #define AHRS_FINV_IMU_ID ABI_BROADCAST
109 #ifndef AHRS_FINV_MAG_ID
110 #define AHRS_FINV_MAG_ID AHRS_FINV_IMU_ID
132 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
138 float dt = (float)(stamp - last_stamp) * 1e-6;
144 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS float_invariant propagation.")
153 ahrs_finv_last_stamp = stamp;
157 uint32_t stamp __attribute__((unused)),
168 uint32_t stamp __attribute__((unused)),
179 uint32_t stamp __attribute__((unused)),
209 ahrs_finv_output_enabled = enable;
218 if (ahrs_finv_output_enabled) {
253 #if PERIODIC_TELEMETRY
int32_t psi
in rad with INT32_ANGLE_FRAC
Event structure to store callbacks in a linked list.
static abi_event geo_mag_ev
static bool ahrs_finv_output_enabled
if TRUE with push the estimation results to the state interface
void float_quat_comp_inv(struct FloatQuat *a2b, struct FloatQuat *a2c, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions.
static void send_att(struct transport_tx *trans, struct link_device *dev)
#define AHRS_COMP_ID_FINV
static void send_geo_mag(struct transport_tx *trans, struct link_device *dev)
Dispatcher to register actual AHRS implementations.
static uint8_t ahrs_finv_id
static void mag_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *mag)
struct OrientationReps body_to_imu
body_to_imu rotation
#define AHRS_PROPAGATE_FREQUENCY
void ahrs_float_invariant_init(void)
#define EULERS_BFP_OF_REAL(_ei, _ef)
Periodic telemetry system header (includes downlink utility and generated code).
int32_t theta
in rad with INT32_ANGLE_FRAC
struct FloatQuat quat
Estimated attitude (quaternion)
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
static abi_event accel_ev
Main include for ABI (AirBorneInterface).
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
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 geo_mag_cb(uint8_t sender_id, struct FloatVect3 *h)
#define RATES_DIFF(_c, _a, _b)
void ahrs_float_invariant_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
struct inv_command cmd
command vector
void ahrs_float_invariant_propagate(struct FloatRates *gyro, float dt)
static uint32_t ahrs_finv_last_stamp
last gyro msg timestamp
void ahrs_float_invariant_update_accel(struct FloatVect3 *accel)
void ahrs_float_inv_set_body_to_imu_quat(struct FloatQuat *q_b2i)
#define RATES_FLOAT_OF_BFP(_rf, _ri)
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
Architecture independent timing functions.
static void compute_body_orientation_and_rates(void)
Compute body orientation and rates from imu orientation and rates.
Paparazzi specific wrapper to run INVARIANT ahrs filter.
struct FloatRates rates
Input gyro rates.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
void ahrs_float_invariant_update_mag(struct FloatVect3 *mag)
#define DefaultPeriodic
Set default periodic telemetry.
static void send_filter_status(struct transport_tx *trans, struct link_device *dev)
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
struct FloatRates bias
Estimated gyro biases.
static const struct usb_device_descriptor dev
#define AHRS_FINV_IMU_ID
IMU (gyro, accel)
static bool ahrs_float_invariant_enable_output(bool enable)
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
int32_t phi
in rad with INT32_ANGLE_FRAC
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 abi_event aligner_ev
#define AHRS_FINV_OUTPUT_ENABLED
#define ABI_BROADCAST
Broadcast address.
#define MAGS_FLOAT_OF_BFP(_ef, _ei)
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
Call ahrs_float_invariant_propagate on new gyro measurements.
static abi_event body_to_imu_ev
struct AhrsFloatInv ahrs_float_inv
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'
#define AHRS_FINV_MAG_ID
magnetometer
void ahrs_float_invariant_register(void)
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
struct inv_state state
state vector
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).