1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-18 22:05:17 +03:00
Commit graph

652 commits

Author SHA1 Message Date
mikeller
70ac9423c7 Unified BUILD_BUG_ON and STATIC_ASSERT into STATIC_ASSERT. 2018-08-20 10:50:06 +12:00
ctzsnooze
249ee2b309 comma 2018-08-06 20:59:46 +10:00
ctzsnooze
67abb63d95 Set default iterm relax to RP and RC smoothing to filter 2018-08-06 10:01:59 +10:00
Kenneth Mitchell
b7e71cbc44 Fix AG Hpf test. 2018-07-27 00:02:23 -04:00
mikeller
ec06575203 Removed unused PID settings. 2018-07-22 11:41:22 +12:00
Bruce Luckcuck
17e76e48f6 PID controller feedforward
Restructures the PID controller to decouple feedforward from D.

Cleaned up the structure of the PID controller; moved some feature-based enhancements out of the main structure.

Feedforward becomes a separate component of the PID controller and there is now:
f_pitch
f_roll
f_yaw

The default values of 60 for pitch and roll matches the default setpoint weight used in BF3.4.  Yaw previously had no setpoint weight capability so the default here needs to be discussed.  Currently it's also set to 60 and flight testing seems positive.  Feedforward on yaw adds a lot of value so I don't think we want to default to 0.  Instead we need decide on the default.

All occurences of setpoint weight have been replaced by feedforward. "setpoint_relax_ratio" has been renamed to "feedforward_transition".

The pidSum now consists of P + I + D + F.

D has been added back for yaw (disabled by default with d_yaw = 0). We've found little need for D for normal quads but it may have value for other configurations - particularly tricopters.

Updated CMS menus to support adjusting the feedforward for each axis.

Changed the default for "rc_interp_ch" to be "RPYT".  Need yaw to be smoothed to support feedforward.

Open issues:

Needs BFC support
- Need to add support for the axis "F" gains.
- Remove "setpoint weight" slider.
- Rename "D Setpoint transition" to "Feedforward transition"

Needs BBE support
- Header "setpoint_relaxation_ratio" has been renamed "feedforward_transition"
- Header "dterm_setpoint_weight" has been replaced with an array named "feed_forward_weight".
  example: H feed_forward_weight:65,60,60    (R,P,Y)
- PID component "AXISF" has been added for all axes. Should be handled like P, I and D values.
- PidSum calculation needs to include F.

Needs LUA script support
- Support the renamed "setpoint_relax_ratio".
- Support for feedforward weight on all 3 axes.

Open code issues:
- rc_adjustments.c - support for adjusting feedforward weight for all axes. Currently only supporting roll - needs coordination with BFC.
2018-07-21 10:26:23 -04:00
ctzsnooze
94c7109a4c Changes, thanks mikeller and jirif 2018-07-21 23:49:41 +12:00
ctzsnooze
4c917efa50 Smooth anti gravity 2018-07-21 23:49:41 +12:00
mikeller
80acf5a53d Minor code improvements for iterm relax. 2018-07-11 21:32:55 +12:00
Michael Keller
5371350150
Merge pull request #6129 from McGiverGim/iterm_relax_decreasing_I
Add Iterm Relax INC modes
2018-07-09 22:43:33 +12:00
mikeller
00228427da Set yaw D default to 0 since it is unused anyway. 2018-06-30 15:25:50 +12:00
Bruce Luckcuck
1982c94780 RC smoothing retraining update - adds full support for CRSF
Adds in flight monitoring of the rx frame rate and adapts the filters if the frame rate changes. Primarily to add support for Crossfire with its ability to switch from 150hz to 50hz (and back) under some circumstances. Will work with any protocol - not CRSF specific.   So if future receivers add the ability to switch frame rates dynamically the logic should support them.

If the current rx frame rate is more than +-20% from the previously detected rate, then the process will retrain for the next 50 samples as long as the rate continues to be outside the 20% tolerance. Once 50 samples are collected the new frame rate is updated and the filter cutoffs are adjusted. Only filters set with their cutoffs = 0 (auto) will be adjusted. There is a 2 second guard time after a successful update before retraining can start again to prevent rapid switching back and forth.

The logic is optimized to not perform any training if the filters are set to manual cutoffs. So there is an opportunity for advanced users to choose specific cutoffs and reduce the PID loop load slightly. However this is not recommended for Crossfire or other protocols that might change their rx frame rate.

Updated the output of the `rc_smoothing_info` cli command to match the revised logic.
2018-06-22 20:10:06 -04:00
Miguel Angel Mulero Martinez
d63eecffaa Add Iterm Relax INC modes 2018-06-15 15:08:09 +02:00
mikeller
5ff68d2c82 Fixed logging inconsistencies. 2018-06-10 13:26:58 +12:00
ctzsnooze
53476d45de bit more fine tuning 2018-06-10 10:15:19 +10:00
ctzsnooze
6d2c1a3c01 initial debug changes 2018-06-10 08:40:04 +10:00
ctzsnooze
705d3939eb Initial default suggestions for 3.4
Set default RC smoothing channels to RPYT

