mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-28 18:07:25 +08:00
[fixedwing] pass imu measurements to ahrs functions to test the refactoring
This commit is contained in:
@@ -137,6 +137,10 @@ INFO_VALUE("it is recommended to configure in your airframe PERIODIC_FREQUENCY t
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define __DefaultAhrsRegister(_x) _x ## _register()
|
||||||
|
#define _DefaultAhrsRegister(_x) __DefaultAhrsRegister(_x)
|
||||||
|
#define DefaultAhrsRegister() _DefaultAhrsRegister(DefaultAhrsImpl)
|
||||||
|
|
||||||
static inline void on_gyro_event( void );
|
static inline void on_gyro_event( void );
|
||||||
static inline void on_accel_event( void );
|
static inline void on_accel_event( void );
|
||||||
static inline void on_mag_event( void );
|
static inline void on_mag_event( void );
|
||||||
@@ -199,6 +203,7 @@ void init_ap( void ) {
|
|||||||
|
|
||||||
#if USE_AHRS
|
#if USE_AHRS
|
||||||
ahrs_init();
|
ahrs_init();
|
||||||
|
DefaultAhrsRegister();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_AHRS && USE_IMU
|
#if USE_AHRS && USE_IMU
|
||||||
@@ -599,7 +604,7 @@ void sensors_task( void ) {
|
|||||||
//FIXME: this is just a kludge
|
//FIXME: this is just a kludge
|
||||||
#if USE_AHRS && defined SITL && !USE_NPS
|
#if USE_AHRS && defined SITL && !USE_NPS
|
||||||
// dt is not really used in ahrs_sim
|
// dt is not really used in ahrs_sim
|
||||||
ahrs_propagate(1./PERIODIC_FREQUENCY);
|
ahrs_propagate(&imu.gyro, 1./PERIODIC_FREQUENCY);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_GPS
|
#if USE_GPS
|
||||||
@@ -738,8 +743,8 @@ PRINT_CONFIG_VAR(AHRS_CORRECT_FREQUENCY)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
imu_scale_accel(&imu);
|
imu_scale_accel(&imu);
|
||||||
if (ahrs.status != AHRS_UNINIT) {
|
if (ahrs.status == AHRS_RUNNING) {
|
||||||
ahrs_update_accel(dt);
|
ahrs_update_accel(&imu.accel, dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,15 +770,18 @@ PRINT_CONFIG_VAR(AHRS_PROPAGATE_FREQUENCY)
|
|||||||
|
|
||||||
#if USE_AHRS_ALIGNER
|
#if USE_AHRS_ALIGNER
|
||||||
// Run aligner on raw data as it also makes averages.
|
// Run aligner on raw data as it also makes averages.
|
||||||
if (ahrs.status == AHRS_UNINIT) {
|
if (ahrs.status == AHRS_REGISTERED) {
|
||||||
ahrs_aligner_run();
|
ahrs_aligner_run();
|
||||||
if (ahrs_aligner.status == AHRS_ALIGNER_LOCKED)
|
if (ahrs_aligner.status == AHRS_ALIGNER_LOCKED) {
|
||||||
ahrs_align();
|
if (ahrs_align(&ahrs_aligner.lp_gyro, &ahrs_aligner.lp_accel, &ahrs_aligner.lp_mag)) {
|
||||||
|
ahrs.status = AHRS_RUNNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ahrs_propagate(dt);
|
ahrs_propagate(&imu.gyro_prev, dt);
|
||||||
|
|
||||||
#if defined SITL && USE_NPS
|
#if defined SITL && USE_NPS
|
||||||
if (nps_bypass_ahrs) sim_overwrite_ahrs();
|
if (nps_bypass_ahrs) sim_overwrite_ahrs();
|
||||||
@@ -805,7 +813,7 @@ PRINT_CONFIG_VAR(AHRS_MAG_CORRECT_FREQUENCY)
|
|||||||
|
|
||||||
imu_scale_mag(&imu);
|
imu_scale_mag(&imu);
|
||||||
if (ahrs.status == AHRS_RUNNING) {
|
if (ahrs.status == AHRS_RUNNING) {
|
||||||
ahrs_update_mag(dt);
|
ahrs_update_mag(&imu.mag, dt);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user