1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00
Commit graph

738 commits

Author SHA1 Message Date
Michael Keller
4246f06529
Merge pull request #7073 from ctzsnooze/Update-D-defaults
Set TPA default to D only, increase D about 10%
2018-11-25 13:31:29 +13:00
Bruce Luckcuck
932b8e01c8 Launch Control: Add yaw iterm windup limit
When operating in `launch_control_mode = FULL` mode (all axes), limit the yaw iterm to reduce the risk of windup.
2018-11-14 17:23:20 -05:00
ctzsnooze
51ff89ed99 Set TPA default to D only, increase D about 10% 2018-11-11 21:44:18 +11:00
Bruce Luckcuck
357d19aa05 Move parameter from PID profile to rate profile 2018-11-09 08:05:40 -05:00
Bruce Luckcuck
fc189e5850 Make TPA configurable to affect P/D or D only
Adds a new `tpa_mode` parameter that accepts `PD` (default) and `D`. Allows the user to configer to affect P/D as it always has, or switch to D-only mode.

Note: the `tpa_mode` parameter was added to the PID Profile instead of rate profiles with the other TPA parameters. This can be discussed, but I didn't think it made sense to have this be part of rate profiles as it affects PID tuning (the same argument could be made for the other TPA parameters).

Code is wrapped in `USE_TPA_MODE` so it can be disabled if needed.
2018-11-08 19:22:29 -05:00
borisbstyle
7566f81d38
Merge pull request #6911 from jflyper/bfdev-move-USE_ITERM_RELAX-to-include-USE_ABSOLUTE_CONTROL
Move USE_ITERM_RELAX up to prevent unused warning of applyAbsoluteControl
2018-11-08 11:50:13 +01:00
Michael Keller
863ee8d114
Merge pull request #7034 from etracer65/level_mode_crash_recovery_delay
Prevent crash recovery detection immediately after entering self-level or GPS Rescue modes
2018-11-04 13:38:17 +13:00
Bruce Luckcuck
13e06d6e30 Reset the crash recovery guard time whenever GPS Rescue is activated
So now the guard time will be set either:
* When changing from level-mode off to on (angle or horizon modes)
* GPS Rescue activates
2018-11-03 19:42:34 -04:00
Bruce Luckcuck
bb834bb126 Prevent crash recovery detection immediately after entering self-level modes
If the quad is in an extreme orientation (like upside down) the transition to self-level modes can cause enough motion to trigger crash recovery. Added a 1 second delay during which crash recovery detection is blocked immediately after entering a self-level mode.

This also addresses an issue with GPS Rescue as when it activates it enables self-level. If in the above scenario this triggered a crash recovery detection then GPS Rescue would interpret this as a crash and immediately disarm.
2018-11-02 23:43:41 -04:00
Bruce Luckcuck
cca3b30a77 Reduce runaway takeoff deactivate throttle to 20%
In recognition that the average quad is getting more powerful and can hover at a lower throttle.
2018-11-02 16:23:50 -04:00
Michael Keller
c0344496ca
Merge pull request #6992 from etracer65/launch_control
Launch Control
2018-11-02 00:49:42 +13:00
Bruce Luckcuck
b723d2976d Changes from review and add unit tests
Stylistic updates and add tests to the PID unit tests to verify launch control behavior
2018-10-30 18:14:49 -04:00
ctzsnooze
de8df24857 Increase default amount of I for 4.0 2018-10-30 12:14:15 +11:00
Bruce Luckcuck
e4dc93b128 Launch Control
Adds a race start assistance system that allows the pilot to pitch forward and then release the sticks with the quad holding position for the race start.
2018-10-27 11:50:37 -04:00
Kenneth Mitchell
ff8d1a842a
Fixes from reviews. 2018-10-25 20:34:55 -04:00
Kenneth Mitchell
ca460e842b
Implement throttle based dynamic gyro and dterm filters. 2018-10-25 19:23:14 -04:00
Steffen Windoffer
f45ab5bb0a cleanup dterm lowpass order 2018-10-20 15:12:40 +02:00
Kenneth Mitchell
641d0a2e54 Implement biquad on 2nd dterm lowpass filter. 2018-10-14 13:34:11 -04:00
jflyper
f00a8e6d0f Move USE_ITERM_RELAX to prevent unused warning of applyAbsoluteControl 2018-10-09 12:42:58 +09:00
borisbstyle
87b2eeb2fd More isolated pid_unittests
Refactor iterm_relax to iterm_relax_axis

