32 #ifndef AHRS_FC_OUTPUT_ENABLED
33 #define AHRS_FC_OUTPUT_ENABLED TRUE
44 #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_body_euler.
phi,
55 <p_to_body_euler.
theta,
56 <p_to_body_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,
76 pprz_msg_send_AHRS_EULER_INT(trans,
dev, AC_ID,
88 pprz_msg_send_GEO_MAG(trans,
dev, AC_ID,
99 if (t_diff > 50000) { mde = 5; }
100 pprz_msg_send_STATE_FILTER_STATUS(trans,
dev, AC_ID, &
ahrs_fc_id, &mde, &
val);
108 #ifndef AHRS_FC_IMU_ID
109 #define AHRS_FC_IMU_ID ABI_BROADCAST
115 #ifndef AHRS_FC_MAG_ID
116 #define AHRS_FC_MAG_ID AHRS_FC_IMU_ID
122 #ifndef AHRS_FC_GPS_ID
123 #define AHRS_FC_GPS_ID GPS_MULTI_ID
141 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
147 float dt = (float)(stamp - last_stamp) * 1e-6;
153 PRINT_CONFIG_MSG(
"Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS_FC propagation.")
164 uint32_t __attribute__((unused)) stamp,
170 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_CORRECT_FREQUENCY)
174 float dt = (float)(stamp - last_stamp) * 1e-6;
179 PRINT_CONFIG_MSG(
"Using fixed AHRS_CORRECT_FREQUENCY for AHRS float_cmpl accel update.")
180 PRINT_CONFIG_VAR(AHRS_CORRECT_FREQUENCY)
182 const float dt = 1. / (AHRS_CORRECT_FREQUENCY);
189 uint32_t __attribute__((unused)) stamp,
195 #if USE_AUTO_AHRS_FREQ || !defined(AHRS_MAG_CORRECT_FREQUENCY)
199 float dt = (float)(stamp - last_stamp) * 1e-6;
204 PRINT_CONFIG_MSG(
"Using fixed AHRS_MAG_CORRECT_FREQUENCY for AHRS float_cmpl mag update.")
205 PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
207 const float dt = 1. / (AHRS_MAG_CORRECT_FREQUENCY);
214 uint32_t stamp __attribute__((unused)),
239 uint32_t stamp __attribute__((unused)),
280 #if PERIODIC_TELEMETRY
static void h(const real32_T x[7], const real32_T q[4], real32_T y[6])
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.
struct AhrsFloatCmpl ahrs_fc
void ahrs_fc_update_mag(struct FloatVect3 *mag, float dt)
bool ahrs_fc_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
void ahrs_fc_propagate(struct FloatRates *gyro, float dt)
void ahrs_fc_update_accel(struct FloatVect3 *accel, float dt)
void ahrs_fc_update_gps(struct GpsState *gps_s)
struct FloatRates gyro_bias
struct FloatRates body_rate
struct FloatQuat ltp_to_body_quat
static uint8_t ahrs_fc_id
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static void compute_body_orientation_and_rates(void)
Compute body orientation and rates from imu orientation and rates.
static abi_event accel_ev
static void gyro_cb(uint8_t sender_id, uint32_t stamp, struct Int32Rates *gyro)
static void mag_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *mag)
#define AHRS_FC_MAG_ID
ABI binding for magnetometer data.
#define AHRS_FC_IMU_ID
ABI binding for IMU data.
static void send_geo_mag(struct transport_tx *trans, struct link_device *dev)
static abi_event aligner_ev
static abi_event geo_mag_ev
static void send_filter_status(struct transport_tx *trans, struct link_device *dev)
#define AHRS_FC_OUTPUT_ENABLED
void ahrs_fc_register(void)
static void send_euler_int(struct transport_tx *trans, struct link_device *dev)
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
static bool ahrs_fc_output_enabled
if TRUE with push the estimation results to the state interface
static void geo_mag_cb(uint8_t sender_id, struct FloatVect3 *h)
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 send_euler(struct transport_tx *trans, struct link_device *dev)
static uint32_t ahrs_fc_last_stamp
static void send_bias(struct transport_tx *trans, struct link_device *dev)
static bool ahrs_fc_enable_output(bool enable)
#define AHRS_FC_GPS_ID
ABI binding for gps data.
Paparazzi specific wrapper to run floating point complementary filter.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
data structure for GPS information
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
#define MAGS_FLOAT_OF_BFP(_ef, _ei)
#define EULERS_BFP_OF_REAL(_ei, _ef)
#define RATES_BFP_OF_REAL(_ri, _rf)
#define RATES_FLOAT_OF_BFP(_rf, _ri)
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t r
in rad/s with INT32_RATE_FRAC
int32_t phi
in rad with INT32_ANGLE_FRAC
int32_t q
in rad/s with INT32_RATE_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")
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.