Commit Graph

39 Commits

Author SHA1 Message Date
ctzsnooze 4c917efa50 Smooth anti gravity 2018-07-21 23:49:41 +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
mikeller 2f0c8d26ff Fix from review. 2018-06-10 03:21:27 +12:00
Bryce Johnson a86e0bc41c frsky-spi-D16 was counting every telemetry state as a good packet. If it was garbage packet it would go straight into the rcData
Add some debugging
2018-06-10 01:37:31 +12:00
AJ Christensen f2cc9acc1f gyro sensors/debug: standardize gyro debugging enum elements
* will require coordination with BFC of course.
* rationale: previously `DEBUG_GYRO_NOTCH` debugging was used to grab the
  scaled, unfiltered gyro readings, prior to the FFT running. This has been
  updated to `DEBUG_GYRO_SCALED`.

  similarly, `DEBUG_GYRO` debugging was used to record the filtered gyro. This
  is updated to `GYRO_FILTERED`.

  interestingly, `DEBUG_GYRO` was also used for movement threshold calibration.
  This has been updated to be `DEBUG_GYRO_CALIBRATION` and also now stores
  per-axis standard deviation.

  Application of filter position moved slightly for logical grouping, has no
  effect due to LTI.
2018-06-07 17:17:26 +12:00
Bruce Luckcuck 826609e703 Experimental filter-based rc channel smoothing
Adds an additional rc channel smoothing algorithm that can be used in place of the default rc interpolation. Utilizing a filter-based approach the smoothing has lower latency and is immune to loop time jitter that can introduce artifacts.  Additionally a smoothing filter is added to the setpoint derivative used to produce D-term setpoint weight resulting in a smoother effect on D.

The default setting is to use the previous interpolation logic and there are no changes unless the optional method is selected.

Configuration:

rc_smoothing_type: (INTERPOLATION | FILTER) - defaults to INTERPOLATION

rc_smoothing_input_hz: (0-255) - sets the rc channel input filter cutoff in Hz. Default value of 0 will enable auto calculation based on received RX frame rate.

rc_smoothing_derivative_hz: (0-255) - sets the setpoint weight derivative filter cutoff in Hz. Default value of 0 will enable auto calculation based on received RX frame rate.

rc_smoothing_debug_axis: (ROLL | PITCH | YAW | THROTTLE) - determines which axis is logged in the debug fields

Debug logging:

set debug_mode = RC_SMOOTHING

debug(0) = raw un-smoothed rc channel data
debug(1) = raw un-smoothed setpoint derivative
debug(2) = filtered setpoint derivative before applied to setpoint weight
debug(3) = auto-calculated filter cutoff frequency base after sampling the rx frame rate

Notes:

Currently only enabled for F4/F7 due to flash size limitations

Uses the rc_inter_ch parameter to determine which channels are smoothed (same as default interpolation logic)

The auto filter cutoff calculation will set a cutoff frequency of 30Hz for typical SBUS frames (9ms).  11ms Spektrum will calculate to approximately 25Hz. The user can manually enter the filter cutoffs to be used instead of the auto calculation.  The current default calculation was chosen as a good starting point but may be adjusted in the future.

Setting a lower cutoff frequency will result in more smoothing, but also more delay.

There currently isn't any support for receivers that change their rx frame rate dynamically.  So for CRSF users wishing to use this alternate smoothing method should change their settings to lock the rx frame rate for now. Support for auto-adjusting to new frame rates in flight will likely be added.
2018-06-03 21:52:01 -04:00
Bruce Luckcuck 9b43839052 Acro trainer
Adds a new angle limiting mode for pilots who are learning to fly in acro mode. Primarily targeted at new LOS acro pilots, but can be used with FPV as well.

The feature is activated with a new mode named "ACRO TRAINER". When the feature is active, the craft will fly in normal acro mode but will limit roll/pitch axes so that they don't exceed the configured angle limit. New pilots can start with a small angle limit and progressively increase as their skills improve.