Isolate pidLevel test

Isolate pidHorizon tests

remove if UNIT_TEST

revert to iterm_relax from iterm_relax_axis
2018-09-19 08:15:32 +02:00
ctzsnooze
299a2d6b8b whitspace 2018-09-15 12:28:41 +10:00
ctzsnooze
ac5d2fbb3a set default to original 40% 2018-09-15 12:20:00 +10:00
ctzsnooze
37da70c555 rebase and recheck 2018-09-15 12:19:53 +10:00
ctzsnooze
80608f5f1c camelCase fix, else added, getMotorMixRange directly 2018-09-15 11:57:47 +10:00
ctzsnooze
586e674898 get motorMixRange only when needed, default inv to 1, editorial 2018-09-15 11:57:47 +10:00
ctzsnooze
942d1bb384 add const, remove float cast 2018-09-15 11:57:47 +10:00
ctzsnooze
f545637669 defaults to improve yaw behaviour, ITermWindupPointInv already defined at zero 2018-09-15 11:57:46 +10:00
borisbstyle
afccf50d96 Add Iterm Relax unittest // refactor
Refactor PID code Iterm Relax and Absolute control

Move defines for unittest to Makefile

Fix unittest isAirmodeActivated()

Absolute control unittests + optimizations

Fix dead code absolute control // unittests

Further optimizations to absolute control switch logic
2018-09-12 08:09:21 +02:00
borisbstyle
aa44fd6bbd Change default iterm_windup 2018-09-10 23:38:40 +02:00
borisbstyle
00dbaf9fa7 Cleanup code // add unittestst for iterm windup 2018-09-10 23:38:39 +02:00
Bruce Luckcuck
9cf671b817 Change dterm_notch_cutoff default to 0
The dterm notch is disabled and dterm_notch_hz is already 0 by default. When the Configurator saves changes from the PID Tuning tab and the notch is disabled it sets both dterm_notch_hz and dterm_notch_cutoff to 0.  Since the default was left at 160, this makes dterm_notch_cutoff appear in diff outputs.  Ultimately it's just cosmetic since the dterm notch is disabled if either value is zero.  But there's no reason for the dterm_notch_cutoff to remain set to the legacy 160 value.
2018-09-10 08:07:27 -04:00
Michael Keller
c71b1cb0df
Merge pull request #6721 from betaflight/anti_windup_fix
Fix bug with antiwindup inversion
2018-09-10 20:51:15 +12:00
borisbstyle
864a2d6a2b Fix bug with antiwindup inversion 2018-09-10 09:08:36 +02:00
ctzsnooze
acbc041259 use the defined value in both places 2018-09-10 16:52:27 +10:00
Bruce Luckcuck
960442e917 Fix iterm relax interfering with crash recovery
Iterm Relax was inserted before crash recovery and this was causing the recovery to be ineffective or fail completely. The problem was that the subsequent iterm calculation was not using the calculated recovery error and instead was using the setpoint error. As such I ended up accumulating and opposing P based on recovery error. This prevented the efforts of crash recovery to level the quad and since it couldn't reach the level state crash recovery wouldn't shut off. This resulted in the pilot only having control over yaw and throttle while crash recovery was still ineffectually trying to control roll/pitch.

The fix is to move crash recovery handling ahead of the iterm relax calculations and make sure that iterm relax uses the error calculated from crash recovery if active.  This also allows crash recovery to reset the iterm accumulation as originally designed.
2018-09-02 09:58:16 -04:00
mikeller
0bce8549ee Renamed 'fc/fc_' files to remove the double 'fc'. 2018-08-26 14:07:06 +12:00
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