Hi Tiago!
Thanks for your interest, we can use some improvement in this area along with some other areas you may be interested.
Like what Paul said, pointing to specific code lines would give some additional context on your questions. Meanwhile, mind if I point out a few issues that you may be interested in doing research on which are possibly related?
We already have stall prevention that takes into account restricting bank angle during turns considering wing loading but we're missing the other two parts: stall detection and stall recovery.
Stall detection
https://github.com/diydrones/ardupilot/issues/2933
Stall recovery
https://github.com/diydrones/ardupilot/issues/2669
Pitot tube failure detection and switch to/from internal synthetic airspeed calculation
https://github.com/diydrones/ardupilot/issues/1628
-TomP
Hi,Thank you for your replies, and sorry for the delayed response (different timezones!).As for the concerned lines:- _detect_underspeed: it there any reason to use a throttle condition on the underspeed detection algorithm, aside from avoiding a potential full throttle descent in case of airspeed sensor failure (which should probably be treated elsewhere)? https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L458
- _detect_underspeed: why do we leave the underspeed condition only when reaching desired altitude and not when reaching the desired airspeed? (to fly/not crash even if the pilot has set a bad trim airspeed/min airspeed?) https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L460
- _update_pitch: why do we need to saturate integrator input (_integ7_input) at all, when we saturate integrator_state (_integ7_state) later, before it's used for any calculation? _integ7_input saturation from https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L683 to https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L690, _integ7_state saturation at https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L719, with no _integ7_state use in between
- _update_pitch: even if we want to be saturating integrator input, the units seem all wrong (shouldn't it be scaled with gainInv/DT?) https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L685 and https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L689
- _update_pitch: in the _integ7_state saturation I think there is a typo on the magic number (5 degrees - as per the comment above that line - equals roughly 0.873 rad, not 0.783 rad) https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L719, related comment starts at https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L702
- _update_speed: does filtering airspeed with accelerometer data work well (since small errors in attitude may yield a significant difference in x-acceleration due to gravity being a comparatively large term) https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L339
Hi,
I've has some time to come back to this and I've focused on the integrator input saturation implementation.What is puzzling me is:
1. From what I can tell we never actually enter the input saturation code (https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L683) unless we change the maximum pitch or minimum pitch parameters in between TECS cycles, as we're checking if the constrained pitch demand is out of limits, which it never is unless we actually change the limits parameters, as the constrained pitch demand is calculated by constraining it to max/min pitch (https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L741).Before commit https://github.com/diydrones/ardupilot/commit/060f5530979585140f89dde345a60d32b1786c33 pitch_dem_unc was used instead for the integrator input saturation check.
2. The units used to saturate the input (e.g. https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L685) are apparently radians. This would imply that the integrator state units are (rad)*s (https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L691).
However, we then add the integrator state (in https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L722) to a variable (temp) that has SEB_error units, m^2/s^2 (https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L710), and saturate it later with pitch*gainInv (https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L719), which again has the same units, given that gainInv has units m^2/s^2 (V*t*g, https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L709). Both the saturation and the unconstrained pitch demand calculation in https://github.com/diydrones/ardupilot/blob/master/libraries/AP_TECS/AP_TECS.cpp#L722 indicate that _integrator_state actually has units m^2/s^2, which is not consistent with its input having units (rad).