first attempt at enabling features by default

update filter notes
2018-06-09 22:26:00 +12:00
mikeller
06428c1b05 More fixes. 2018-06-09 19:20:46 +12:00
mikeller
d43c178488 Fixes from review. 2018-06-09 13:22:36 +12:00
Michael Keller
db3c0d1447 Some fixes. 2018-06-08 21:18:54 +12:00
Thorsten Laux
fefedbd686 attempts to improve relax
attempts to improve relax fix

attempts to improve relax fix

bug fixes

spaces

changed settings and added isAirmodeActive()

fix rebase error
2018-06-08 21:01:46 +12:00
Michael Keller
7936fb07d5
Merge pull request #6052 from mikeller/change_setpoint_weight_to_decimal_scaling
Changed 'dtermSetpointWeight' to use decimal scaling.
2018-06-07 23:38:16 +12:00
Michael Keller
2dd1d742bf
Merge pull request #6051 from etracer65/rc_smoothing_training
RC smoothing: improve rx frame rate detection, add rc_smoothing_info cli command
2018-06-07 16:22:48 +12:00
Michael Keller
3f3fb0c01c Changed 'dtermSetpointWeight' to use decimal scaling. 2018-06-06 11:21:11 +12:00
Bruce Luckcuck
e49c10b573 RC smoothing: improve rx frame rate detection, add rc_smoothing_info cli command
Improved the rx frame rate detection/training by delaying calculation to avoid loop time jitter during flight controller initialization.

For auto cutoffs calculate a value appropriate for BIQUAD or PT1 depending on the configuration.

Added a new rc_smoothing_info cli command to display internal details about its operation.
2018-06-05 18:25:13 -04:00
mikeller
a373204d7a Added validation checks for interpolation settings, made throttle boost conditional. 2018-06-05 18:38:57 +12:00
mikeller
e29fa595f5 Optimised the use of static variables in the PID loop. 2018-06-04 18:56:30 +12:00
Bruce Luckcuck
7e18d7c1b9 Make filter type selectable and add BIQUAD
Adds options to select the filter type for both input and derivative.
rc_smoothing_input_type = PT1 | BIQUAD (default is BIQUAD)
rc_smoothing_derivative_type = OFF | PT1 | BIQUAD (default is OFF)
2018-06-03 21:52:15 -04:00
Bruce Luckcuck
826609e703 Experimental filter-based rc channel smoothing
Adds an additional rc channel smoothing algorithm that can be used in place of the default rc interpolation. Utilizing a filter-based approach the smoothing has lower latency and is immune to loop time jitter that can introduce artifacts.  Additionally a smoothing filter is added to the setpoint derivative used to produce D-term setpoint weight resulting in a smoother effect on D.

The default setting is to use the previous interpolation logic and there are no changes unless the optional method is selected.

Configuration:

rc_smoothing_type: (INTERPOLATION | FILTER) - defaults to INTERPOLATION

rc_smoothing_input_hz: (0-255) - sets the rc channel input filter cutoff in Hz. Default value of 0 will enable auto calculation based on received RX frame rate.

rc_smoothing_derivative_hz: (0-255) - sets the setpoint weight derivative filter cutoff in Hz. Default value of 0 will enable auto calculation based on received RX frame rate.

rc_smoothing_debug_axis: (ROLL | PITCH | YAW | THROTTLE) - determines which axis is logged in the debug fields

Debug logging:

set debug_mode = RC_SMOOTHING

debug(0) = raw un-smoothed rc channel data
debug(1) = raw un-smoothed setpoint derivative
debug(2) = filtered setpoint derivative before applied to setpoint weight
debug(3) = auto-calculated filter cutoff frequency base after sampling the rx frame rate

Notes:

Currently only enabled for F4/F7 due to flash size limitations

Uses the rc_inter_ch parameter to determine which channels are smoothed (same as default interpolation logic)

The auto filter cutoff calculation will set a cutoff frequency of 30Hz for typical SBUS frames (9ms).  11ms Spektrum will calculate to approximately 25Hz. The user can manually enter the filter cutoffs to be used instead of the auto calculation.  The current default calculation was chosen as a good starting point but may be adjusted in the future.

Setting a lower cutoff frequency will result in more smoothing, but also more delay.

