Skip to content

Commit

Permalink
[rotorcraft] ahrs dt: only calc if USE_AUTO_AHRS_FREQ or !defined(AHR…
Browse files Browse the repository at this point in the history
…S_PROPAGATE_FREQUENCY)
  • Loading branch information
flixr committed Sep 8, 2014
1 parent 7c3d72e commit ad17b25
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sw/airborne/firmwares/rotorcraft/main.c
Expand Up @@ -319,13 +319,20 @@ static inline void on_accel_event( void ) {
}

static inline void on_gyro_event( void ) {
#if USE_AUTO_AHRS_FREQ || !defined(AHRS_PROPAGATE_FREQUENCY)
PRINT_CONFIG_MSG("Calculating dt for AHRS/INS propagation.")
// timestamp when last callback was received
static float last_ts = 0.f;
// current timestamp
float now_ts = get_sys_time_float();
// dt between this and last callback
float dt = now_ts - last_ts;
last_ts = now_ts;
#else
PRINT_CONFIG_MSG("Using fixed AHRS_PROPAGATE_FREQUENCY for AHRS/INS propagation.")
PRINT_CONFIG_VAR(AHRS_PROPAGATE_FREQUENCY)
const float dt = (1./AHRS_PROPAGATE_FREQUENCY);
#endif

ImuScaleGyro(imu);

Expand Down

0 comments on commit ad17b25

Please sign in to comment.