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

288 commits

Author SHA1 Message Date
Hans Christian Olaussen
242d5df827 tabs and spaces 2021-04-26 19:11:47 +02:00
KarateBrot
d02af7334c Added tracking of multiple dynamic notches per axis and replaced FFT with SDFT 2021-03-24 17:09:28 +01:00
Nicola De Pasquale
698974a085 revert default dyn_lpf_expo_curve value for gyro 2021-01-24 15:40:56 +01:00
Michael Keller
58b4cb916c Added missing simplified gyro tuning defaults. 2020-12-26 14:27:06 +01:00
IvoFPV
cff19dc113 Implement tuning sliders, add to CMS, MSP 2020-12-26 14:26:50 +01:00
Nicola De Pasquale
3714903122 enabled gyro dlpf by default 2020-10-03 22:10:36 +02:00
Sam Lane
4c99ad743d Rename FAST_RAM to FAST_DATA 2020-08-23 08:49:26 +01:00
Nicola De Pasquale
c1ce6f30f8 removed unnecessary static declarations 2020-08-16 11:12:55 +02:00
Nicola De Pasquale
d0fe84528a using same curve of dyn dterm lpf 2020-08-08 15:36:28 +02:00
Nicola De Pasquale
988024ee4e updated dynThrottle curve 2020-08-07 15:28:36 +02:00
Bruce Luckcuck
ad0e7154a7 Split initialization from gyro.c for flash savings
Move low performance requirements initialization code into gyro_init.c and optimize that for size.
2020-03-13 10:08:11 -04:00
Bruce Luckcuck
447cbac988 Add support for Bosch BMI270 gyro/accelerometer sensor 2020-03-08 18:56:50 -04:00
Bruce Luckcuck
c128b16122 Fix "may be used uninitialized" warnings
Prevent the false warnings when compiled for debugging
2020-02-21 18:48:30 -05:00
jflyper
ff16686893 White space tidy 2020-02-17 23:54:57 +13:00
Bruce Luckcuck
653fe308cb Add "auto" mode to yaw spin recovery
Changes yaw spin recovery from a simple on/off to on/off/auto. In auto mode the triggering threshold is automatically calculated based on the user's current max yaw rate.

So `yaw_spin_recovery` has the following options:
`OFF`: Feature is disabled
`ON`: Feature is enabled with a manually configured `yaw_spin_threshold`
`AUTO`: Feature is enabled and the trigger threshold is automatically calculated.

The auto calculation of the trigger threshold is:
```
MAX(yawRate * 0.25, 200)
```
The 25% of the user's rate is to provide a buffer for yaw overshoots during normal flight. Overall the threshold is constrained between 500 - 1950 to match the manual selection.

The default is changed from `ON` to `AUTO` so that users will get protection without needing to configure the threshold manually.

In `AUTO` mode the threshold is calculated dynamically so rate changes in flight (like rateprofile change) will set a new trigger threshold.
2020-02-05 23:55:31 -05:00
Bruce Luckcuck
f584780944 Gyro native rate sampling, filtering, and scheduler restructuring 2020-02-04 18:19:35 -05:00
ctzsnooze
7b2e075b3a Simplify and improve Dynamic Notch
Remove prevCenterFreq[axis]
Simpler peak detection:
- cubes, not squares
- only look one bin either side
More accurate frequency determination
Updated annotations and explanations
Whitespace fixes
fftStartBin can't be less than 1
Dynamic PT1 smoothing
biquad filter on centerFreq removed
centerFreq's now floats

Limits and better min max logic

constrain within nyquist limits

If gyro rate was 2khz and dynamic notch range max, this will keep the notch max to 960hz.

Simple fixes

Get lowest min above and below the peak

First go at setting DN range by a maxHz

increment the PG version in gyro.c

MSP correct size

Resolve comments from Mike and Rav.

Fis msp, deprecating range
2020-01-26 13:05:24 +13:00
jflyper
be923434b8 Rename FLASH_SIZE to TARGET_FLASH_SIZE 2020-01-20 12:30:28 +09:00
Dominic Clifton
3b3ead25f0 ICM42605 - Initial sensor support. 2019-12-26 20:09:47 +01:00
mikeller
935a684765 Fixed use of 'abs()' for floats. 2019-11-30 10:33:12 +13:00
mikeller
cedcf2d7e2 Added calibration menu to CMS. 2019-11-19 13:59:52 +13:00
mikeller
4a7904695e Moved 'config.[ch]' into the 'config/' directory. 2019-10-28 11:17:25 +13:00
Michael Keller
c3fff1a5de Fixed instances of int functions being used in float expressions. 2019-10-08 15:45:00 +13:00
ctzsnooze
f61a940a05 Set default dyanmic notch range to medium
In 4.0x the dynamic notch range was set by default to AUTO mode.

