Commit Graph

47 Commits

Author SHA1 Message Date
ProDrone f0681de53d Updates and feature additions to failsafe system.
- Added failsafe flightmode and rc control box.

To make failsafe procedure a separate flight mode and make it possible
to trigger failsafe with an AUX switch.

- Failsafe mode is activated when failsafe is active.

RC link lost is simulated with the failsafe AUX switch.
When NOT armed: failsafe switch to failsafe mode is shown in GUI (mode
tab).

- Activate failsafe mode with AUX switch.

- Prevent arming when failsafe via AUX switch is active (safety issue).

- Make failsafe disarm if motors armed and throttle was LOW (2D & 3D)
for `failsafe_throttle_low_delay` time (__JustDisarmEvent__).

Applied code changes to effectively add pull request: Make failsafe
disarm if motors armed and throttle low #717.

- Use failsafeIsMonitoring() to actually start monitoring.

- Added `failsafe_kill_switch` to code.

When set to 1 (0 is default), the failsafe switch will instantly disarm
(__KillswitchEvent__) instead of executing the landings procedure.
Arming is NOT locked after
this, so the craft could be re-armed if needed.
This is intended for racing quads where damage and danger must be
minimized in case of a pilot error.

- Added `failsafe_throttle_low_delay`, adapted documentation.

Used to adjust the time throttle level must have been LOW
to _only disarm_ instead of _full failsafe procedure_
(__JustDisarmEvent__).

- Updated the failsafe documentation.

- Re-enable arming at end of failsafe procedure.

At the end of a handled failsafe event, that means: auto-landing,
__JustDisarmEvent__ or __KillswitchEvent__, the RX link is monitored for
valid data.
Monitoring is a part of the failsafe handling, which means the craft is
still in failsafe mode while this is done.
Arming is re-enabled (allowed) when there is a valid RX link for more
then XX seconds, where XX depends on the handled event like this:
1. XX = 30 seconds after auto landing.
2. XX = 3 seconds after __JustDisarmEvent__.
3. XX = 0 seconds after __KillswitchEvent__.

NOTE: When armed via an AUX switch, you will have to switch to the
disarmed position at the very end to be able to re-arm.
The failsafe mode will not end until you do.

- __KillswitchEvent__ has now priority over __JustDisarmEvent__

- Apply rxfail values instantly when failsafe switch is ON

- Added missing cases to display.c

Show M when failsafe is monitoring for RX recovery (AND disarming when
armed with a switch).

===

Reworked the code from counter-based to time-based.

- AUX failsafe switch now has identical behavior to RX loss.

- Added RX failure and RX recovery timing.

- __KillswitchEvent__ skips RX failure detection delay (direct disarm).

===

[UNIT TESTS]

Adapted failsafe related unittests from counter-based to time-based

- Added failsafeOnValidDataFailed() to some tests

- Removed duplicate test setup from rc_controls_unittest.cc

- Removed magic numbers from rx_ranges_unittest.cc and rx_rx_unittest.cc

- Reworked all test-cases for flight_failsafe_unittest.cc
2015-09-04 16:55:40 +02:00
Alexander Fedorov 01632998a3 Blackbox: Enable logging when mode switch is active 2015-07-22 13:36:22 +12:00
Dominic Clifton ea6a6ccb3d First cut of custom servo mixers.
Main rule logic and MSP commands ported from baseflight.

Gimbal mixer updated to use rules.  This allows us to remove more
conditional logic.  Operation of gimbal servos is now different.
2015-06-28 23:06:56 +01:00
Dominic Clifton 6f3c16fe6c Reducing the maximum number of mode ranges from 40 to 20 to free up some
configuration storage space.
2015-05-30 00:03:56 +01:00
Dominic Clifton c174a52ebe Allow independent pitch and roll in-flight PID adjustment. Fixes #149. 2015-05-17 23:43:55 +01:00
borisbstyle da8bb6f6fc Yaw Expo Feature 2015-05-06 22:23:40 +01:00
Nicholas Sherlock 5edfdde942 Restore previous rate limit for yaw of 2.55
Since some people are indeed using yaw > 1.0.
2015-03-26 02:02:32 +13:00
Nicholas Sherlock 828ec550cd Apply the same maximum control rates (1.0) in CLI and MSP
Previously it was possible to set roll/pitch rate > 1.0 using MSP, but
not using the CLI. Roll/pitch rate > 1.0 is meaningless.

TPA is also limited to 1.0.
2015-03-22 20:38:15 +13:00
Dominic Clifton 5e3734946e # This is a combination of 2 commits.
# The first commit's message is:

Previously, at minimum throttle, the quad would do absolutely no self-leveling
and simply run the motors at constant minthrottle.  This allowed the chance
for the quad to lose control during flight if the throttle was set to minimum,
say, to drop from a high altitude to a lower one.

