Skip to content

Commit

Permalink
Copter: Share flags across common areas
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed Oct 12, 2024
1 parent c3affa4 commit fa72467
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions ArduCopter/failsafe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,28 @@ void Copter::failsafe_check()
return;
}

if (!in_failsafe && failsafe_enabled && tnow - failsafe_last_timestamp > 2000000) {
// motors are running but we have gone 2 second since the
// main loop ran. That means we're in trouble and should
// disarm the motors->
in_failsafe = true;
// reduce motors to minimum (we do not immediately disarm because we want to log the failure)
if (motors->armed()) {
motors->output_min();
}

LOGGER_WRITE_ERROR(LogErrorSubsystem::CPU, LogErrorCode::FAILSAFE_OCCURRED);
}
if (failsafe_enabled) {
if (!in_failsafe && tnow - failsafe_last_timestamp > 2000000) {
// motors are running but we have gone 2 second since the
// main loop ran. That means we're in trouble and should
// disarm the motors->
in_failsafe = true;
// reduce motors to minimum (we do not immediately disarm because we want to log the failure)
if (motors->armed()) {
motors->output_min();
}

if (failsafe_enabled && in_failsafe && tnow - failsafe_last_timestamp > 1000000) {
// disarm motors every second
failsafe_last_timestamp = tnow;
if(motors->armed()) {
motors->armed(false);
motors->output();
LOGGER_WRITE_ERROR(LogErrorSubsystem::CPU, LogErrorCode::FAILSAFE_OCCURRED);
}

if (in_failsafe && tnow - failsafe_last_timestamp > 1000000) {
// disarm motors every second
failsafe_last_timestamp = tnow;
if(motors->armed()) {
motors->armed(false);
motors->output();
}
}
}
}

Expand Down

0 comments on commit fa72467

Please sign in to comment.