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

49 commits

Author SHA1 Message Date
pichim
899ce6731d
Chirp signal generator as flight mode (#13105) 2025-01-21 21:22:35 +11:00
ctzsnooze
3138141cd1
Position hold for 4.6 and Altitude Hold updates (#13975)
* autopilot naming, function sharing
* initial position hold setup
* get current gps location
* first position hold draft
* basic control scheme
* add debug values for testing
* first working example with smoothed acceleration
* add deadbands
* Re-organise included files and functions thanks Karate
* revise PID gains
* PIDJ distance controller, not velocity based. Remove airmode check
* sanity check notes
* fix pid bug and improve iTerm handling
* calculate PIDs independently for each axis, increas DJ gains
* adjust pids and smoothing; smoothing cutoff to settings
* force iTerm to zero when close to target
* allow earth referencing in alt and pos hold
* stop activation until throttle raised, but not require airmode
use wasThrottleRaised in place of isAirmodeActivated where airmode isn't really needed
* remove unnecessary debug
* block arming if poshold or althold switches are on
* basic sanity check and OSD warning
* allow user to fly without mag only if they reverse the default
* separate alt and pos hold deadbands
if poshold deadband is zero, sticks are ignored
if user tries to enable posHold and it can't work, they get stick with a deadband
* try to prevent position hold if no mag without valid IMU
fixes a bug in the last commit, also
* retaisn iTerm just attenuate the output
* struct for values
* reset position at start when slowed down, retain rotated iTerm back
* resolve bounceback and remove iTerm attenuation
* adjust PID gains to 30
* force unit tests sto work
* tidy up after merge
* Use mpif
* conditionally only do compass check if Mag is defined
* fixe defines and remove const
* comments to explain strange rc multiplier
* fix small omission when refactoring after throttle raised PR
* licence updates, refactoring from review comments
* fix issues when pos hold deadband is set to zero
* A for acceleration element, not J
* compact the posHoldUpdate() function - thanks K
* rename showPosHoldWarning to posHoldFailure
* Use a function in gps.c to initate the posHold activity on new GPS data
* Use autopilotAngle in place of posHoldAngle
* separate function for gpsHeading truth
* use FLIGHT_MODE(POS_HOLD_MODE) in place of isPosHoldRequested
* removed non-required definitions
* fix failure to initiate position hold from error in ifdef
* refactoring from reviews, rename posHoldReset
* move deadbands for pos and alt hold to their config files.
* comment
* fix for blackbox breakup of GPS values
reverts use a function in gps.c to initate the posHold activity on new GPS data
* fix for msp change for posHoldConfig
* try to constrain aggressiveness at start, smaller deadband
* allow greater overshoot at the start for high incoming speed
rename justStarted to isDeceleratingAtStart
* dynamically update smoothing at the start
* retain iTerm when moving sticks, to keep attitude in the wind
* fix unit tests
* finally retain iTerm correctly while moving sticks, but reset at start
* Fix iTerm reset and parameter rotation
* absolute rotation vs incremental rotation, fix spike after resetting target location
* don't rotate D or A, it reverses their sign inappropriately
* Block yaw, allow in CLI, option to apply yaw correction code
* restore debug
* calc D from groundspeed and drift angle
* add back some target based D
* Earth Frame iTerm vector
appears to work :-)
* fix unit test
* lower PID gains, slowly leak iTerm while sticks move
* earth ref Dterm, not from GPS Speed
smoother than using GPS Speed and heading
* stronger PIDs
* adjust debug
* shoehorn the unit tests
* Proper earth referencing, at last
* clean up a bit
* no need to duplicate wrapping done in sin_approx
* add note about PT1 gain on PT2 filters
* avoid unnecessary float conversions
* Remove unnecessary CLI testing params
* update PID gains, stronger tilt angle correction
* improved distance to target. thanks to demvlad
* Terminate start individually on each axis
added comments
* refactoring to avoid code duplication
* implement reviews, reduce PID gains
* upsampling filter at 5Hz
* warn if posHold mode requested but throttle not above airmode activation point
* disable angle feedforward in position hold
* rebase, pass unit test
* sequential PT1's, refactoring from reviews
* PID and filter revision
* bane of my life
* lenient sanity check, message for noMag, possible DA vector limit code
* replace angleTarget in pid.c only when autopilot is active
* rearrange status checks
* fix debug, tidy up EF axis names, add comments about sign and direction
* stop more cleanly, easier sanity check, phases, debugs complete
* extend sanity check distance while sticks move; refactor; comments
* fix instability on hard stop, allow activation after arming but before takeoff
* make altHoldState_t  local, getter to pass unit tests.
* hopefully the last cleanup of this test file
* implement review from PL - thank you!
* restore angle limiting in pid.c , max of 80 degrees allowed in CLI
* fixes after review changes weren't right
* fix braces
* limit max angle to 50 by vector length
* Fix curly brackets, comments and debug mistake
* in autopilot modes, allow up to 85 deg for pos hold
* limit pilot angle in position hold to half the configured position hold angle
* use smaller of angle_limit or half the autopilot limit
* increase alt_hold sensitivity 5x and narrow deadband to 20
* make altitude control 5x stronger with narrower deadband and new name
* add suggestions from recent reviews
* start autopilot gpsStamp at 0
* renaming variables
* reset the upsampling filters when resetting position control
* improved gpsStamp thanks PL
Also cleanup names and notes
* simplify altitude control
* rename to GPS_distances  to GPS_latLongVectors
* alt_hold respect zero deadband, hold when throttle is zero
* remove unused debug
* fix unit test
* re-name variables in alt_hold and update comments
* more flexible limit on target vs current altitude
* updates from reviews, thanks karate
* review changes from PL
* more updates from PL review
* rationalise GPS_latLongVectors
* remove static newGpsData and rescueThrottle
* Thanks, PL, for your review
* Modifications, but has a big twitch when sticks stop
* Re-naming, fix the twitch, minor changes
* remove unnecessary unit test reference
* sanity dist to 10m at full stop, send task interval for upsampling filter
* vector and parameter re-name
Co-Authored-By: Jan Post <19867640+KarateBrot@users.noreply.github.com>
* small changes from review
Co-Authored-By: Mark Haslinghuis <8344830+haslinghuis@users.noreply.github.com>
Co-Authored-By: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
* comment PL
Co-Authored-By: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
* fix ltm alt_hold flightMode
* NOINLINE some pid.c functions
* Revert "NOINLINE some pid.c functions"
This reverts commit 56a3f7cec2.
* fast_code_pref the wing functions in pid.c
* use fast_code_pref where won't break the build
* apply fast_code_pref correctly
* NOINLINE some pid.c functions
FAST_CODE_PREF for updatePIDAudio
add comment to FAST_CODE_PREF
FIx platform.h unit test issue
Wing functions all FAST_CODE_PREF
* revert FAST_CODE_PREF changes
* Reduce ITCM RAM footprint considerably
* multiple name changes and some refactoring
Thanks, PL
* small editorial change
* refactoring, thanks PL
Co-Authored-By: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
* 64 bytes to check crossing 180 deg longitude
Co-Authored-By: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
* try to fix build error
Co-Authored-By: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
* Revert "try to fix build error"
This reverts commit f926d26021.
* just guessing here
* Revert "just guessing here"
This reverts commit ebc240a325.
* use a null location at initialisation
* Revert "use a null location at initialisation"
This reverts commit b51ae1395d.
* revert more compact initialisation code due to SITL error otherwise
* fix wrapping when 180 lon meridian is crossed
* null location option from PL
* Revert "null location option from PL"
This reverts commit ad40e979bd.
* refactor PosHold start/stop code
* move Alt_Hold and Pos_Hold warnings ahead of Angle, update some comments
* use setTargetLocationByAxis, fix comments
* change from karatebrot review
Co-Authored-By: Jan Post <19867640+KarateBrot@users.noreply.github.com>
* things still to do
Co-Authored-By: Jan Post <19867640+KarateBrot@users.noreply.github.com>
* keep warning strings 12 or less characters
Co-Authored-By: Jan Post <19867640+KarateBrot@users.noreply.github.com>
* a few more
Co-Authored-By: Jan Post <19867640+KarateBrot@users.noreply.github.com>

---------

Co-authored-by: Jan Post <19867640+KarateBrot@users.noreply.github.com>
Co-authored-by: Mark Haslinghuis <8344830+haslinghuis@users.noreply.github.com>
Co-authored-by: Petr Ledvina <2318015+ledvinap@users.noreply.github.com>
Co-authored-by: Jay Blackman <blckmn@users.noreply.github.com>
2024-12-06 13:04:00 +11:00
ctzsnooze
fc52b6b4ff
Use wasThrottleRaised in place of isAirmodeActivated where appropriate (#13968)
* use wasThrottleRaised in place of isAirmodeActivated where airmode isn't really needed

* fix unit test

* fix typo

* remove unnecessary check

* final changes and clarificartions

* Update src/main/flight/mixer.c

Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>

---------

Co-authored-by: Mark Haslinghuis <mark@numloq.nl>
Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>
2024-10-17 10:46:54 +02:00
ctzsnooze
7156dc84a3
Update turtle / crashflip mode (#13905)
* stop motors after 90 degrees of rotation and with max rate

* handle no accelerometer data

* improve check for acc, although seems to be OK without it

* disable all attenuation if rate is set to zero

* refactoring thanks Karate

* use sensors.h

* remove unnecessary arming check

* exit crashFlip immediately switch is reverted if throttle is zero

* add Crashflip Rate to OSD

* Revert unnecessary changes in crashflip core.c code

and clarify comments about crashflip switch

* update / minimise comments, thanks Karate

* ensure all names say `crashflip` consistently

* Undo quick re-arm because motrors were not reversed

* fix issue with reversed motors, we must disarm

* ignore yaw rotation and set gyro limit to 1900 deg/s

* default attenuation to off (crashflip_rate = 0)

* refactoring, increase rate limit to allow stronger inhibition

* enable in race_pro mode

* don't attenuate on attitude until a significant change occurs

* no attenuation for small changes

* Updates from review by PL

* remove whitespace

* refactor motorOutput, update comments, renaming variables

thanks PL

* changes from review PL

* only permit fast re-arm if crashflip rate set and crashflip was successful

* properly exit turtle mode

* add crashFlipSuccessful to unit test extern c

* small updates from review

* improved crashflip switch handling

* remove unnecessary motors normal check
2024-10-05 07:58:33 +10:00
Petr Ledvina
aa92203215
rc-modes bugfix - prevent buffer overflow when serializing box names (#13880) 2024-09-10 18:15:52 +02:00
ctzsnooze
254da8f460
Altitude hold for 4.6 (#13816) 2024-09-04 20:29:03 +10:00
Mark Haslinghuis
5a28ce5129
Make Cppcheck happier revived (#13566)
Co-authored-by: Štěpán Dalecký <daleckystepan@gmail.com>
2024-05-10 13:23:32 +10:00
SpencerGraffunder
aad197f791
Add GPS Lap Timer (#11856)
* Add gps lap timer

* change timing to GPS time instead of local time

* rebase and minor changes

* implement KarateBrot's suggestions

* follow ledvinap's suggestions, some OSD symbol changes

* move platform.h include to the top

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* fix osd elements not showing, remove useless block

* cleanup, move pg stuff to pg folder

* cleanup from review

* minor mods to gps lap timer update, add number of laps tracked

* rename time variable

* add const to timeMs

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

* Update licenses, add is_sys_element macro

* update licenses

* round to nearest centisecond

Co-authored-by: Jan Post <Rm2k-Freak@web.de>

---------

Co-authored-by: Jan Post <Rm2k-Freak@web.de>
2023-05-25 02:31:22 +02:00
Jon Mahoney
d3c824d6b7 Ready Mode
By giving a mode that signals the pilot is ready other than armed props
at a race event it will be easier to determine when all pilots are ready
to race.
2022-10-23 23:00:00 -04:00
Davor Kustec
4b9ac000ec New feature 'Beeper Mute'
Added comma in the last element of struct

Removed BOXBEEPERON from condition
2020-10-06 14:15:57 +02:00
Bruce Luckcuck
19ece68555 Add box mode to disable stick commands
Adds a `STICK COMMAND DISABLE SW` mode used to prevent inadvertant triggering of controls, calibrations, or settings changes. Useful for USB HID mode when using the flight controller as a joystick (and auto-detect doesn't work), in "team" or "relay" racing where multiple quads might be bound to the same transmitter, or just in general if the user wants prevent stick commands.

Will also prevent stick arming when the mode is active (but not stick disarming).
2020-09-15 12:51:19 -04:00
Birk Tjelmeland
aa5066e443 Add MSP override mode
The MSP override mode allows for use of MSP togehter with
another RX feature like SBUS. When enabling the MSP override
mode all channels from the `msp_override_channels` bitmask
will be overwritten by data comming from MSP instead of the
main RX.
2020-07-27 13:01:38 +02:00
mikeller
f3ec114a2a Added custom (switch) box naming. 2020-03-12 07:04:24 +13:00
Dave Huber
6a67972c6c Updated linked mode processing
Allows links and ranges in a single mode.
Code styling changes.
Add config validation for chained links (not allowed).
2019-02-21 14:45:52 -06:00
Bruce Luckcuck
42af168854 Optimize rc modes activation conditions processing
Analyze the rc modes activation conditions and only process configured entries. Previously the entire possible list was processed even though typically only a handful are configured.

Reduces the RX task processing time by about 25% (~44us to ~33us) with an average setup of 3 modes configured (F405, SBUS). Processing time savings will diminish as the user configures more modes. But typically far fewer than the maximum of 20 will be configured.
2019-02-05 16:05:16 -05:00
Michael Keller
c0344496ca
Merge pull request #6992 from etracer65/launch_control
Launch Control
2018-11-02 00:49:42 +13:00
mikeller
7b7ddd099f Remove unused BARO, GPS_HOME, GPS_HOLD modes. 2018-10-29 00:50:44 +13: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
mikeller
817bb2ed86 Rename 'isAirmodeActive()' to 'airmodeIsEnabled()'. 2018-10-23 01:09:17 +13:00
mikeller
2fffaac3df Added 'VTX CONTROL DISABLE' mode. 2018-09-02 16:19:12 +12:00
Michael Keller
625b23915e
Merge pull request #6220 from ctzsnooze/AG_New
Improved anti-gravity
2018-07-22 02:06:31 +12:00
ctzsnooze
4c917efa50 Smooth anti gravity 2018-07-21 23:49:41 +12:00
mikeller
017bdca593 Remove unused modes. 2018-07-19 00:12:11 +12:00
Robert Lacroix
aa18ab4afa Allow linking of modes
This allows modes to be linked, for example to link vtx pit mode to paralyze. Whenever paralyze is activated, vtx pit mode is activated as well. Also the logic to prevent mode changes when enabling paralyze can be removed in favor of making paralyze sticky.

Modes can be linked in CLI by providing the mode id as the last parameter of the aux command. For example in order to link vtx pit mode to paralyze, replace the last 0 of the pit mode aux (39) with the mode id of paralyze (45):

```
aux 2 39 2 1700 2100 0 0
```

becomes

```
aux 2 39 2 1700 2100 0 45
```

_Legal disclaimer: I am making my contributions/submissions to this project solely in my personal capacity and am not conveying any rights to any intellectual property of any third parties._
2018-07-13 13:05:15 +02:00
mikeller
93ab648183 Added disabling of GPS_RESCUE when 3D is enabled. 2018-07-01 21:33:32 +12: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
mikeller
557d704b9e Fixed RC modes PG version after GPS rescue. 2018-05-21 15:07:36 +12:00
s0up
ac6b8088c9 add gps rescue mode 2018-05-20 16:28:17 -07:00
Robert Lacroix
092baf5805 Add Paralyze mode support
During team relay races it's unsafe to retrieve crashed quads because the course is continuously hot. In order to safely fly a backup quad with the primary quad crashed in the field (but powered up) it's necessary to:

* Disable arming, so that the crashed quad doesn't unintentionally arm as well. This is specifically a problem when a transmitter can send signals to all powered up receivers (like FrSky and others).
* Change VTX to an unused channel with low power output
* Turn off telemetry

This change introduces a new mode called paralyze which disables arming and prevents mode changes (except beeper). It can only be invoked while the quad isn't armed. Once it's invoked, the FC has to be power cycled. In order to invoke it, the mode needs to be in a disengaged state at least once, so that forgetting to flip the switch back after crashing doesn't immediately invoke graveyard on the backup quad.

_Legal disclaimer: I am making my contributions/submissions to this project solely in my personal capacity and am not conveying any rights to any intellectual property of any third parties._
2018-05-10 07:40:31 -07: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
92d19e7be6
Merge pull request #3036 from cleanflight/spracingf7dual-pidaudio (#5586)
PID-Audio feature
2018-04-01 11:08:41 +12:00
Michael Keller
b4667332d7
Merge pull request #5208 from jflyper/bfdev-piniobox-cleanup
PINIOBOX Separation of boxId and permanentId.
2018-02-20 01:53:07 +13:00
jflyper
18d5a373c0 Separation of boxId and permanentId. 2018-02-18 21:30:05 +09:00
mikeller
232fc4e8de Unified BOX3DDISABLE and BOX3DONASWITCH switches. 2018-02-13 20:02:02 +13:00
jflyper
6557b161aa Add box to pinio monitor/mapper 2018-02-12 13:54:40 +09:00
Petr Ledvina
5a75737df9 Implement getBoxIdState
packFlightModeFlags is simplified by using it. Base for #5111
2018-02-05 13:10:52 +01:00
jflyper
11c47c631b Port iNav's rangefinder 2017-12-20 12:54:19 +09:00
mikeller
b489d0ba9d Renamed 'parameter_group' to 'pg'. 2017-12-19 23:36:31 +13:00
Dave Huber
b9272ae325 Added Logic AND to Modes
Added Mode Inversion configuration, CLI commands, and update.
Changed Mode Inversion to Mode Logic.
configure by AND/OR instead of output inversion.
Fixed Mode Logic code after debugging.
Added PG_REGISTER to cli unittest.
Revert version to previous.
Revamped Mode Logic using existing Conditions config.
Requires coordination with BF-configurator, but works with CLI (added argument in 'aux' command).
Coding standard changes.
Cleaned up code. Added modeLogic enum.
removed executable permissions.
Code cleanup, cliAux backward compatible.
changed bitArrayInv to bitArrayXor.
allow for old 'aux' command (without last argument) to be made. asserts MODELOGIC_OR instead of resetting the memory.
2017-12-12 10:35:15 -06:00
Curtis Bangert
b13e73c9bb Pit mode on a switch 2017-11-26 23:17:21 -05:00
Bryce Johnson
d1a197f99e 3d on a mode switch 2017-10-11 13:08:12 -05:00
mikeller
98d85969ce Added distinct mode for 'beep GPS number of satellites found', and separated this functionality from 'RX_SET' beeping. 2017-10-04 08:43:03 +13:00
Bryce Johnson
fd37566bc5 New turtle mode that only spins needed props 2017-09-07 07:59:59 -05:00
Bryce Johnson
f8bd089e47 Add in prearm option for safer arming.
When prearm is used, it must be enabled before arming.  Before you can arm again, the prearm switch needs to get toggled. (+3 squashed commit)
2017-07-30 17:08:46 -05:00
Martin Budden
6943fb8e56 Split MSP box code into separate module 2017-07-20 13:33:34 +01:00
mikeller
282668edde Added BOXDSHOTREVERSE as a separate mode to BOX3DDISABLE. 2017-07-08 12:32:23 +12:00
Dominic Clifton
32fa109a64 Merge pull request #2852 from azolyoung/add-runcam-split-support
Add runcam split support
2017-06-23 08:48:07 +12:00
Dominic Clifton
db006b1585 Merge pull request #2856 from ledvinap/improvement-64bit-boxid
array based box masks
2017-06-19 13:31:08 +12:00