1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00
Commit graph

68 commits

Author SHA1 Message Date
ctzsnooze
16c157e840
Shared altitude control parameters (#13884) 2024-10-05 16:32:50 +10:00
Ivan Efimov
983b510184
Fix: Hyperbolic TPA curve initialization (for wings) (#13932) 2024-09-27 20:24:34 +02:00
ctzsnooze
254da8f460
Altitude hold for 4.6 (#13816) 2024-09-04 20:29:03 +10:00
ctzsnooze
3fe4281a63
Apply iterm_windup per-axis by limiting iTerm based on pidSum (#13543) 2024-09-04 11:26:40 +10:00
Ivan Efimov
ac384cf34c
Hyperbolic PID multiplier curve (for wings) (#13805)
* TPA_CURVE_HYPERBOLIC (for wings)

* typo fix: tpa_rate_stall_throttle

* ledvinap's review

* fix tpa_curve_expo divider (10 instead of 100)

* Define fixes

* whoops, 16 instead of 1600 for PWL points

* if case for when dividing by zero for hyperbolic expo

* More ledvinap's review

* pow instead of pow_approx + unit tests for hyperbolic TPA

* basic unit tests for classic TPA

* pow was for double. pow_approx for floats is enough

* remove #else from comments

* pow_approx -> powf for hyperbolic TPA

* PWL: brigning back static assert after #13818 PR

* removed extra line per haslinghuis's review
2024-08-29 15:57:03 +10:00
ctzsnooze
f2bd6e69b2
Feedforward improvements for 4.6 (#13576)
* feedforward update for 4.6

improve jitter reduction method
don't interpolate CRSF protocol
replace 'boost' with highpass element for yaw FF
make yaw highpass element CLI adjustable
add yaw feedforward sustain params to CLI and BBE
refactoring and unit test fix

* implement review suggestions, start on the filter struct

* Attempt PT1 filter init method

* fix silly error, scale time constant correctly

improve gain linearisation at shorter time constants

* fix averaging init

* Review suggestions from PL

* Improve filter initialisation

much better :-)

* re-name prevPacketDuplicate to prevPacketWasADuplicate

* Add review comments - thanks Jan and Mark!

* cast gyro.gyroDebugAxis to int

* A better fix than int cast

* implement review comments from PL

also hopefully improved some comments.

* increase PG to 10, expecting the Disarm PR to use 9

* two always win against one ;-)

* remove inappropriate comment, remove space

* update comments and review suggestions from PL
2024-08-25 09:34:27 +02:00
ctzsnooze
dd73ce4dd7
Re-name ezDisarm variables and tidying up (#13835)
* just re-naming variables and tidying up

* change name to landing_disarm_threshold
2024-08-21 09:01:49 +02:00
ctzsnooze
f890287598
Auto-disarm on landing impact (#13803)
* Disarm on landing

* Changes from review comments, thanks PL

* Sorry missed that one

* calculate Acc magnitude once only, not multiple times

* Include gyro factors as in crashRecovery

* Fix bug in CrashRecovery delta gains

Add temporary debugs to monitor error and delta inputs

* remove 1G subtraction for accMagnitude

thanks Karate

* Use AccDelta or Jerk - thanks Karate

* Revert using Gyro Setpoint and Delta

* Fix typo, thanks Mark

* increment PG version to 9
2024-08-10 08:34:51 +02:00
Ivan Efimov
e2e1a68ba0
S-term (for wings) (#13679)
* S-term for wings

* tabs

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>

* pidData[axis].S

---------

Co-authored-by: Petr Ledvina <ledvinap@gmail.com>
2024-06-20 12:01:13 +02:00
ctzsnooze
34057bfbc2
Refactor Feedforward Angle and RC Smoothing - mashup of 12578 and 12594 (#12605)
* Refactor Feedforward Angle and RC Smoothing

* update rc_smoothing at regular intervals

* add Earth Ref to OSD, update pid and rate PG

* Initialise filters correctly

* refactoring to improve performance

* Save 24 cycles in Horizon calculations, other optimisations

At a cost of 40 bytes

* save 25 cycles and 330 bytes in rc_smoothing

* feedforward max rate improvements

* typo fix

* Karatebrot's review suggestions  part one

* Karatebrot's excellent suggestions part 2

* more efficient if we calculate inverse at init time

Co-Authored-By: Jan Post <post@stud.tu-darmstadt.de>

* Horizon delay, to ease it in when returning sticks to centre

* fix unit tests after horizon changes

Co-Authored-By: 4712 <4712@users.noreply.github.com>

* horizon_delay_ms, default 500

* fix unit test for feedforward from setpointDelta

* Final optimisations - thanks @Karatebrot for your advice

* increase horizon level strength default to 75 now we have the delay

* restore Makefile value which allowed local make test on mac

---------

Co-authored-by: Jan Post <post@stud.tu-darmstadt.de>
Co-authored-by: 4712 <4712@users.noreply.github.com>
2023-04-23 22:03:18 +02:00
ctzsnooze
241e9a9b94
Angle and Horizon Mode improvements (#12231)
* Angle and Horizon Update for 4.5

* BugFix FF noise Angle Mode on yaw and in level _race mode

* use time constant in ms for angle feedforward smoothing

* refactor to remove unnecessary definition

---------

Co-authored-by: ChrisRosser <chrisrosser91@gmail.com>
2023-03-15 09:46:24 +11:00
haslinghuis
7e441b5f4f
Merge pull request #11887 from KarateBrot/styledef
Remove old style definitions
2022-10-16 00:22:02 +02:00
KarateBrot
ddf1d46549 Remove old style definitions 2022-10-13 03:33:54 +02:00
Tobias Bolin
2bdb660d56 Add test for anti-windup affecting Anti Gravity gain 2022-10-12 21:58:43 +02:00
Mathias Rasmussen
9957ceb275 Fix function brace style 2022-10-12 16:31:55 +02:00
ctzsnooze
db528ccc8f Restore iTerm Windup to all axes, active by default 2022-08-22 10:03:55 +10:00
ctzsnooze
6aaaf727ff update antigravity for 4.4, no boost on yaw
Update to anti-gravity, including removal of the old Step mode, ability to adjust the P contribution (thanks @Limon), PT2 smoothed derivative model, inherent limiting of P boost during extremely fast stick travels to minimise P oscillations, less I during the middle of a throttle up, no I boost on yaw, add hz to cutoff labels

No antigravity on yaw, fix longstanding typo

h
2022-07-25 11:37:07 +10:00
Štěpán Dalecký
f85ebba6a4 Refactoring of IMU and ACC 2022-06-28 18:26:10 +02:00
ctzsnooze
2262dfc60e use Throttle Setpoint, not rcDATA(throttle), for TPA 2022-01-25 18:37:01 +11:00
Mathias Rasmussen
87c259a26e Fix use of floating point math functions 2021-12-21 04:18:59 +01:00
ctzsnooze
99a7479b8c consistent gyro and dterm filter names 2021-09-27 09:12:00 +10:00
ctzsnooze
5863015354 ifdef condition consistently applied, field names consistent, pg ID updated 2021-08-30 09:33:12 +10:00
ctzsnooze
28d9d778a6 feedforward transition moved to feedforward.c 2021-08-30 02:07:36 +10:00
ctzsnooze
c26428232a msp and other small fixes 2021-05-25 08:29:32 +10:00
ctzsnooze
3b62b2e5d4 add PT2 and PT3 lowpass filter options 2021-05-18 09:59:27 +10:00
ctzsnooze
636d563abe major rc changes ctzsnooze 2021 2021-05-07 14:40:43 +10:00
Bruce Luckcuck
87f322927a Self-level modes expo
Adds angle setpoint roll/pitch expo for self-level modes.

Previously the angle setpoint was a simple linear calculation based on the stick deflection percentage and the angle limit. This makes control very jumpy around center stick and people would often resort to adding expo in their radios to compensate. This then adds the complication of wanting expo in the radio when in self-level but not when in acro - leading to complicated mixes, virtual switches, etc.

This PR adds separate self-level expo settings for roll/pitch so the user can customize the axis behavior. Yaw is excluded because this axis uses normal rates and expo controlling the rotational rate around the yaw axis and not an angle setpoint. The roll/pitch expo can range from 0 (off) to 100 (max) like other RC expo settings. For example:
```
set roll_level_expo = 30
set pitch_level_expo = 40
```
The default values are 0 which disables any expo and behaves as before.

The settings are available in the CMS rate profile menu.
2021-01-25 19:08:43 -05:00
mikeller
b6689edc26 Removed VBat PID compensation. 2020-06-22 01:12:47 +12:00
Bruce Luckcuck
c06106e2d1 Split initialization from pid.c for flash savings
Move low performance requirements initialization code into pid_init.c and optimize that for size.

Saves 2688 bytes for target STM32F7X2.
2020-05-03 13:58:55 -04:00
Bruce Luckcuck
e76fd50421 Change iterm_windup to only apply to yaw
Except for when Launch Control is active - then apply to all axes.
2020-03-15 13:03:02 -04:00
Michael Keller
ea4f30c3ac
Revert "apply iterm_windup to yaw only" 2020-03-16 02:00:50 +13:00
mikeller
53ba871a34 Fixed unit tests. 2020-03-14 10:19:33 +13:00
Michael Keller
c984107291
Merge pull request #9482 from ctzsnooze/Revert-iTerm-Relax
Restore proper behaviour of iterm_relax_cutoff in setpoint mode
2020-02-17 08:11:26 +13:00
phobos-
8ce268d5f1 Implemented NFE Race Mode 2020-02-16 13:46:08 +01:00
mikeller
bc4701aebf Simplified the calculations, fixed tests. 2020-02-16 10:34:31 +13:00
Bruce Luckcuck
f584780944 Gyro native rate sampling, filtering, and scheduler restructuring 2020-02-04 18:19:35 -05:00
Michael Keller
69a3a4ac08
Merge pull request #9315 from hydra/bf-log-disarm-reason
Log disarm reason.
2020-01-17 19:30:37 +13:00
Dominic Clifton
2fead0aedf Log disarm reason. 2020-01-16 20:16:11 +01:00
Michael Keller
71661acde2 Changed 'ASSERT_' in unit tests to 'EXPECT_' for more comprehensive failure reporting. 2019-12-27 14:30:24 +13:00
Thorsten Laux
91ad2498ff ff from interpolated setpoint 2019-08-08 09:50:18 +02:00
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
mikeller
760a524027 Fixed tests, added crash indication. 2019-04-05 08:39:23 +13: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
ctzsnooze
0f8c85ad0d Update unit test values for higher relax threshold
Update unit test values for higher relax threshold
2019-03-03 11:34:07 +11:00
mikeller
03dc1a1aee Fixed tests. 2019-02-28 19:52:11 +13: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
mikeller
b5908f5bab Applied 'USE_ACC' consistently. 2019-02-08 09:51:48 +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
Thorsten Laux
b0af988a75 unit test bugs 2018-12-10 19:28:18 +01:00