Skip to content

Commit

Permalink
Plane: check G_Dt to catch startup errors
Browse files Browse the repository at this point in the history
this catches cases where constructors lead to G_Dt being incorrect
  • Loading branch information
tridge committed Jul 21, 2022
1 parent 3e89e32 commit 25e317d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ArduPlane/ArduPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ void Plane::one_second_loop()
// reset the landing altitude correction
landing.alt_offset = 0;
}

// this ensures G_Dt is correct, catching startup issues with constructors
// calling the scheduler methods
if (!is_equal(1.0f/scheduler.get_loop_rate_hz(), scheduler.get_loop_period_s()) ||
!is_equal(G_Dt, scheduler.get_loop_period_s())) {
INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
}
}

void Plane::three_hz_loop()
Expand Down

0 comments on commit 25e317d

Please sign in to comment.