1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00
Commit graph

738 commits

Author SHA1 Message Date
Michael Keller
b468b94995
Merge pull request #7924 from mikeller/add_crash_recovery_disarm
Added 'disarm' option to crash recovery.
2019-04-14 21:49:05 +12:00
Michael Keller
c3d828e4b4
Merge pull request #7737 from joelucid/remove_ff
remove smart_feedforward
2019-04-14 21:32:39 +12:00
Bruce Luckcuck
e2b5fc24bd Refactor dshot command output scheduling logic
Change to a state machine that tracks the progress of each dshot command in the queue as it moves through the various phases. Simplifies the code to make it easier to understand and maintain.

Transition to timing based on motor output cycle counts calculated from desired delays instead of using direct time comparisons. Since the output timing is always based on the motor update schedule, there were cases where if the time between motor updates was a significant percentage of the desired dshot command timing, then the output could get irregular and skip cycles (for example trying to use 2K pid loop with 500us timing conflicting with 1ms timing between dshot command outputs).
2019-04-08 08:19:38 -04:00
mikeller
760a524027 Fixed tests, added crash indication. 2019-04-05 08:39:23 +13:00
mikeller
247f759652 Added 'disarm' option to crash recovery. 2019-04-04 22:40:00 +13:00
Bruce Luckcuck
96ee9e3103 Unify lowpass settings regardless of whether USE_DYN_LPF is defined
Defaults will be the same regardless of whether the target has `USE_DYN_LPF` included. Previously the defaults would vary and it wouldn't be obvious why.

Defaults are as follows:
gyro lowpass 1: 150/BIQUAD
gyro lowpass 2: OFF
dterm lowpass 1: 150/BIQUAD
dterm lowpass 2: 150/BIQUAD

Nothing has changed int eh dynamic lowpass logic. If it's enabled those settings will be used in place of the static lowpass cutoff.

Needs coordination with the Configurator to change the defaults used when re-eanbling the lowpass filters as they are currently based on previous version settings and will dfault to inappropriate values.
2019-04-02 20:18:19 -04:00
mikeller
33902a2169 Disabled 'iterm_rotation' according to agreement. 2019-04-01 22:53:43 +13:00
Bruce Luckcuck
e3df0269fc Change absolute control default to disabled and reenable iterm_rotation 2019-03-31 08:53:00 -04:00
Michael Keller
ef831e64b1
Merge pull request #7888 from mikeller/fix_lowpass_defaults
Fixed defaults for lowpass filters.
2019-03-30 11:09:10 +13:00
Michael Keller
83cecb17f5
Merge pull request #7890 from joelucid/ac_yaw
apply abs control also on yaw
2019-03-30 10:50:40 +13:00
Thorsten Laux
2bb8ed76fd apply abs control also on yaw 2019-03-28 12:05:19 +01:00
Thorsten Laux
fb6558a142 add abs control debug modes 2019-03-28 11:58:18 +01:00
mikeller
d16f35d9cb Fixed defaults for lowpass filters. 2019-03-28 22:58:22 +13:00
Thorsten Laux
bd708d6741 fix abs control #7863 2019-03-24 18:49:09 +01:00
ctzsnooze
7101fe220a log acCorrection, not acError
Improves usefulness of Absolute Control logging in iterm_relax mode.
2019-03-21 10:24:47 +11:00
Thorsten Laux
11c21368c8 remove smart_feedforward 2019-03-08 06:49:09 +01:00
mikeller
b578801208 Fixed conditional scope.
Fix unit tests.
2019-03-08 12:46:48 +13:00
Thorsten Laux
0ba3c5e468 4.0 defaults
address feedback

updated defaults and yaw I scaling

switch integrated yaw off by default
2019-03-08 12:43:49 +13:00
ctzsnooze
3458a75283 use a define for ITERM_RELAX_CUTOFF_DEFAULT
use a define for ITERM_RELAX_CUTOFF_DEFAULT
lock in at 20hz by default
update comment about why do this
2019-03-03 11:34:07 +11:00
ctzsnooze
a0237e6cde Defaults set, Annotations
Default threshold 40 deg/sec
Anotations provided to explain
- cutoff independence factor when calculating itermRelaxSetpointThreshold
- meaning of ITERM_RELAX_SETPOINT_THRESHOLD
2019-03-03 11:34:07 +11:00
ctzsnooze
1d998ea404 iTermRelaxFactor now only attenuates amount added
The original setpoint based iTerm Relax code attenuated the amount of iTerm added per loop by a relax factor based on an HPF of setpoint.
At some point the code was re-factored and the relax factor multiplied the accumulating iterm error itself, such that almost any relax factor below 1.0 would quickly zero out iTerm.
This was bad for racing because when making sustained tight turns, I would abrubtly be zeroed when the setpoint for the starting of some relax was close to the threshold.
This was never the intent of the original proposal, which was for a smoother attenuation of iTerm, and for retention of some accumulation of iTerm during spirals around poles etc.
This PR fixes that error.
It also changes the default threshold up from 30 deg/s to 40 deg/s which better suits racing.
Also included us a form of simple cutoff independence. In the initial form, lowering cutoff would reduce the effectiveness but draw out the duration.  Now cutoff only really affects duration.
Lower cutoff values are better for quads with greater motor delay, faster values are better for quicker quads. For most of my quads a cutoff of 30 works best.
I've also removed newlines.

