mirror of
https://github.com/okalachev/flix.git
synced 2026-08-15 16:29:00 +00:00
Add tilt disarm failsafe
This commit is contained in:
+2
-1
@@ -10,7 +10,7 @@ extern int channelZero[16], channelMax[16];
|
|||||||
extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel;
|
extern int rollChannel, pitchChannel, throttleChannel, yawChannel, armedChannel, modeChannel;
|
||||||
extern int rcRxPin, voltagePin;
|
extern int rcRxPin, voltagePin;
|
||||||
extern int wifiMode, wifiLongRange, udpLocalPort, udpRemotePort, espnowChannel;
|
extern int wifiMode, wifiLongRange, udpLocalPort, udpRemotePort, espnowChannel;
|
||||||
extern float rcLossTimeout, descendTime;
|
extern float rcLossTimeout, descendTime, disarmTilt;
|
||||||
extern float voltageScale;
|
extern float voltageScale;
|
||||||
extern LowPassFilter<float> voltageFilter;
|
extern LowPassFilter<float> voltageFilter;
|
||||||
|
|
||||||
@@ -128,6 +128,7 @@ Parameter parameters[] = {
|
|||||||
// safety
|
// safety
|
||||||
{"SF_RC_LOSS_TIME", &rcLossTimeout},
|
{"SF_RC_LOSS_TIME", &rcLossTimeout},
|
||||||
{"SF_DESCEND_TIME", &descendTime},
|
{"SF_DESCEND_TIME", &descendTime},
|
||||||
|
{"SF_DISARM_TILT", &disarmTilt},
|
||||||
};
|
};
|
||||||
|
|
||||||
void setupParameters() {
|
void setupParameters() {
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ extern float controlRoll, controlPitch, controlThrottle, controlYaw;
|
|||||||
|
|
||||||
float rcLossTimeout = 1;
|
float rcLossTimeout = 1;
|
||||||
float descendTime = 10;
|
float descendTime = 10;
|
||||||
|
float disarmTilt = radians(120);
|
||||||
|
|
||||||
void failsafe() {
|
void failsafe() {
|
||||||
rcLossFailsafe();
|
rcLossFailsafe();
|
||||||
autoFailsafe();
|
autoFailsafe();
|
||||||
|
tiltFailsafe();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RC loss failsafe
|
// RC loss failsafe
|
||||||
@@ -45,3 +47,15 @@ void autoFailsafe() {
|
|||||||
yaw = controlYaw;
|
yaw = controlYaw;
|
||||||
throttle = controlThrottle;
|
throttle = controlThrottle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disarm if tilted too much
|
||||||
|
void tiltFailsafe() {
|
||||||
|
if (!armed) return;
|
||||||
|
if (mode != STAB) return;
|
||||||
|
|
||||||
|
Vector up = Quaternion::rotateVector(Vector(0, 0, 1), attitude);
|
||||||
|
float tilt = acos(up.z);
|
||||||
|
if (disarmTilt && tilt > disarmTilt) {
|
||||||
|
armed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ void failsafe();
|
|||||||
void rcLossFailsafe();
|
void rcLossFailsafe();
|
||||||
void descend();
|
void descend();
|
||||||
void autoFailsafe();
|
void autoFailsafe();
|
||||||
|
void tiltFailsafe();
|
||||||
int parametersCount();
|
int parametersCount();
|
||||||
const char *getParameterName(int index);
|
const char *getParameterName(int index);
|
||||||
float getParameter(int index);
|
float getParameter(int index);
|
||||||
|
|||||||
Reference in New Issue
Block a user