mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-28 19:48:31 -04:00
Plane: added time for flying in any mode
- previously we only kept track of starting flying while in auto which gets reset when switching in and out of auto and on takeoff/land. Now we keep track of a "global" one that will track the is_flying flag regardless of the flight mode.
This commit is contained in:
parent
a3c51698cb
commit
4f46c5331a
@ -577,7 +577,7 @@ bool Plane::suppress_throttle(void)
|
||||
auto_state.takeoff_complete == false) {
|
||||
|
||||
if (is_flying() &&
|
||||
millis() - auto_state.started_flying_in_auto_ms > 5000 && // been flying >5s
|
||||
millis() - started_flying_ms > 5000 && // been flying >5s in any mode
|
||||
adjusted_relative_altitude_cm() > 500) { // are >5m above AGL/home
|
||||
// we're already flying, do not suppress the throttle. We can get
|
||||
// stuck in this condition if we reset a mission and cmd 1 is takeoff
|
||||
|
@ -512,6 +512,9 @@ private:
|
||||
// previous value of is_flying()
|
||||
bool previous_is_flying;
|
||||
|
||||
// time since started flying in any mode in milliseconds
|
||||
uint32_t started_flying_ms;
|
||||
|
||||
// Navigation control variables
|
||||
// The instantaneous desired bank angle. Hundredths of a degree
|
||||
int32_t nav_roll_cd;
|
||||
|
@ -99,6 +99,11 @@ void Plane::update_is_flying_5Hz(void)
|
||||
|
||||
auto_state.last_flying_ms = now_ms;
|
||||
|
||||
if (!previous_is_flying) {
|
||||
// just started flying in any mode
|
||||
started_flying_ms = now_ms;
|
||||
}
|
||||
|
||||
if ((control_mode == AUTO) &&
|
||||
((auto_state.started_flying_in_auto_ms == 0) || !previous_is_flying) ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user