1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

warn if posHold mode requested but throttle not above airmode activation point

This commit is contained in:
ctzsnooze 2024-10-29 08:49:00 +11:00
parent a700bff52a
commit 0f1e7bae2c
3 changed files with 8 additions and 6 deletions

View file

@ -1064,11 +1064,8 @@ void processRxModes(timeUs_t currentTimeUs)
// and we have Acc for self-levelling
&& sensors(SENSOR_ACC)
// Need Mag unless a BRAVE user tries it without
&& (sensors(SENSOR_MAG) || allowPosHoldWithoutMag())
// and we have altitude data
&& isAltitudeAvailable()
// prevent activation until after takeoff
&& wasThrottleRaised()) {
&& (sensors(SENSOR_MAG) || allowPosHoldWithoutMag()))
{
if (!FLIGHT_MODE(POS_HOLD_MODE)) {
ENABLE_FLIGHT_MODE(POS_HOLD_MODE);
// this is just a 'request to initiate' the function

View file

@ -24,6 +24,7 @@
#include "build/debug.h"
#include "common/filter.h"
#include "common/maths.h"
#include "fc/core.h"
#include "fc/rc.h"
#include "fc/runtime_config.h"
@ -218,6 +219,10 @@ bool positionControl(void) {
) {
return false;
}
if (!wasThrottleRaised()) {
return false;
}
if (isNewDataForPosHold()) {
posHold.gpsDataIntervalS = getGpsDataIntervalSeconds(); // interval for current GPS data value 0.01s to 1.0s

View file

@ -581,7 +581,7 @@ STATIC_UNIT_TESTED FAST_CODE_NOINLINE float pidLevel(int axis, const pidProfile_
// earthRef code here takes about 76 cycles, if conditional on angleEarthRef it takes about 100. sin_approx costs most of those cycles.
float sinAngle = sin_approx(DEGREES_TO_RADIANS(pidRuntime.angleTarget[axis == FD_ROLL ? FD_PITCH : FD_ROLL]));
sinAngle *= (axis == FD_ROLL) ? -1.0f : 1.0f; // must be negative for Roll
const float earthRefGain = FLIGHT_MODE(GPS_RESCUE_MODE | ALT_HOLD_MODE | POS_HOLD_MODE) ? 1.0f : pidRuntime.angleEarthRef;
const float earthRefGain = FLIGHT_MODE(GPS_RESCUE_MODE | ALT_HOLD_MODE ) ? 1.0f : pidRuntime.angleEarthRef;
angleRate += pidRuntime.angleYawSetpoint * sinAngle * earthRefGain;
pidRuntime.angleTarget[axis] = angleTarget; // set target for alternate axis to current axis, for use in preceding calculation