This would set range to low, medium or high based on the dynamic lowpass max setting, which the user was supposed to configure to suit the maximum rpm of the quad.

In 4.1 we are moving the maximum value of the dynamic gyro lowpass very high whenever the rpm filter is enabled.  And, generally, it is OK to do this even on non-rpm quads.

The problem then becomes that the dynamic notch quietly shifts itself to HIGH mode, and that can cause it to not track ordinary frame and prop resonances like it should.

I think it will be better overall in medium mode, which works best for most quads out of the box.  Users of very high RPM quads can choose high.  XClass quads or machines with low frequency resonance should choose low, and should set the dyn_notch_min_hz value low enough to reach the resonant peak.
2019-09-02 15:50:10 +10:00
Michael Keller
1585b4a31a
Merge pull request #8784 from ctzsnooze/Static-lowpass1-to-match-min
Set default static lowpass1 gyro value to the same as default gyro lowpass1 min
2019-09-01 15:43:28 +12:00
Bruce Luckcuck
86f9960987 Gyro filtering restructure
Refactor the gyro filtering to move the filters from the individual gyro sensor and make them part of the logical gyro object. For dual-gyro mode the sensors are averaged BEFORE and then filtering is applied. This differs from the current structure where filtering is applied individually to each sensor and the results were averaged at the end.

Significantly reduces filtering processing load and enables RPM Filtering for dual-gyro mode.
2019-08-31 19:13:41 -04:00
ctzsnooze
e1c1fa8e47 Set static lowpass1 on gyro to match gyro lowpass1 min
In 4.0, the dynamic gyro lowpass1 min and the static gyro lowpass1 alternative had the same values, so that if the dynamic lowpass was not active, we would get conservative static filtering.

In moving to 4.1 with PT1 filtering we have raised the dynamic gyro lowpass1 min, but not raised the static gyro lowpass1 value.

We should make them both the same, again.
2019-08-31 12:25:37 +10:00
Bruce Luckcuck
50ce338390 Correct IMU gyro input to be based on sample loop time rather than actual delta time
The current calculation accumulates gyro data between IMU updates based on the actual time delta betwwn samples. The problem with this is that loop time jitter or delays will decrease the accuracy of the gyro rotational input into the attitude calculation. The sensor samples based on a hardware driven clock that matches the `gyro.targetLooptime`. The sensor captures samples at these intervals regardless of when we read them so the calculation should be based on the duration between samples rather then the duration between processing loops.

Will improve the accuracy of the IMU attitude estimate - particularly in cases of higher CPU load and increased looptime jitter. Bench testing shows reduced drift. Also flight tested and behaved as expected.
2019-07-26 16:32:03 -04:00
jflyper
b90ed88f2e Bypass calibration for GYRO_FAKE 2019-07-17 23:36:54 +09:00
jflyper
a78238e0f2 Allow resorting to fake gyro if USE_FAKE_GYRO is defined 2019-07-17 14:03:24 +09:00
Dominic Clifton
980df1536f Refactored arbitrary gyro and mag alignment.
The original implementation:

* removed the old 'alignment' variable
* did not require 'ALIGN_CUSTOM'
* always used rotation matrix
* had no additional per-pid-loop conditional logic.

Extract currently unused code into tests.
In preparation for either deleting or re-using in validateAndFixConfig.

Fix code style of some old boardalignment code.

De-duplicate vector rotation code.

Now that rotation code is exacted from `alignBoard` and now  doesn't use
`boardRotation` some if it was similar to the code in `rotateV` in
maths.c

Use DECIDEGREES for mag and gyro/acc custom alignments.

Use unnamed structure instead of `values`.

Redefine what 'custom' orientation means.

Move alignment test-only code into the tests.

Ensure gyro/mag custom alignment settings follow the enum variations.

This can't be applied to ALIGN_DEFAULT because, in the case of the MAG,
the default isn't actually known until the gyro is detected, see
`compassDetect`.

OMNIBUSF4/F7 - Don't use ALIGN_DEFAULT in target.h,
common_defaults_post.h does this now.

Comment cleanup.

Delete unused alignment code left from various tests/refactoring
efforts.

* Please do not squash this commit.

Fix SITL build by avoiding structure assignment with anonymous inner
struct.

The error from the build server was as follows:

```./src/main/common/sensor_alignment.c:49:5: error: missing initializer
for field ‘yaw’ of ‘struct <anonymous>’
[-Werror=missing-field-initializers]
     *sensorAlignment = CUSTOM_ALIGN_CW0_DEG;
     ^
In file included from ./src/main/common/sensor_alignment.c:27:0:
./src/main/common/sensor_alignment.h:80:17: note: ‘yaw’ declared here
         int16_t yaw;
                 ^
```

