1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00
Commit graph

515 commits

Author SHA1 Message Date
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
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