mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-1216 modified alarms for manualcontrol/receiver to reflect new architecture
This commit is contained in:
parent
564a991222
commit
12eed41e58
@ -122,7 +122,7 @@ void altitudeHandler(bool newinit)
|
||||
#else /* if defined(REVOLUTION) */
|
||||
void altitudeHandler(__attribute__((unused)) bool newinit)
|
||||
{
|
||||
PIOS_Assert(0); // should not be called
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL); // should not be called
|
||||
}
|
||||
#endif // REVOLUTION
|
||||
|
||||
|
@ -64,16 +64,16 @@ static bool forcedDisArm(void);
|
||||
*/
|
||||
void armHandler(bool newinit)
|
||||
{
|
||||
static portTickType lastSysTime;
|
||||
static ArmState_t armState;
|
||||
|
||||
if (newinit) {
|
||||
AccessoryDesiredInitialize();
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
setArmedIfChanged(FLIGHTSTATUS_ARMED_DISARMED);
|
||||
armState = ARM_STATE_DISARMED;
|
||||
armState = ARM_STATE_DISARMED;
|
||||
}
|
||||
|
||||
portTickType sysTime = xTaskGetTickCount();
|
||||
|
||||
FlightModeSettingsData settings;
|
||||
FlightModeSettingsGet(&settings);
|
||||
ManualControlCommandData cmd;
|
||||
@ -190,7 +190,7 @@ void armHandler(bool newinit)
|
||||
|
||||
// only allow arming if it's OK too
|
||||
if (manualArm && okToArm()) {
|
||||
armedDisarmStart = lastSysTime;
|
||||
armedDisarmStart = sysTime;
|
||||
armState = ARM_STATE_ARMING_MANUAL;
|
||||
}
|
||||
break;
|
||||
@ -198,7 +198,7 @@ void armHandler(bool newinit)
|
||||
case ARM_STATE_ARMING_MANUAL:
|
||||
setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMING);
|
||||
|
||||
if (manualArm && (timeDifferenceMs(armedDisarmStart, lastSysTime) > settings.ArmingSequenceTime)) {
|
||||
if (manualArm && (timeDifferenceMs(armedDisarmStart, sysTime) > settings.ArmingSequenceTime)) {
|
||||
armState = ARM_STATE_ARMED;
|
||||
} else if (!manualArm) {
|
||||
armState = ARM_STATE_DISARMED;
|
||||
@ -208,27 +208,27 @@ void armHandler(bool newinit)
|
||||
case ARM_STATE_ARMED:
|
||||
// When we get here, the throttle is low,
|
||||
// we go immediately to disarming due to timeout, also when the disarming mechanism is not enabled
|
||||
armedDisarmStart = lastSysTime;
|
||||
armedDisarmStart = sysTime;
|
||||
armState = ARM_STATE_DISARMING_TIMEOUT;
|
||||
setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMED);
|
||||
break;
|
||||
|
||||
case ARM_STATE_DISARMING_TIMEOUT:
|
||||
// We get here when armed while throttle low, even when the arming timeout is not enabled
|
||||
if ((settings.ArmedTimeout != 0) && (timeDifferenceMs(armedDisarmStart, lastSysTime) > settings.ArmedTimeout)) {
|
||||
if ((settings.ArmedTimeout != 0) && (timeDifferenceMs(armedDisarmStart, sysTime) > settings.ArmedTimeout)) {
|
||||
armState = ARM_STATE_DISARMED;
|
||||
}
|
||||
|
||||
// Switch to disarming due to manual control when needed
|
||||
if (manualDisarm) {
|
||||
armedDisarmStart = lastSysTime;
|
||||
armedDisarmStart = sysTime;
|
||||
armState = ARM_STATE_DISARMING_MANUAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case ARM_STATE_DISARMING_MANUAL:
|
||||
// arming switch disarms immediately,
|
||||
if (manualDisarm && (armSwitch || (timeDifferenceMs(armedDisarmStart, lastSysTime) > settings.DisarmingSequenceTime))) {
|
||||
if (manualDisarm && (armSwitch || (timeDifferenceMs(armedDisarmStart, sysTime) > settings.DisarmingSequenceTime))) {
|
||||
armState = ARM_STATE_DISARMED;
|
||||
} else if (!manualDisarm) {
|
||||
armState = ARM_STATE_ARMED;
|
||||
|
@ -83,6 +83,14 @@ static controlHandler handler_ALTITUDE = {
|
||||
},
|
||||
.handler = &altitudeHandler,
|
||||
};
|
||||
static controlHandler handler_AUTOTUNE = {
|
||||
.controlChain = {
|
||||
.Stabilization = false,
|
||||
.PathFollower = false,
|
||||
.PathPlanner = false,
|
||||
},
|
||||
.handler = NULL,
|
||||
};
|
||||
|
||||
static controlHandler handler_PATHFOLLOWER = {
|
||||
.controlChain = {
|
||||
@ -127,6 +135,8 @@ int32_t ManualControlStart()
|
||||
ManualControlSettingsConnectCallback(configurationUpdatedCb);
|
||||
ManualControlCommandConnectCallback(commandUpdatedCb);
|
||||
|
||||
// clear alarms
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_MANUALCONTROL);
|
||||
|
||||
// Make sure unarmed on power up
|
||||
armHandler(true);
|
||||
@ -207,19 +217,19 @@ static void manualControlTask(void)
|
||||
handler = &handler_ALTITUDE;
|
||||
break;
|
||||
case FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE:
|
||||
handler = NULL;
|
||||
handler = &handler_AUTOTUNE;
|
||||
break;
|
||||
// There is no default, so if a flightmode is forgotten the compiler can throw a warning!
|
||||
}
|
||||
|
||||
if (handler) {
|
||||
bool newinit = false;
|
||||
if (flightStatus.FlightMode != newMode) {
|
||||
flightStatus.ControlChain = handler->controlChain;
|
||||
flightStatus.FlightMode = newMode;
|
||||
FlightStatusSet(&flightStatus);
|
||||
newinit = true;
|
||||
}
|
||||
bool newinit = false;
|
||||
if (flightStatus.FlightMode != newMode) {
|
||||
flightStatus.ControlChain = handler->controlChain;
|
||||
flightStatus.FlightMode = newMode;
|
||||
FlightStatusSet(&flightStatus);
|
||||
newinit = true;
|
||||
}
|
||||
if (handler->handler) {
|
||||
handler->handler(newinit);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void pathFollowerHandler(bool newinit)
|
||||
#else /* if defined(REVOLUTION) */
|
||||
void pathFollowerHandler(__attribute__((unused)) bool newinit)
|
||||
{
|
||||
PIOS_Assert(0); // should not be called
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL); // should not be called
|
||||
}
|
||||
#endif // REVOLUTION
|
||||
|
||||
|
@ -80,6 +80,7 @@ void stabilizedHandler(bool newinit)
|
||||
break;
|
||||
default:
|
||||
// Major error, this should not occur because only enter this block when one of these is true
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
stab_settings = cast_struct_to_array(settings.Stabilization1Settings, settings.Stabilization1Settings.Roll);
|
||||
return;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
&& (settings.ChannelGroups.FlightMode >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE
|
||||
|| cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_INVALID
|
||||
|| cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_NODRIVER))) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
|
||||
ManualControlCommandSet(&cmd);
|
||||
|
||||
@ -324,32 +324,32 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
if (settings.FailsafeFlightModeSwitchPosition >= 0 && settings.FailsafeFlightModeSwitchPosition < settings.FlightModeNumber) {
|
||||
cmd.FlightModeSwitchPosition = (uint8_t)settings.FailsafeFlightModeSwitchPosition;
|
||||
}
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
|
||||
AccessoryDesiredData accessory;
|
||||
// Set Accessory 0
|
||||
if (settings.ChannelGroups.Accessory0 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
|
||||
accessory.AccessoryVal = settings.FailsafeChannel.Accessory0;
|
||||
if (AccessoryDesiredInstSet(0, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
// Set Accessory 1
|
||||
if (settings.ChannelGroups.Accessory1 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
|
||||
accessory.AccessoryVal = settings.FailsafeChannel.Accessory1;
|
||||
if (AccessoryDesiredInstSet(1, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
// Set Accessory 2
|
||||
if (settings.ChannelGroups.Accessory2 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
|
||||
accessory.AccessoryVal = settings.FailsafeChannel.Accessory2;
|
||||
if (AccessoryDesiredInstSet(2, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
} else if (valid_input_detected) {
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_MANUALCONTROL);
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_RECEIVER);
|
||||
|
||||
// Scale channels to -1 -> +1 range
|
||||
cmd.Roll = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL];
|
||||
@ -411,7 +411,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY0, &settings, dT);
|
||||
#endif
|
||||
if (AccessoryDesiredInstSet(0, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
// Set Accessory 1
|
||||
@ -421,7 +421,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY1, &settings, dT);
|
||||
#endif
|
||||
if (AccessoryDesiredInstSet(1, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
// Set Accessory 2
|
||||
@ -432,7 +432,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
||||
#endif
|
||||
|
||||
if (AccessoryDesiredInstSet(2, &accessory) != 0) {
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING);
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -701,7 +701,7 @@
|
||||
<rect
|
||||
inkscape:label="#rect4000-8-0-9"
|
||||
style="fill:#332d2d;fill-opacity:1;stroke:#ffffff;stroke-width:0.53149605;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
|
||||
id="ManualControl"
|
||||
id="Receiver"
|
||||
width="13.893178"
|
||||
height="56.637238"
|
||||
x="576.71594"
|
||||
@ -1135,7 +1135,7 @@
|
||||
</g>
|
||||
<g
|
||||
style="display:none"
|
||||
inkscape:label="ManualControl-OK"
|
||||
inkscape:label="Receiver-OK"
|
||||
id="layer36"
|
||||
inkscape:groupmode="layer">
|
||||
<rect
|
||||
@ -1143,14 +1143,14 @@
|
||||
x="576.71594"
|
||||
height="56.637238"
|
||||
width="13.893178"
|
||||
id="ManualControl-OK"
|
||||
id="Receiver-OK"
|
||||
style="fill:#04b629;fill-opacity:1;stroke:#ffffff;stroke-width:0.53149605;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
|
||||
inkscape:label="#rect4000-8-0-9"
|
||||
transform="translate(-497.66563,-344.28037)" />
|
||||
</g>
|
||||
<g
|
||||
style="display:none"
|
||||
inkscape:label="ManualControl-Warning"
|
||||
inkscape:label="Receiver-Warning"
|
||||
id="layer33"
|
||||
inkscape:groupmode="layer">
|
||||
<rect
|
||||
@ -1158,19 +1158,19 @@
|
||||
x="576.71594"
|
||||
height="56.637238"
|
||||
width="13.893178"
|
||||
id="ManualControl-Warning"
|
||||
id="Receiver-Warning"
|
||||
style="fill:#f1b907;fill-opacity:1;stroke:#ffffff;stroke-width:0.53149605;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
|
||||
inkscape:label="#rect4000-8-0-9"
|
||||
transform="translate(-497.66563,-344.28037)" />
|
||||
</g>
|
||||
<g
|
||||
style="display:none"
|
||||
inkscape:label="ManualControl-Error"
|
||||
inkscape:label="Receiver-Error"
|
||||
id="layer34"
|
||||
inkscape:groupmode="layer">
|
||||
<g
|
||||
transform="translate(78,0)"
|
||||
id="ManualControl-Error"
|
||||
id="Receiver-Error"
|
||||
style="stroke:#cf0e0e;stroke-opacity:1;display:inline"
|
||||
inkscape:label="#g3878">
|
||||
<path
|
||||
@ -1185,14 +1185,14 @@
|
||||
</g>
|
||||
<g
|
||||
style="display:none"
|
||||
inkscape:label="ManualControl-Critical"
|
||||
inkscape:label="Receiver-Critical"
|
||||
id="layer35"
|
||||
inkscape:groupmode="layer">
|
||||
<rect
|
||||
transform="translate(-497.66563,-344.28037)"
|
||||
inkscape:label="#rect4000-8-0-9"
|
||||
style="fill:#cf0e0e;fill-opacity:1;stroke:#ffffff;stroke-width:0.53149605;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;display:inline"
|
||||
id="ManualControl-Critical"
|
||||
id="Receiver-Critical"
|
||||
width="13.893178"
|
||||
height="56.637238"
|
||||
x="576.71594"
|
||||
|
Before Width: | Height: | Size: 235 KiB After Width: | Height: | Size: 235 KiB |
@ -1,8 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/systemhealth">
|
||||
<file>html/Actuator-Critical.html</file>
|
||||
<file>html/ManualControl-Critical.html</file>
|
||||
<file>html/ManualControl-Warning.html</file>
|
||||
<file>html/Receiver-Critical.html</file>
|
||||
<file>html/Receiver-Warning.html</file>
|
||||
<file>html/CPU-Critical.html</file>
|
||||
<file>html/CPU-Warning.html</file>
|
||||
<file>html/FlightTime-Error.html</file>
|
||||
@ -29,8 +29,8 @@
|
||||
</qresource>
|
||||
<qresource prefix="/systemhealth" lang="fr">
|
||||
<file alias="html/Actuator-Critical.html">html/fr/Actuator-Critical.html</file>
|
||||
<file alias="html/ManualControl-Critical.html">html/fr/ManualControl-Critical.html</file>
|
||||
<file alias="html/ManualControl-Warning.html">html/fr/ManualControl-Warning.html</file>
|
||||
<file alias="html/Receiver-Critical.html">html/fr/Receiver-Critical.html</file>
|
||||
<file alias="html/Receiver-Warning.html">html/fr/Receiver-Warning.html</file>
|
||||
<file alias="html/CPU-Critical.html">html/fr/CPU-Critical.html</file>
|
||||
<file alias="html/CPU-Warning.html">html/fr/CPU-Warning.html</file>
|
||||
<file alias="html/FlightTime-Error.html">html/fr/FlightTime-Error.html</file>
|
||||
|
@ -10,6 +10,7 @@
|
||||
<elementname>CPUOverload</elementname>
|
||||
<elementname>EventSystem</elementname>
|
||||
<elementname>Telemetry</elementname>
|
||||
<elementname>Receiver</elementname>
|
||||
<elementname>ManualControl</elementname>
|
||||
<elementname>Actuator</elementname>
|
||||
<elementname>Attitude</elementname>
|
||||
|
Loading…
x
Reference in New Issue
Block a user