Browse Source

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.
master
Tom Pittenger 10 years ago committed by Andrew Tridgell
parent
commit
4f46c5331a
  1. 2
      ArduPlane/Attitude.cpp
  2. 3
      ArduPlane/Plane.h
  3. 5
      ArduPlane/is_flying.cpp

2
ArduPlane/Attitude.cpp

@ -577,7 +577,7 @@ bool Plane::suppress_throttle(void) @@ -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

3
ArduPlane/Plane.h

@ -512,6 +512,9 @@ private: @@ -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;

5
ArduPlane/is_flying.cpp

@ -99,6 +99,11 @@ void Plane::update_is_flying_5Hz(void) @@ -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…
Cancel
Save