mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-24 09:38:29 -04:00
Plane: use scheduler ticks in place of mainloop_count
This commit is contained in:
parent
9bb1224cef
commit
73092c3c30
@ -126,9 +126,6 @@ void Plane::loop()
|
|||||||
G_Dt = (timer - perf.fast_loopTimer_us) * 1.0e-6f;
|
G_Dt = (timer - perf.fast_loopTimer_us) * 1.0e-6f;
|
||||||
perf.fast_loopTimer_us = timer;
|
perf.fast_loopTimer_us = timer;
|
||||||
|
|
||||||
// for mainloop failure monitoring
|
|
||||||
perf.mainLoop_count++;
|
|
||||||
|
|
||||||
// tell the scheduler one tick has passed
|
// tell the scheduler one tick has passed
|
||||||
scheduler.tick();
|
scheduler.tick();
|
||||||
|
|
||||||
|
@ -741,9 +741,6 @@ private:
|
|||||||
// System Timers
|
// System Timers
|
||||||
// Time in microseconds of start of main control loop
|
// Time in microseconds of start of main control loop
|
||||||
uint32_t fast_loopTimer_us;
|
uint32_t fast_loopTimer_us;
|
||||||
|
|
||||||
// Counter of main loop executions. Used for performance monitoring and failsafe processing
|
|
||||||
uint16_t mainLoop_count;
|
|
||||||
} perf;
|
} perf;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -16,14 +16,15 @@
|
|||||||
*/
|
*/
|
||||||
void Plane::failsafe_check(void)
|
void Plane::failsafe_check(void)
|
||||||
{
|
{
|
||||||
static uint16_t last_mainLoop_count;
|
static uint16_t last_ticks;
|
||||||
static uint32_t last_timestamp;
|
static uint32_t last_timestamp;
|
||||||
static bool in_failsafe;
|
static bool in_failsafe;
|
||||||
uint32_t tnow = micros();
|
uint32_t tnow = micros();
|
||||||
|
|
||||||
if (perf_info.get_num_loops() != last_mainLoop_count) {
|
const uint16_t ticks = scheduler.ticks();
|
||||||
|
if (ticks != last_ticks) {
|
||||||
// the main loop is running, all is OK
|
// the main loop is running, all is OK
|
||||||
last_mainLoop_count = perf_info.get_num_loops();
|
last_ticks = ticks;
|
||||||
last_timestamp = tnow;
|
last_timestamp = tnow;
|
||||||
in_failsafe = false;
|
in_failsafe = false;
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user