With this edit, the quad will still self-level at minimum throttle when armed,
allowing for safe decents from altitude.  To prevent motors spinning when
arming/disarming, the yaw input is ignored if the throttle is at minimum and
we're using the sticks to arm/disarm.

Conflicts:
	src/main/flight/mixer.c

# This is the 2nd commit message:

added cli command disable_pid_at_min_throttle
2015-03-09 23:36:54 +01:00
Dominic Clifton e4a6886266 Allow independent in-flight adjustment of roll and pitch. 2015-03-07 15:14:52 +00:00
Dominic Clifton b595b49ca8 Decouple roll and pitch rates. MSP clients take note of updated
MSP_RC_TUNING/MSP_SET_RC_TUNING commands.
2015-03-07 15:11:20 +00:00
Dominic Clifton 55d9994ff8 Reset adjustment states when switching profiles.
Fixes #544.
2015-02-26 13:58:03 +00:00
Dominic Clifton f77a762b48 Allow inflight adjustments for floating-point based PID controllers. 2015-01-30 20:54:34 +01:00
Krzysztof Rosinski 34cd8f466e MSP command for sonar altitude 2015-01-29 15:17:15 +01:00
Dominic Clifton b64c71264c Renaming getRcStickPosition to getRcStickDeflection and moving to
rc_controls.c.
2015-01-16 01:00:40 +00:00
Dominic Clifton 347b156727 Avoid calling mwDisarm() when due to having auto_disarm_delay when using
switch to arm().
2014-12-26 20:22:13 +00:00
Dominic Clifton 503e7a0817 Decouple altitudehold.c from config.c. Update flight_imu_unittest and
altitude_hold_unittest.
2014-11-03 20:03:21 +01:00
Dominic Clifton 28f9fa629c Add rate profiles and inflight switching between them. See Profiles and
Inflight Adjustment documentation for details.
2014-10-29 23:36:34 +00:00
Dominic Clifton cac814923c Update RC Controls so that functions with different modes can be
applied.  The existing modes are 'step'.  A new mode is 'select'.

The other unit tests need fixing up so that appropriate code is compiled
as C and not C++ code.
2014-10-29 20:52:44 +00:00
Dominic Clifton 2df976409d Allow inflight adjustment of pitch/roll (linked) and yaw PID settings. 2014-10-24 23:10:17 +01:00
Dominic Clifton 4a90599e3a Allow inflight adjustment of throttle expo. 2014-10-24 22:16:49 +01:00
Dominic Clifton f166ca3516 Allow inflight adjustment of yaw rate. 2014-10-24 22:01:31 +01:00
Dominic Clifton 9ddbb4ed9d Allow inflight adjustment of rc_expo. 2014-10-24 21:58:30 +01:00
Dominic Clifton 81e3425326 Allow inflight adjustment of pitch/roll rate. 2014-10-24 21:52:12 +01:00
Dominic Clifton 066c814a8a Update `adjrange` command to take an 'adjustment index/slot'. Apply
adjustment ranges to adjustment slots when channel is within range.

example:

```
adjrange 0 0 0 900 1700 0 2
adjrange 1 0 0 1700 2100 1 2
```

explained:

* configure adjrange 0 to use adjustment slot 1 (0) so that when aux1
(0) in the range 900-1700 then do nothing when aux 3 (2) is in any
position.
* configure adjrange 1 to use adjustment slot 1 (0) so that when aux1
(0) in the range 1700-2100 then do use adjustment 1 (rc rate) when aux 3
(2) is in the appropriate position.

Without the entire range of aux1 being defined there is nothing that
would stop aux 3 adjusting the rc rate once aux 1 wasn't in the higher
range. 

There are 4 adjustment slots and 12 adjustment ranges.

Adjustment slots and adjustment ranges can use the same aux channel.

e.g.

`adjrange 2 1 0 900 2100 1 3`

* configure adjrange 2 to use adjustment slot 2 (1) so that when aux4
(3) in the range 900-2100 then use adjustment 1 (rc rate) when aux 4 (3)
is in the appropriate position.
2014-10-24 20:49:00 +01:00
Dominic Clifton bd39445be8 Add cli command to configure adjustment ranges.
e.g. `adjrange 0 0 1700 2100 1 2`