There currently isn't any support for receivers that change their rx frame rate dynamically.  So for CRSF users wishing to use this alternate smoothing method should change their settings to lock the rx frame rate for now. Support for auto-adjusting to new frame rates in flight will likely be added.
2018-06-03 21:52:01 -04:00
mikeller
f32731638d Removed default changes from this pull request. 2018-06-03 22:44:42 +12:00
mikeller
75693fbd5b Added defaults and MSP support to filter settings. 2018-06-03 22:44:42 +12:00
mikeller
a9b3911e03 Made new PID loop improvements conditional, disabled some for F3 to save flash space. 2018-06-03 17:07:10 +12:00
mikeller
c666fcfa17 Reordered and optimised pidProfile parameter group. 2018-05-31 23:51:31 +12:00
Thorsten Laux
bb71b6ec64 correct drift 2018-05-30 23:06:27 +02:00
Thorsten Laux
8fe07af613 correct stickInput 2018-05-30 23:06:27 +02:00
Thorsten Laux
0138200c1c initialize acErrorRate if iterm_relax is off 2018-05-30 23:05:16 +02:00
Thorsten Laux
b40db51448 address style issues and set off by default 2018-05-30 23:05:15 +02:00
Thorsten Laux
bd289121fc absolute control feature 2018-05-30 23:04:26 +02:00
Thorsten Laux
df71817fba incorporate style feedback 2018-05-30 23:01:54 +02:00
Thorsten Laux
7c8c3b6784 address style requests 2018-05-30 23:01:54 +02:00
Thorsten Laux
85b0f6f9c2 ITerm relax feature 2018-05-30 23:01:54 +02:00
Bruce Luckcuck
ad067ee09a Overshoot logic updates, disable for GPS Rescue, constrain max setpoint
Updates for finalize the flight performance.

Disable if GPS Rescue is active

Constrain the max setpoint calculated by the angle correction logic. To catch border cases where the user activates the feature while inverted and has a high gain which could result in excessively high setpoint rates.

Make sure internal states are reset when feature is activated via mode switch.
2018-05-29 21:08:19 -04:00
Bruce Luckcuck
2384088855 Requested changes, cleanup and control logic updates
Also added a new parameter acro_trainer_gain to allow adjustments to the limiting strength.
2018-05-29 21:08:19 -04:00
Bruce Luckcuck
9b43839052 Acro trainer
Adds a new angle limiting mode for pilots who are learning to fly in acro mode. Primarily targeted at new LOS acro pilots, but can be used with FPV as well.

The feature is activated with a new mode named "ACRO TRAINER". When the feature is active, the craft will fly in normal acro mode but will limit roll/pitch axes so that they don't exceed the configured angle limit. New pilots can start with a small angle limit and progressively increase as their skills improve.

The accelerometer must be enabled for the feature to be configured and function.

Also the feature will only be active while in acro flight and will disable if ANGLE or HORIZON modes are selected.

For most users all they need to do is simply configure the new mode to be active as desired on the "Modes" tab in the configurator and configure the desired angle limit in the cli.

Configuration parameters:

acro_trainer_angle_limit: (range 10-80) Angle limit in degrees.

acro_trainer_lookahead_ms: (range 10-200) Time in milliseconds that the logic will "look ahead" to help minimize overshoot and bounce-back if the limit is approached at high gyro rates. The default value of 50 should be good for most users. For low powered or unresponsive craft (micros or brushed) it may be helpful to increase this setting if you're seeing substantial overshoot.

acro_trainer_debug_axis: (ROLL, PITCH) The axis that will log information if debugging is active.

To enable debugging:
set debug_mode = ACRO_TRAINER

debug(0) - Current angle
debug(1) - The internal logic state
debug(2) - Modified setpoint
debug(3) - Projected angle based gyro rate and lookahead period
2018-05-29 21:08:16 -04:00
Michael Keller
eecb59db45
Merge pull request #5963 from joelucid/iterm_relax
ITerm relax feature
2018-05-30 09:32:21 +12:00
Thorsten Laux
dc929baf75 make itermRelax into enum 2018-05-29 16:40:23 +02:00
AJ Christensen
a63c8b0079 gyro & d-term filters: remove filtering options except biquad/pt1
* through extensive testing prior to the beginning of the RC cycle, we have
  discovered that the simplest combination of filters appears to be up to four
  PT1 filters: two for gyro, and two for d-term.
* non-cascaded biquad filter plumbing is retained for noisy setups and the
  dynamic notch bandpass, although gyro and d-term variants of the filtering may
  eventually be removed in favor of pt1
* update all related unit tests
2018-05-29 10:54:46 +12:00
Thorsten Laux
5bdc2ead61 make itermRelax an uint8_t 2018-05-28 16:44:13 +02:00
Thorsten Laux
6239b8258a make itermrelax on yaw optional 2018-05-28 16:41:05 +02:00
Thorsten Laux
2c02c14a1d debug log only roll and pitch, but separately 2018-05-28 16:40:09 +02:00