Browse Source

Copter: use scheduler ticks in place of mainloop_count

master
Peter Barker 7 years ago committed by Andrew Tridgell
parent
commit
7f69c5d26d
  1. 3
      ArduCopter/ArduCopter.cpp
  2. 1
      ArduCopter/Copter.cpp
  3. 2
      ArduCopter/Copter.h
  4. 7
      ArduCopter/failsafe.cpp

3
ArduCopter/ArduCopter.cpp

@ -226,9 +226,6 @@ void Copter::loop() @@ -226,9 +226,6 @@ void Copter::loop()
G_Dt = (float)(timer - fast_loopTimer) / 1000000.0f;
fast_loopTimer = timer;
// for mainloop failure monitoring
mainLoop_count++;
// Execute the fast loop
// ---------------------
fast_loop();

1
ArduCopter/Copter.cpp

@ -48,7 +48,6 @@ Copter::Copter(void) @@ -48,7 +48,6 @@ Copter::Copter(void)
inertial_nav(ahrs),
pmTest1(0),
fast_loopTimer(0),
mainLoop_count(0),
auto_trim_counter(0),
in_mavlink_delay(false),
param_loader(var_info),

2
ArduCopter/Copter.h

@ -479,8 +479,6 @@ private: @@ -479,8 +479,6 @@ private:
// --------------
// Time in microseconds of main control loop
uint32_t fast_loopTimer;
// Counter of main loop executions. Used for performance monitoring and failsafe processing
uint16_t mainLoop_count;
// arm_time_ms - Records when vehicle was armed. Will be Zero if we are disarmed.
uint32_t arm_time_ms;

7
ArduCopter/failsafe.cpp

@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
//
static bool failsafe_enabled = false;
static uint16_t failsafe_last_mainLoop_count;
static uint16_t failsafe_last_ticks;
static uint32_t failsafe_last_timestamp;
static bool in_failsafe;
@ -36,9 +36,10 @@ void Copter::failsafe_check() @@ -36,9 +36,10 @@ void Copter::failsafe_check()
{
uint32_t tnow = AP_HAL::micros();
if (mainLoop_count != failsafe_last_mainLoop_count) {
const uint16_t ticks = scheduler.ticks();
if (ticks != failsafe_last_ticks) {
// the main loop is running, all is OK
failsafe_last_mainLoop_count = mainLoop_count;
failsafe_last_ticks = ticks;
failsafe_last_timestamp = tnow;
if (in_failsafe) {
in_failsafe = false;

Loading…
Cancel
Save