Cleanup sensor_alignment API.
2019-07-13 11:51:20 +12:00
ctzsnooze
5b1c3749c3 Update 4.0x filters
Evolutionary changes to the original 4.0 defaults.
Intended to reduce chance of D-mediated flyaways on arming.
Also seems to fly better due to less gyro delay.
CHanges:
- Gyro filtering dynamic reverts back to PT1, to provide less delay, and in recognition that gyro filtering was more than adequate with the biquad.  Setpoints are higher due to lower reach of PT1.  The static gyro biquad at 150 was lower than really needed.  Markedly less gyro delay.
- Stronger D term filtering, especially at low throttle, to greatly reduce risk arming flyaways. The Dynamic D biquad is now set almost twice as low, with strong cut at 100hz where D resonance flyaways seemed to be driven from.  This filter array results in a D noise contribution that is typically not much greater than the P contribution, keeping very cool motors despite the lesser gyro filters.  This has been well tested using PID Toolbox.
Although there is more delay in D, this is offset by the reduced gyro delay.
2019-05-15 11:01:06 +10:00
Michael Keller
89179fb6e8
Renamed 'gyro_filter_impl.h' to 'gyro_filter_impl.c'. (#8187)
Renamed 'gyro_filter_impl.h' to 'gyro_filter_impl.c'.
2019-05-07 12:13:30 +12:00
mikeller
5fded1b56f Renamed 'gyro_filter_impl.h' to 'gyro_filter_impl.c'. 2019-05-07 00:49:14 +12:00
mikeller
5141bbfa94 Moved 'rpm_filter' into 'flight'. 2019-05-06 00:10:31 +12:00
Michael Keller
95be4b0195
Merge pull request #8102 from etracer65/dyn_lpf_gyro_to_use
Change gyro dynamic lpf throttle update to use the active gyro selection
2019-04-29 01:23:17 +12:00
Michael Keller
3589824b7c
For Discussion: modify filter defaults to reduce risk of flyaways (#8043)
For Discussion: modify filter defaults to reduce risk of flyaways
2019-04-28 12:22:31 +12:00
Bruce Luckcuck
5b22ed3d15 Change gyro dynamic lpf throttle update to use the active gyro selection
Instead of the configuration value.
2019-04-26 20:05:41 -04:00
ctzsnooze
80f5fa2c6d For Discussion: modify filter defaults to reduce risk of flyaways
Some users have reported flyaways on arming/throttling up with betaflight 4.0, in quads that fiy alright on 3.5.
This PR changes the default filtering so that D transmission more closely approximates that of 3.5.
With these defaults, quads that fly OK on 3.5 should not take-off vertically due to uncontrolled D oscillation.
2019-04-19 11:48:44 +10:00
Dominic Clifton
67bd97b193 Really fix gyro detection code code for multi gyro setups.
Broken in e44f75b4a7.

Problem caused by not checking both of the bits after masking.

Prior to this commit the code would incorrectly attempt to use GYRO1
when only GYRO2 was detected resulting in a segfault.
2019-04-17 15:31:08 +02:00
Bruce Luckcuck
acf0af7790 Add DUAL_GYRO_SCALED debug mode to capture raw scaled roll/pitch from each gyro
Data is before the filters but scaled to 0-2000dps.

debug(0) = gyro 1 roll
debug(1) = gyro 1 pitch
debug(2) = gyro 2 roll
debug(3) = gyro 2 roll
2019-04-08 10:26:11 -04:00
Michael Keller
2eb8762d6f
Merge pull request #7918 from etracer65/unify_lowpass_settings
Unify lowpass settings regardless of whether USE_DYN_LPF is defined
2019-04-04 01:42:02 +13:00
mikeller
e44f75b4a7 Fixed gyro detection for multi gyro setups. 2019-04-04 00:39:55 +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
d16f35d9cb Fixed defaults for lowpass filters. 2019-03-28 22:58:22 +13:00
Dominic Clifton
b7417a6d3d Fix crash when first or second gyro is not detected.
Firmware now silently uses the one it does find.

User can detect this by looking at the `diff` output.
2019-03-19 20:47:01 +01:00
AJ Christensen
4fdee6ec1c Gyro Sensors: Remove 32kHz gyro sampling mode(s) and associated code 2019-02-13 22:41:21 +13:00
mikeller
21edada68b Removed leftover references to 'gyro_align', 'acc_align'. 2019-02-01 01:50:40 +13:00
jflyper
5b40bb4b24 Set acc alignment to that of active gyro 2019-01-29 11:33:01 +09:00
AJ Christensen
5bcf35c7af Extend gyro filter implementation debugging for pitch and yaw axis.
* Introduce CLI parameter gyro_filter_debug_axis which defaults to 'ROLL',
  the previous behavior. When set to either PITCH, or YAW, the debug logging
  implementation in the gyro filtering will use that axis instead.
2019-01-21 22:22:37 +13:00