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

269 commits

Author SHA1 Message Date
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
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
Thorsten Laux
9ef95bb84d address code review comments 2019-01-08 09:50:26 +01:00
Thorsten Laux
8d4ed72e13 rpm telemetry based notch filter 2019-01-07 13:36:01 +01:00
mikeller
fdd5869054 Update L3GD20 gyro to modern gyro API. 2018-12-19 01:25:39 +13:00
jflyper
a27a374f41 Do call gyroPreInitsensor for gyro 2 even if it is not activated. 2018-12-17 02:07:50 +09:00
jflyper
9ea1428d11 Introduce per device pin pre-init 2018-12-13 11:15:26 +09: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
Bruce Luckcuck
afc1591956 Dual gyro debugging optimize
Bypass the numerous dual-gyro DEBUG_SET statements unless a related debug_mode is set. The dual-gyro debugging is rarely used so in most cases all of the statements can be bypassed. Saves 1-2% CPU load on SPRACINGF7DUAL running in `gyro_to_use = BOTH` and at 32K.
2018-11-08 14:54:16 -05: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
Bruce Luckcuck
8e0128a2b2 Fix ordering of gyro filtering and overflow/yaw-spin logic
Since the gyro overflow and yaw-spin logic uses filtered gyro data they need to be after the filter application.

Currently the logic is before causing it to operate on one sample old data. This won't prevent the logic from working and it's not a critical fix, but it's better to have the checks after the filtering.
2018-10-01 10:27:48 -04:00
Bruce Luckcuck
6656780205 Dual gyro fixes - fix non-reentrant code in gyro sensor update and fix hardcoded gyroSensor1 logic
Fixes instances of hardcoded gyroSensor1 in the status functions for overflow detection, yaw spin detection, and the sensor temperature reading.

Also fixes non-reentrant code in gyroUpdateSensor() that would not behave properly when gyro_to_use = BOTH
2018-09-28 12:57:30 -04:00
jflyper
fc6c24c38e Configurable acc/gyro 2018-09-10 17:55:52 +09:00
jflyper
58647e678f Remove reset facility 2018-09-06 20:07:09 +09:00
jflyper
9caeceb2dd Resolve upward inclusion 2018-09-06 18:43:58 +09:00
Michael Keller
c12981f732
Merge pull request #6617 from etracer65/gyro_lpf_updates
Disable DLPF EXPERIMENTAL mode for MPU60x0; remove experimental support from F3
2018-08-23 22:25:48 +12:00
Bruce Luckcuck
ec038c7db4 Changes from review - add default clause and update PG version 2018-08-22 17:26:23 -04:00
mikeller
6de1c32d9d Added shadow copies for CLI and MSP. 2018-08-21 00:36:47 +12:00