set adjustment range 0, which applies to aux channel 0 (aux1) when range
is between 1700 and 2100 then apply function 1 (rc rate) to aux channel
2 (aux3)
2014-10-24 19:51:40 +01:00
Dominic Clifton 18abad5dd7 Extract range definition so it can be reused. 2014-10-24 18:57:06 +01:00
Dominic Clifton a2a9443045 Seperate adjustment configuration from adjustment state. Rename 'step'
parameter to 'delta' applying the adjustment.  Configure adjustment
states based on adjustment configuration for AUX3 and AUX4.
2014-10-24 15:46:07 +01:00
Dominic Clifton 6d7035819f First cut of allowing a 3POS switch on AUX3 to change rc rate.
rcRate is decreased when low, increased when HIGH and no change when the
switch is in the middle.

The rcRate ticks up/down at 0.01 every 500ms if the switch is left on.

If using a momentary switch and if you can toggle the switch between
middle and low or middle and high more frequently than 500ms then the
rate will be increased accordingly.  Similar to how a keyboard repeat
behaves.
2014-10-22 23:10:40 +01:00
Dominic Clifton ca9f183b83 Cleanup some aux range defines and comments. 2014-10-12 21:05:34 +01:00
Dominic Clifton cfcd4792bb Determine with an aux range is used to arm. 2014-10-12 21:02:45 +01:00
Dominic Clifton b0eab0cc9e Update the cli AUX command to take range parameters - see docs/Modes.md 2014-10-12 19:32:55 +01:00
Dominic Clifton b43fa247de Handle channel boundaries better.
More efficient, less code, easier to understand.
2014-10-12 18:31:59 +01:00
Dominic Clifton 2369a63df0 First cut of code that passed the unit tests for mod activations,
however it uses / operations and doesn't handle the case where the
channel value is on the boundary between two ranges.
2014-10-12 18:15:44 +01:00
Dominic Clifton c0fd0c1f33 Replace profile.activate and rcOptions with
profile.modeActivationCondition and rcModeActivationMask.

Implementation of using and setting modeActivationConditions is missing.
2014-10-12 10:40:38 +01:00
Dominic Clifton 3eb8bcb3e5 Merge branch 'feature-sonar-flight-mode-no-baro' of dclifton-github.com:nebbian/cleanflight into nebbian-feature-sonar-flight-mode-no-baro
Fixed tabs, kept old references to VARIO.  Made SONAR mode a new option so that aux settings could be preserved.

Conflicts:
	src/main/config/runtime_config.h
	src/main/flight/altitudehold.h
	src/main/flight/imu.c
	src/main/io/rc_controls.h
	src/main/mw.c
	src/main/sensors/initialisation.c
2014-09-26 13:36:19 +01:00
Dominic Clifton d60183d91d Normalize all the line endings 2014-09-15 23:40:17 +01:00
Dominic Clifton 6ce5736990 Update LED strip code to allow configurable LED strips.
See documentation for details.
2014-09-15 03:15:11 +01:00
Andreas Tacke 275089eca1 Make disarming via AUX switch independent of throttle value configurable
Conflicts:
	src/cli.c
	src/config.c
	src/mw.c
	src/mw.h
2014-09-08 11:02:02 +01:00
Ben Hitchcock 66fce423bb Code allowing the use of sonar without requiring a barometer.
This code has been flight tested on a Naze32 acro, with no barometer onboard.  It also works when the target doesn't have BARO defined.
2014-09-05 11:28:55 +08:00
Dominic Clifton 00a1858faa Cleanup and fix the use of permenant box ids. 2014-08-27 23:59:52 +01:00
Dominic Clifton 1c6ea1d397 Fix ANGLE mode and HORIZON mode resetting the errorAngle when they are
both attempted to be enabled at the same time.  Angle mode now takes
precedence over horizon mode.

Fix using aux settings that are not applicable to in-use aux channels -
prior to this it was possible to configure aux4 and then switch to
RX_SERIAL using a 7 channel system (3 aux channels) and aux4 would still
have been processed.
2014-08-26 21:28:23 +01:00
Dominic Clifton e867af8c4b Correct project name in GPL notices. 2014-06-05 00:47:47 +01:00
Dominic Clifton d718f5b9d6 Support configuring AUX 5 to 8.
The MSP is changed in a way that might provide some backwards
compatibility.  The first 4 channels are sent/read as before followed by
the next 4 channels.

If I client ignores extra data received it should be backwards
compatible.

Clients can looks for the new capability bit which indicates the MSP
protocol supports AUX 1-8.
2014-06-04 19:50:12 +01:00
Dominic Clifton 0bbcd6570f Updated source files to include the GPL v3 notices. Include a copy of
the GPL v3.
2014-06-04 16:48:23 +01:00
Dominic Clifton 18046013a4 Decouple sticks processing code from main mw loops.
Decouple led ring driver from non-driver code.
2014-06-01 18:36:33 +01:00
Dominic Clifton d19a5e7046 Cleanup project structure. Update unit test Makefile to place object
files in obj/test
2014-05-31 22:43:06 +01:00