32 #ifndef AHRS_ICQ_OUTPUT_ENABLED
33 #define AHRS_ICQ_OUTPUT_ENABLED TRUE
44 #if PERIODIC_TELEMETRY
52 pprz_msg_send_AHRS_QUAT_INT(trans, dev, AC_ID,
70 pprz_msg_send_AHRS_EULER_INT(trans, dev, AC_ID,
71 <p_to_imu_euler.phi,
72 <p_to_imu_euler.theta,
73 <p_to_imu_euler.psi,
82 pprz_msg_send_AHRS_GYRO_BIAS_INT(trans, dev, AC_ID,
93 pprz_msg_send_GEO_MAG(trans, dev, AC_ID,
104 if (t_diff > 50000) { mde = 5; }
105 pprz_msg_send_STATE_FILTER_STATUS(trans, dev, AC_ID, &
ahrs_icq_id, &mde, &val);
113 #ifndef AHRS_ICQ_IMU_ID
114 #define AHRS_ICQ_IMU_ID ABI_BROADCAST
120 #ifndef AHRS_ICQ_MAG_ID
121 #define AHRS_ICQ_MAG_ID AHRS_ICQ_IMU_ID
136 ahrs_icq_last_stamp = stamp;
137 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
143 float dt = (float)(stamp - last_stamp) * 1e-6;
149 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_ICQ propagation.")
160 uint32_t __attribute__((unused)) stamp,
163 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_CORRECT_FREQUENCY)
167 float dt = (float)(stamp - last_stamp) * 1e-6;
173 PRINT_CONFIG_MSG(
"Using fixed AHRS_CORRECT_FREQUENCY for AHRS int_cmpl_quat accel update.")
174 PRINT_CONFIG_VAR(AHRS_CORRECT_FREQUENCY)
176 const float dt = 1. / (AHRS_CORRECT_FREQUENCY);
184 uint32_t __attribute__((unused)) stamp,
187 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_MAG_CORRECT_FREQUENCY)
191 float dt = (float)(stamp - last_stamp) * 1e-6;
197 PRINT_CONFIG_MSG(
"Using fixed AHRS_MAG_CORRECT_FREQUENCY for AHRS int_cmpl_quat mag update.")
198 PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
200 const float dt = 1. / (AHRS_MAG_CORRECT_FREQUENCY);
208 uint32_t stamp __attribute__((unused)),
232 uint32_t stamp __attribute__((unused)),
240 ahrs_icq_output_enabled = enable;
247 if (ahrs_icq_output_enabled) {
281 #if PERIODIC_TELEMETRY
int32_t psi
in rad with INT32_ANGLE_FRAC
static abi_event geo_mag_ev
Event structure to store callbacks in a linked list.
struct AhrsIntCmplQuat ahrs_icq
void ahrs_icq_update_mag(struct Int32Vect3 *mag, float dt)
static abi_event body_to_imu_ev
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
struct OrientationReps body_to_imu
Dispatcher to register actual AHRS implementations.
Generic transmission transport header.
#define AHRS_PROPAGATE_FREQUENCY
Periodic telemetry system header (includes downlink utility and generated code).
int32_t theta
in rad with INT32_ANGLE_FRAC
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
void ahrs_icq_update_gps(struct GpsState *gps_s)
#define VECT3_ASSIGN(_a, _x, _y, _z)
Main include for ABI (AirBorneInterface).
static void mag_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *mag)
#define MAG_FLOAT_OF_BFP(_ai)
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
static abi_event accel_ev
static uint8_t ahrs_icq_id
static bool_t ahrs_icq_enable_output(bool_t enable)
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
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_icq_update_accel(struct Int32Vect3 *accel, float dt)
void ahrs_icq_propagate(struct Int32Rates *gyro, float dt)
void ahrs_icq_set_body_to_imu_quat(struct FloatQuat *q_b2i)
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Paparazzi specific wrapper to run floating point complementary filter.
static bool_t ahrs_icq_output_enabled
if TRUE with push the estimation results to the state interface
int32_t r
in rad/s with INT32_RATE_FRAC
void ahrs_icq_register(void)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
struct Int32Rates gyro_bias
#define AHRS_ICQ_IMU_ID
ABI binding for IMU data.
void ahrs_register_impl(AhrsEnableOutput enable)
Register an AHRS implementation.
struct Int32Quat ltp_to_imu_quat
#define MAG_BFP_OF_REAL(_af)
Architecture independent timing functions.
data structure for GPS information
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
bool_t ahrs_icq_align(struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
#define DefaultPeriodic
Set default periodic telemetry.
void int32_quat_comp_inv(struct Int32Quat *a2b, struct Int32Quat *a2c, struct Int32Quat *b2c)
Composition (multiplication) of two quaternions.
static void stateSetBodyRates_i(struct Int32Rates *body_rate)
Set vehicle body angular rate (int).
static uint32_t ahrs_icq_last_stamp
static void stateSetNedToBodyQuat_i(struct Int32Quat *ned_to_body_quat)
Set vehicle body attitude from quaternion (int).
#define AHRS_ICQ_OUTPUT_ENABLED
static const struct usb_device_descriptor dev
void int32_eulers_of_quat(struct Int32Eulers *e, struct Int32Quat *q)
static abi_event aligner_ev
int32_t phi
in rad with INT32_ANGLE_FRAC
API to get/set the generic vehicle states.
static struct Int32Quat * orientationGetQuat_i(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (int).
static void geo_mag_cb(uint8_t sender_id, struct FloatVect3 *h)
static void set_body_state_from_quat(void)
Rotate angles and rates from imu to body frame and set state.
struct Int32Rates imu_rate
int32_t p
in rad/s with INT32_RATE_FRAC
#define ABI_BROADCAST
Broadcast address.
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
void int32_rmat_transp_ratemult(struct Int32Rates *rb, struct Int32RMat *m_b2a, struct Int32Rates *ra)
rotate anglular rates by transposed rotation matrix.
#define AHRS_ICQ_MAG_ID
ABI binding for magnetometer data.
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.
enum AhrsICQStatus status
status of the AHRS, AHRS_ICQ_UNINIT or AHRS_ICQ_RUNNING