Hi Francis,
Thanks for your effort on this!
Paul and I had already discussed making the code take account of the
aerodynamic load factor. See the discussion here:
https://github.com/diydrones/ardupilot/issues/1528
plus the earlier discussion on stall avoidance.
So while this had been planned, I hadn't actually implemented it till
today (prompted by your email). See the discussion on the implementation
here:
https://groups.google.com/forum/#!topic/drones-discuss/M_6YY1NweCc
There are a few things in your paper that I think are worth commenting
on.
> APM Plane autopilot needs only three (3) new parameters in order to
> avoid stalling. First, a reference stall speed (Vs) at Standard
> Temperature and Pressure (STP) computed on-line using aircraft weight
> and wing dimensions, plus current weight, if different. That is all
> (Reference Vs, reference weight, and current weight).
right now what we have is ARSPD_FBW_MIN, which is the minimum apparent
airspeed the user wants the aircraft to fly at. Up to now this value has
not been scaled for aerodynamic load factor. The patch set above fixes
that, by both adjusting the bank limit to account for load corrected
minimum airspeed, and adjusting target airspeeds in turns to account for
the load factor.
I'd prefer to not add a weight and reference weight as
parameters. Instead I'd prefer to just document how users should adjust
ARSPD_FBW_MIN to account for adding weight to an aircraft. A wiki page
describing the following would be ideal:
- how to estimate stall speed given aircraft dimensions
- how to measure stall speed using a flight test and log file
- how to adjust stall speed when the weight of the aircraft is changed
then we can keep the single parameter which captures the minimum speed
for level flight, and let the code take account of adjustments for
non-level flight.
The wiki page should also provide advice on how far above the stall
speed that ARSPD_FBW_MIN should be set.
> The autopilots have two airspeed reference systems, True Air Speed
> (TAS) and Indicated (calibrated) Air Speed (IAS). Navigation functions
> (like waypoints or Inertial navigation) need TAS; the piloting
> functions (like turning or landing or avoiding stall) need IAS.
yes, that is captured in ardupilot using the EAS2TAS ratio. We recently
discovered that the use of the temperature sensor in the barometer was
throwing off the EAS2TAS ratio by about 5% or so because the barometer
gets hot as it is in among lots of other electronics. The above patch
set changes it to use the temperature from a digital airspeed sensor
when available, which tends to be a lot more accurate.
> The desirable feature about IAS is that different altitudes and temperatures do not affect stall
> speed, or banked turn speed, or landing speed. For example, the TAS at which an airplane stalls is
> different at different altitudes for the same weight or g loads. However, the air density change
> with altitude affects IAS proportionally to the way it affects wing stall. Therefore, stall speed (Vs)
> for a given weight or g load is at the same IAS even though air densities are different.
indeed. ArduPilot already uses TAS or IAS in the appropriate places, by
using the EAS2TAS scaling factor. If you find a place where you don't
think we use the right airspeed then please let us know. We tested this
by flying at very high altitudes (over 20km) in the SITL simulator,
where EAS2TAS gets very large.
> a. Gear Down state (fixed or retractable gear are down), Flap setting percentage 0% to 100%
> where 0% is the special no flaps case. The data structure will contain a 0%, 33%, 66%, and
> 100% stall speed flap setting reference points. Servo settings at points in between are
> interpolated. Rarely, will the 33%, 66%, and 100% data points be provided, but they are not
> excluded from the software design.
>
> b. Gear Up state (retractable gear case or no landing gear), with flap setting percentage 0% to
> 100% where 0% is the no flaps special case. As above, the design does not exclude stall speed
> estimates at partial flap settings. Autopilot software must take care the structure is safely
> initialized and defend against GCS omissions or errors.
right now ArduPilot is not aware of whether landing gear is down, and in
fact very few ArduPilot users fly with retractable landing gear. I don't
think adding different airspeed handling for gear down is worthwhile at
this stage.
I also don't think we should ask users to enter mimimum airspeed for
different flap settings. We need to strike a reasonable balance between
configurability and complexity, and I think having to enter minimum
airspeed numbers for different flap settings goes too far down the
complexity path.
> An over simplified event driven state machine approach is used for thinking through Stall
> Avoidance suggestions in each of the 18 APM Plane Flight Modes . It does not apply to Copter or
> Rover.
there are actually only 3 flight mode categories from the point of view
of stall avoidance. They are:
CAT1) manual attitude control and manual throttle control (MANUAL,
STABALIZE, TRAINING and ACRO)
CAT2) automatic attitude control and manual throttle control
(FBWA and AUTOTUNE)
CAT3) automatic attitude control and automatic throttle control
(CIRCLE, FBWB, CRUISE, AUTO, RTL, LOITER and GUIDED)
The details of the individual flight modes within each category doesn't
matter for stall avoidance.
The stall avoidance techniques available in the 3 categories are:
CAT1: no stall avoidance possible, pilot may in fact be deliberately
stalling the airframe
CAT2: stall avoidance via limiting bank angle is possible. We cannot
use throttle control in these modes
CAT3: stall avoidance via both bank angle limiting and throttle/pitch
control is possible (via the TECS controller).
> I diverge for a moment to note the autopilot does not have direct feedback from the motors.
> Eventually this needs to be corrected no matter whether petrol or electric power. Stall Avoidance
> needs to know immediately whether servo PWM signals to the throttle have actually added
> power.
that may be possible in the future with some types of ESC (eg. CANBUS
ESCs), or could possibly be inferred from current draw. I'm not sure we
actually need to know this though, as TECS will automatically put the
nose down if raising the throttle doesn't gain enough speed.
It would be useful to know if the motor is dead for a failsafe, where
the autopilot can do an emergency land on motor failure, but I think we
should leave that for a separate discussion.
> The event generator is a simple piece of code primarily responsible for calling the state machine
> with two indexes into the function table. The event generator always loads the new 32 bit Real-
> Time Counter (RTC) and the new Vccs into the state machine’s associated data structure. RTC time
> tags give states the ability to perform delays. The event generator does not decide anything based
> on state because that is accomplished by the indexing. The event generator may log exception
> conditions or trace the state machine if trace is enabled.
>
> The event generator could be called at the Plane 50 Hz loop rate, but I think no less than 10 Hz.
> State Machine decision making is as fast as indexing into an array of function handles. State
> machine function handlers may manipulate the Vccs stall thresholds used for comparisons by the
> event generator (1.3Vs, 1.2Vs, 1.07Vs). The event detects a speed level, however the state
> machine determines falling or rising edge. Flight Mode is the first index into the state machine.
> Event is the second index. Both are stored in the state machine structure, but are extracted and
> passed to the state machine execute function in order to extract and call the chosen function.
> Event indexes could be:
Have you had a chance to read through the current code so you understand
the structure? Discussions of general stall avoidance strategies are
very welcome, but this sort of detailed code structure suggestion
doesn't really help unless you relate it to the current code structure.
> Some of the 18 Flight Modes (states) need to progress through sub-states, for example when
> transitioning between modes. Following are suggested concepts of operation for Stall avoidance
> in each flight mode:
there seems to be some misconceptions on how some of the flight modes
work in your table. I'll add some notes below.
> FBWA MODE
>
> Stall is actively avoided in FBWA mode. Verbal stall warning triggers are sent to the GCS on the
> qualified event falling edge “IAS(ekf) is between 1.2Vs – 1.07Vccs” thus causing the GCS to say,
> “Approaching Stall, add power” because the pilot controls the throttle.
>
> When the event falling edge “IAS(ekf) is below 1.07Vccs” qualifies as valid, trigger the GCS to say
> once, “Avoiding Stall, leveling wings, lowering nose .” Level the wings using constant 20% aileron
> servo deflection until level or until IAS(ekf) rises above the original 1.3Vccs threshold.
>
> Simultaneously reduce the angle of attack by pitching the nose down 2 degrees per second, but
> not to exceed 6 degrees below the horizontal
We don't have a direct AoA measure in ArduPilot, so we'd need to proxy
it with pitch. Controlling pitch to avoid stall in FBWA mode is
problematic as it could lead to not being able to take off. A lot of
users takeoff in FBWA mode, and on the initial hand launch the airspeed
may be quite low, plus the airspeed estimate will be very poor if you
don't have an airspeed sensor as it won't yet have had a chance to build
up a wind estimate.
The patches I link to above do add bank angle limits based on load
factor in FBWA, which I think is fine. We may add a pitch limit later,
but I don't think we should go as far as pitching the nose down if the
user is asking for a positive pitch. If the user wants full staill
avoidance they should really be using an auto-throttle mode like FBWB or
CRUISE.
> The autopilot does not intervene to control the throttle because it violates the FBWB concept.
FBWB is in fact an auto-throttle mode, and uses TECS, so it can benefit
from the full stall avoidance strategy by adding power and lowering the
nose.
> AUTOTUNE MODE
>
> Stall avoidance is active in Autotune Mode by making GCS announcements and by limiting up
> elevator excursions. Otherwise, Autotune is treated like Manual mode –
> no intervention.
AUTOTUNE is actually the same as FBWA mode. The only difference is that
it learns attitude controller gains while flying. See FBWA comments above.
> TRAINING MODE
>
> Stall avoidance is active in Training Mode. Intervention is similar to Autotune Mode by making
> GCS announcements and by limiting up elevator excursions.
TRAINING mode is a full manual mode. It is designed for teaching manual
flight. Stall avoidance is inappropriate.
> CRUISE stall avoidance needs more throttle. However, the autopilot does not intervene to control
> the throttle because it violates the CRUISE concept.
CRUISE mode is a auto-throttle mode. CRUISE mode operates the same as
AUTO mode, except that the user controls where the target waypoint is
with the sticks.
> In LOITER Mode the autopilot is thought to control attitude but not
> throttle.
LOITER is an auto-throttle mode.
> TAKEOFF MODE
There is no separate TAKEOFF mode, it is part of AUTO, but the throttle
is set to 100%, and a target pitch is set in the mission.
> LANDING MODE
there is no 'LANDING MODE', it is part of AUTO, but with different
target airspeed.
See
http://plane.ardupilot.com/wiki/flying/flight-modes/
I do like the suggestion of a GCS warning on approching stall, but we
need to find a way to prevent lots of false positives. For example, if
you are holding the plane on the ground before takeoff in FBWA mode then
the plane doesn't actually know it isn't flying yet. So it will think it
is stalled. We don't want the GCS to be shouting "stall warning" at the
user.
We could use some heuristics to guess if we are flying or not, and we do
use heuristics like that in other places in the code, we'll just need to
try to make it not too annoying.
Cheers, Tridge