diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index ca2fcbca1b..c76f12b1d5 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -93,8 +93,6 @@ static inline void on_gyro_event( void ); static inline void on_accel_event( void ); static inline void on_mag_event( void ); volatile uint8_t ahrs_timeout_counter = 0; -#else -static inline void on_ahrs_event(void); #endif // USE_IMU #endif // USE_AHRS @@ -587,13 +585,9 @@ void event_task_ap( void ) { i2c_event(); #endif -#if USE_AHRS -#if USE_IMU +#if USE_AHRS && USE_IMU ImuEvent(on_gyro_event, on_accel_event, on_mag_event); -#else - AhrsEvent(on_ahrs_event); -#endif // USE_IMU -#endif // USE_AHRS +#endif #if USE_GPS GpsEvent(on_gps_solution); @@ -725,13 +719,6 @@ static inline void on_mag_event(void) #endif } -#else // USE_IMU not defined -static inline void on_ahrs_event(void) -{ -#ifdef AHRS_UPDATE_FW_ESTIMATOR - ahrs_update_fw_estimator(); -#endif -} #endif // USE_IMU #endif // USE_AHRS diff --git a/sw/airborne/subsystems/ahrs/ahrs_infrared.h b/sw/airborne/subsystems/ahrs/ahrs_infrared.h index 43a2b3b340..a4d2870756 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_infrared.h +++ b/sw/airborne/subsystems/ahrs/ahrs_infrared.h @@ -36,7 +36,4 @@ extern void ahrs_update_infrared(void); // TODO copy ahrs to state instead of estimator extern void ahrs_update_fw_estimator(void); -#define AhrsEvent(_available_callback) { \ - } - #endif /* AHRS_INFRARED_H */ diff --git a/sw/airborne/subsystems/ahrs/ahrs_sim.c b/sw/airborne/subsystems/ahrs/ahrs_sim.c index 290602091b..3dcfcf0263 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_sim.c +++ b/sw/airborne/subsystems/ahrs/ahrs_sim.c @@ -53,6 +53,10 @@ void update_ahrs_from_sim(void) { FLOAT_RMAT_OF_EULERS(ahrs_float.ltp_to_imu_rmat, ahrs_float.ltp_to_imu_euler); compute_body_orientation_and_rates(); + +#ifdef AHRS_UPDATE_FW_ESTIMATOR + ahrs_update_fw_estimator(); +#endif } @@ -92,6 +96,10 @@ void ahrs_align(void) void ahrs_propagate(void) { + if (ahrs_sim_available) { + update_ahrs_from_sim(); + ahrs_sim_available = FALSE; + } } void ahrs_update_accel(void) { diff --git a/sw/airborne/subsystems/ahrs/ahrs_sim.h b/sw/airborne/subsystems/ahrs/ahrs_sim.h index 7aca2313a7..ee36d402be 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_sim.h +++ b/sw/airborne/subsystems/ahrs/ahrs_sim.h @@ -37,14 +37,4 @@ extern float ins_pitch_neutral; extern void update_ahrs_from_sim(void); -#define AhrsEvent(_available_callback) { \ - if (ahrs_sim_available) { \ - update_ahrs_from_sim(); \ - _available_callback(); \ - ahrs_sim_available = FALSE; \ - } \ - } - - - #endif /* AHRS_SIM_H */