The accelerometer must be enabled for the feature to be configured and function.

Also the feature will only be active while in acro flight and will disable if ANGLE or HORIZON modes are selected.

For most users all they need to do is simply configure the new mode to be active as desired on the "Modes" tab in the configurator and configure the desired angle limit in the cli.

Configuration parameters:

acro_trainer_angle_limit: (range 10-80) Angle limit in degrees.

acro_trainer_lookahead_ms: (range 10-200) Time in milliseconds that the logic will "look ahead" to help minimize overshoot and bounce-back if the limit is approached at high gyro rates. The default value of 50 should be good for most users. For low powered or unresponsive craft (micros or brushed) it may be helpful to increase this setting if you're seeing substantial overshoot.

acro_trainer_debug_axis: (ROLL, PITCH) The axis that will log information if debugging is active.

To enable debugging:
set debug_mode = ACRO_TRAINER

debug(0) - Current angle
debug(1) - The internal logic state
debug(2) - Modified setpoint
debug(3) - Projected angle based gyro rate and lookahead period
2018-05-29 21:08:16 -04:00
Thorsten Laux 791c584d81 add debug option DEBUG_ITERM_RELAX 2018-05-28 16:37:41 +02:00
s0up ac6b8088c9 add gps rescue mode 2018-05-20 16:28:17 -07:00
mikeller a48da6c1ee Cleaned up SmartAudio debugging. 2018-05-13 02:08:27 +12:00
blckmn a9f74cd6df Removed excess trailing spaces before new lines on licenses. 2018-04-25 20:58:00 +10:00
blckmn 46fe22b4bd Direct license replacement 2018-04-22 09:22:46 +10:00
Michael Keller b2c247d34a
Added USB VCP detect and debugging. (#5689) 2018-04-18 01:22:46 +12:00
conkerkh c182748dbb SDIO rewrite in baremetal, fixes for WORMFC. (#5441)
* SDIO rewrite in baremetal, fixes for WORMFC.

* Fix identation, move LED TIM

* Fix identation
2018-03-21 00:08:34 +13:00
conkerkh 742cb5f93b Add current sensor debug option. (#5260)
Allows for easy calculation of required scale and offset.

0 - miliVolts
1 - centiAmps
2 - amperageLatest
3 - mahDrawn
2018-03-04 11:42:41 +13:00
Dominic Clifton cde9a9517b SPRacingF7DUAL - Dual SIMULTANEOUS gyro support. (#5264)
* CF/BF - Set STM32F7 SPI FAST clock to 13.5Mhz - Gyros not stable at
27mhz.

* CF/BF - Initial SPRacingF7DUAL commit.

Support two simultaneous gyro support (code by Dominic Clifton and Martin Budden)
There are new debug modes so you can see the difference between each gyro.

Notes:
* spi bus instance caching broke spi mpu detection because the detection
tries I2C first which overwrites the selected bus instance when using
dual gyro.
* ALL other dual-gyro boards have one sensor per bus.  SPRacingF7DUAL is has two per bus and thus commit has a lot of changes to fix SPI/BUS/GYRO initialisation issues.

* CF/BF - Add SPRacingF4EVODG target.

This target adds a second gyro to the board using the SPI pads on the back of the board.

* CF/BF - Temporarily disable Gyro EXTI pin to allow NEO target to build.
2018-03-04 11:29:31 +13:00
Bruce Luckcuck a32b05c284 Initial implementation of Runaway Takeoff Prevention (anti-taz)
Detects runaway pidSum values on takeoff and auto-disarms to prevent the "Tasmanian Devil" caused by incorrect props, wrong motor order/direction, incorrect flight controller orientation, etc.  After a successful takeoff and normal flight is detected the feature is disabled for the remainder of the battery.
2018-01-31 07:36:16 -05:00
Michael Keller 4258651b3a
Merge pull request #4881 from jflyper/bfdev-adc-internal-full-task-version
VREFINT and core temperature support, full task polling version
2018-01-10 16:12:05 +13:00
jflyper a03b85025c Internal ADC support, full task polling version 2018-01-10 11:49:56 +09:00
Steffen Windoffer e0b95fb0fb remove unused debug modes 2018-01-07 21:38:18 +01:00
jflyper a510091bf1 Add Benewake TFmini/TF02 support 2017-12-21 02:21:36 +09:00
jflyper 11c47c631b Port iNav's rangefinder 2017-12-20 12:54:19 +09:00
mikeller d3a6b3730f Added FrSky X SPI RX protocol.
Original implementation from midelic.

Added RX number support.

Fixed (almost) SmartPort over SPI.

Fixed indentation.

Somewhat working telemetry.

Fixed SmartPort.

Work on SmartPort.

Work on SmartPort.

Working version without RX ringbuffer.

Na, stuff it, ringbuffer is better.

Fixed build.

Make sure we don't lose packets.

Made MSP over SmartPort over SPI work.

Moved processing of incoming telemetry into 'handleTelemetry'.

Improved telemetry buffering.

Make sure telemetry polling is happening.

Some cleanups.

Make telemetry wait if MSP is pemding.

Made MSP over SmartPort work.

Fixes after rebase.

Combined FrSky D and FrSky X.

Combined FrSky D and FrSky X.

Merged D and X.
2017-11-29 03:12:02 +13:00
mikeller 3873463fcf Added support for the FrSky FPort protocol. 2017-11-07 22:25:02 +13:00
jflyper 47b9bc878b Convert debug statements into debug modes 2017-09-24 19:36:35 +09:00
Martin Budden ee1e008a80 Added gyro raw output debug mode 2017-08-28 08:21:55 +01:00
Martin Budden ef00cc45cf Changed DEBUG_NOTCH to record unfiltered gyro output (#3965) 2017-08-27 07:45:22 +01:00
mikeller a4ba8b3db8 Cleanup of the FrSky SPI RX code. 2017-08-20 23:36:07 +12:00
Dan Nixon cfb23ad0ac Add debug mode to CMS menu 2017-07-16 11:14:37 +01:00
rav d9909b91d3 enable frequency analysis and automatic, dynamic changing of notch filter frequencies
change F3 from CM1 to CM4
add debug flags for FFT
add bandpass filter
add different filtering apply function
add feature DYNAMIC_FILTER
replace mode GTUNE with DYNAMIC FILTER
move gyro frequency analysis into gyro loop instead of own task
2017-05-11 16:10:29 +02:00
mikeller 6a03b48e7f Reworked altitude estimation. Made it work when ACC is disabled. 2017-04-08 22:54:44 +12:00
Bas Delfos 8dbb156ea0 Added KISS ESC sensor information for rpm and temperature to debug fields 2017-03-28 23:11:23 +02:00
Bas Delfos b53cbbefc3 Moved ESC telemetry to sensors 2016-12-08 21:19:23 +01:00
Martin Budden 2b3cc549e9 Enabled CCM RAM for stack. Added stack watermarking 2016-12-01 09:46:47 +00:00
Martin Budden 4fe68ce093 Improved scheduler and task timing instrumentation 2016-11-27 07:08:24 +00:00
Bas Delfos 16178a0662 Implementation of KISS ESC Telemetry protocol 2016-11-17 22:04:44 +01:00
Martin Budden af5c1e3902 Added ARRAYEND and DEBUG_SET utilities 2016-10-13 14:37:43 +01:00
borisbstyle 24b4036968 Redefine rate implementation // new power expo // remove super expo feature 2016-08-27 10:35:55 +12:00
Martin Budden 541f4d4018 Directory rearrangement to reflect cleanflight changes 2016-08-07 13:44:00 +01:00