32 #ifndef AHRS_FC_OUTPUT_ENABLED
33 #define AHRS_FC_OUTPUT_ENABLED TRUE
44 #if PERIODIC_TELEMETRY
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,
64 pprz_msg_send_AHRS_GYRO_BIAS_INT(trans, dev, AC_ID,
65 &gyro_bias.p, &gyro_bias.q, &gyro_bias.r, &
ahrs_fc_id);
80 pprz_msg_send_AHRS_EULER_INT(trans, dev, AC_ID,
92 pprz_msg_send_GEO_MAG(trans, dev, AC_ID,
103 if (t_diff > 50000) { mde = 5; }
104 pprz_msg_send_STATE_FILTER_STATUS(trans, dev, AC_ID, &
ahrs_fc_id, &mde, &val);
112 #ifndef AHRS_FC_IMU_ID
113 #define AHRS_FC_IMU_ID ABI_BROADCAST
119 #ifndef AHRS_FC_MAG_ID
120 #define AHRS_FC_MAG_ID AHRS_FC_IMU_ID
135 ahrs_fc_last_stamp = stamp;
136 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
142 float dt = (float)(stamp - last_stamp) * 1e-6;
148 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_FC propagation.")
159 uint32_t __attribute__((unused)) stamp,
162 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_CORRECT_FREQUENCY)
166 float dt = (float)(stamp - last_stamp) * 1e-6;
171 PRINT_CONFIG_MSG(
"Using fixed AHRS_CORRECT_FREQUENCY for AHRS float_cmpl accel update.")
172 PRINT_CONFIG_VAR(AHRS_CORRECT_FREQUENCY)
174 const float dt = 1. / (AHRS_CORRECT_FREQUENCY);
181 uint32_t __attribute__((unused)) stamp,
184 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_MAG_CORRECT_FREQUENCY)
188 float dt = (float)(stamp - last_stamp) * 1e-6;
193 PRINT_CONFIG_MSG(
"Using fixed AHRS_MAG_CORRECT_FREQUENCY for AHRS float_cmpl mag update.")
194 PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
196 const float dt = 1. / (AHRS_MAG_CORRECT_FREQUENCY);
203 uint32_t stamp __attribute__((unused)),
226 uint32_t stamp __attribute__((unused)),
235 ahrs_fc_output_enabled = enable;
244 if (ahrs_fc_output_enabled) {
276 #if PERIODIC_TELEMETRY
int32_t psi
in rad with INT32_ANGLE_FRAC
Event structure to store callbacks in a linked list.
#define AHRS_FC_IMU_ID
ABI binding for IMU data.
#define RATES_BFP_OF_REAL(_ri, _rf)
Dispatcher to register actual AHRS implementations.
struct FloatRates gyro_bias
Generic transmission transport header.
static abi_event accel_ev
static void geo_mag_cb(uint8_t sender_id, struct FloatVect3 *h)
#define AHRS_PROPAGATE_FREQUENCY
#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
static struct Int32Eulers * orientationGetEulers_i(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (int).
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
static abi_event aligner_ev
Main include for ABI (AirBorneInterface).
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
static uint32_t ahrs_fc_last_stamp
struct FloatQuat ltp_to_imu_quat
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
bool_t ahrs_fc_align(struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
Architecture independent timing functions.
data structure for GPS information
#define AHRS_FC_MAG_ID
ABI binding for magnetometer data.
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")
void ahrs_fc_register(void)
#define DefaultPeriodic
Set default periodic telemetry.
static bool_t ahrs_fc_output_enabled
if TRUE with push the estimation results to the state interface
static abi_event body_to_imu_ev
void ahrs_fc_update_mag(struct Int32Vect3 *mag, float dt)
void ahrs_fc_set_body_to_imu_quat(struct FloatQuat *q_b2i)
static const struct usb_device_descriptor dev
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
static uint8_t ahrs_fc_id
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.
struct FloatRates imu_rate
void ahrs_fc_update_gps(struct GpsState *gps_s)
struct OrientationReps body_to_imu
Paparazzi specific wrapper to run floating point complementary filter.
void ahrs_fc_recompute_ltp_to_body(void)
void ahrs_fc_update_accel(struct Int32Vect3 *accel, float dt)
#define ABI_BROADCAST
Broadcast address.
static bool_t ahrs_fc_enable_output(bool_t enable)
static void aligner_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
void ahrs_fc_propagate(struct Int32Rates *gyro, float dt)
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)
struct AhrsFloatCmpl ahrs_fc
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 abi_event geo_mag_ev
struct OrientationReps ltp_to_body
#define AHRS_FC_OUTPUT_ENABLED
static void mag_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *mag)