set to current cutoff maybe fix unit test

default cutoff set to current value

in unit test add itermRelaxSetpointThreshold as float

in unit test add itermRelaxSetpointThreshold as float, because ITERM_RELAX_SETPOINT_THRESHOLD doesn't exist any more

Move itermRelaxFactor limit, remove from fast ram

remove unncessary max, revert unit test changes, restore original defaults.

remove max from debug
restore old defaults and revert unit test changes temporarily to see if will pass unit test with defaults

whoops

lets see if unit test passes when cutoff is 20

lets see if unit test passes when cutoff is 20
2019-02-28 19:51:50 +13:00
Thorsten Laux
e16ef1db4f First attempt low throttle airmode oscillation fix
raise dc offset immediately

Add airmode noise fix

no filter when inactive and slightly more throttle

hpf throttle to avoid large moves increasing throttle persistently

fix ws

fix ununsed variable and default to off

include airmode throttle offset in loggingThrottle
2019-02-18 23:48:36 +13:00
Bruce Luckcuck
a64bd06f5a D_MIN cleanup - use array for parameters; move CMS menu entries
Change to using an array of `uint8_t` for the `d_min_` axis parameters. Simplifies the code.

The CMS menu entries were incorrectly placed under the `FILTER PP` submenu. Moved to the `MISC PP` submenu.
2019-02-09 15:40:27 -05:00
ctzsnooze
b70d34f9db Update D_CUT to D_MIN, add setpoint
Directly and easily set the minimum value for D on pitch and roll.
- Boost back to the primary D setting is generated from gyro or setpoint inputs.
- Setpoint input is stick derived, faster by 10ms approx, and does not respond to propwash.
- Gyro input is motor derived and slower, but responds to propwash
- timing value sets balance between gyro (100) and setpoint (0) boost factors
- gain value sets overall sensitivity
- default D mins are 20 roll 22 pitch
- default D is 35, 38; if undefined then normal 30, 32 values
TUNING
- D value to flip overshoot control
- D_min to noise, lower values mean cooler motors but perhaps more propwash.
- Advance, higher values bring the boost in earlier, and stronger overall, useful for very high flip rates, but dampen stick responsiveness slightly.
- Gain value adjust against logs, checking maximal boost with flips and some rise with propwash, should be edging to get up from the min value in normal flight.
2019-02-10 01:44:55 +11:00
mikeller
35bc646692 Excised some more unused code after review. 2019-02-08 09:51:48 +13:00
mikeller
b5908f5bab Applied 'USE_ACC' consistently. 2019-02-08 09:51:48 +13:00
mikeller
299d96fdc7 Added battery cell count based automatic PID profile switching. 2019-02-04 13:15:43 +13:00
mikeller
73d18ede66 Halved motor_output_limit for 3D modes. 2019-01-30 00:05:41 +13:00
mikeller
a3cf7e0cf7 Added motor output limiting per profile. 2019-01-28 00:37:00 +13:00
Bruce Luckcuck
99685c21c6 Add setpoint to blackbox logging
Currently only rcCommand values are included in the log data and the configurator calculates the actual setpoint values based on rates values added to the blackbox header. The problem with this is that the rates information is only written at arming so if the rates change during the log (rateprofile change, in-flight adjustments, etc.) then the calculated setpoints will be incorrect. There's no way to tell from the log that this happened. This often causes confusion because it will suddenly make it appear in the log that the PID controller is not acheiving the requested rates when it's just a presentation error. Also the rates will be incorrectly calculated when the user selects Raceflight style rates as the rates type is not supplied in the log header (and the viewer doesn't have the forumla for them anyway).

This change adds the actual setpoint values for each axis as used by the PID controller, removing the necessity for the viewer to perform any calculations. In addition to showing any rate changes, it will also show any cases where other flight features have modified the setpoints from the user's input. These were invisible previously (examples include level modes, Acro Trainer, GPS Rescue, yaw spin recovery, etc.).

Also the throttle value used in the mixer is included in the throttle axis. This allow visualization of things that affect the commanded throttle like throttle boost, throttle limit, GPS Rescue, angle level strength, etc.
2019-01-25 09:01:55 -05:00
Michael Keller
aaad98ecc3
Merge pull request #7435 from etracer65/use_fabsf_for_floats
Use fabsf() instead of ABS() for floats
2019-01-21 11:34:47 +13:00
Michael Keller
f72bc436f8
Merge pull request #7432 from etracer65/zero_throttle_anti_windup_in_pidloop
Move anti-windup iterm reset from rx loop to pid loop
2019-01-21 11:33:58 +13:00
Michael Keller
8740e484f7
Merge pull request #7393 from kmitchel/dyn_filt_init
Allow dyn lpf to initialize if static lpf config is 0.
2019-01-21 11:32:20 +13:00
Bruce Luckcuck
3d671c7134 Use fabsf() instead of ABS() for floats
The ABS() macro doesn't handle -0 floats correctly. Also fabsf() is more efficient.
2019-01-19 14:15:54 -05:00
Bruce Luckcuck
d867aeced3 Move anti-windup iterm reset from rx loop to pid loop
Having the iterm resetting happening in the rx loop causes a sawtooth PID/motor effect while idling since the PID loop is running at a much higher rate and iterm is allowed to grow during this, and then only reset at a much lower rate in the rx loop. This can potentially lead to some oscillation and/or resonance while idling before takeoff as the sawtooth signal can make it through to the motor outputs.
2019-01-19 11:18:24 -05:00
ctzsnooze
65750f09dc Classic D values if no D_Cut
At compile time, if D_CUT is not defined for a given target, the user will get lower default D values.
2019-01-16 09:00:38 -07:00
Kenneth Mitchell
f6e456cd06
Allow dyn lpf to initialize if static lpf config is 0.
Change min > max per review.

Fix missing ifdef.
2019-01-15 16:48:21 -05:00
ctzsnooze
7e3e5649e1 DTERM_CUT
This code cuts D by a specified percentage durning normal flight.

It lets D smoothly rise up to normal during rapid gyro moves like flips and rolls, and increase during prop wash events.

D should now be tuned to values the 'normal' 30-45 range.

If D is 40, a dterm_cut_percentage of 65 will cut D to 14 in normal flight, but the quad will still get full 40 of D to control bounce-back after flips and about 25 of D during strong prop wash.

The dterm_cut_percentage can be adjusted via the OSD, from the D filtering page.
Adding d_cut results in cooler motors, lower amounts of noise in motor traces and faster reactions to quick stick inputs.

Too high a dterm_cut_percentage may bring out P oscillation from lack of D.  Values of 70% are generally OK.

Input is gyro differential (delta).  Frequencies above 40hz (above propwash) are attenuated with a configurable (dterm_cut_range_hz) biquad filter.  Lower values for range can be used if the quad is very noisy or gets low frequency D resonant oscillation.  Up to 50 or 60hz may suit clean quads where prop wash control is the main priority.  Too high a range value results in D being boosted from noise in normal flight.

The boost signal is 'integrated, smoothed and delayed' with a 7hz PT1 'dterm_cut_lowpass_hz' filter.  The default of 7Hz gives about the right amount of smoothing and delay.  Higher numbers cause the boost to come on faster, with less delay. Lower values delay the boost effect and cause it to last longer.

The dterm_cut_gain amount controls the strength of the boost effect by amplifying the input to the boosting effect.  If the quad is flow gently, a higher gain value may be needed to gain full boost.

Logging with set debug_mode = D_CUT allows recording of realtime D values on roll and pitch into debug 2 and 3.  The reatime D value should reach its set maximum during rapid turns, ideally at about the time D itself peaks.  If it fails to reach the maximum, gain should be increased.

The D_Cut feature is not enabled on LUXV2RACE, OMNIBUS, SPRACINGF3NEO because there isn't enough flash space.
2019-01-12 21:09:03 -07:00
Michael Keller
a136f0b7e0
Merge pull request #7304 from joelucid/linear_pids
Thrust Linearization
2019-01-09 09:08:06 +13:00
Thorsten Laux
9ef95bb84d address code review comments 2019-01-08 09:50:26 +01:00
Thorsten Laux
998845be3e prevent divide by zero 2019-01-07 15:52:57 +01:00
Thorsten Laux
8d4ed72e13 rpm telemetry based notch filter 2019-01-07 13:36:01 +01:00
Thorsten Laux
ad253c146b add Thrust Linearization feature 2019-01-03 15:09:17 +01:00
Michael Keller
60118da63f
Merge pull request #6432 from joelucid/integrated_yaw
For discussion: Integrated yaw control
2018-12-15 18:40:00 +13:00
Thorsten Laux
906a697668 make iyaw conditional, bump pidProfile version number 2018-12-11 08:28:53 +01:00
Thorsten Laux
8bcc4dab64 fix indentation and pidProfile version number 2018-12-11 08:18:51 +01:00
Thorsten Laux
17a995e03e fix abs control refactor, make abs control cutoff configurable 2018-12-10 09:05:20 +01:00
Thorsten Laux
d4512672fe Move to pid.c, add relax to offset drag based component, make configurable 2018-12-09 14:21:44 +01:00
Kenneth Mitchell
233ac7fb3f
Allow width=0 to select single notch. Restore dyn lpf mins. 2018-12-02 10:01:51 -05:00
Kenneth Mitchell
011eae93c6
Cascaded notch filters. 2018-12-02 09:52:02 -05:00