1
0
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:
Corvus Corax 2014-03-02 20:06:05 +01:00
parent 564a991222
commit 12eed41e58
13 changed files with 54 additions and 42 deletions

View File

@ -122,7 +122,7 @@ void altitudeHandler(bool newinit)
#else /* if defined(REVOLUTION) */ #else /* if defined(REVOLUTION) */
void altitudeHandler(__attribute__((unused)) bool newinit) 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 #endif // REVOLUTION

View File

@ -64,16 +64,16 @@ static bool forcedDisArm(void);
*/ */
void armHandler(bool newinit) void armHandler(bool newinit)
{ {
static portTickType lastSysTime;
static ArmState_t armState; static ArmState_t armState;
if (newinit) { if (newinit) {
AccessoryDesiredInitialize(); AccessoryDesiredInitialize();
lastSysTime = xTaskGetTickCount();
setArmedIfChanged(FLIGHTSTATUS_ARMED_DISARMED); setArmedIfChanged(FLIGHTSTATUS_ARMED_DISARMED);
armState = ARM_STATE_DISARMED; armState = ARM_STATE_DISARMED;
} }
portTickType sysTime = xTaskGetTickCount();
FlightModeSettingsData settings; FlightModeSettingsData settings;
FlightModeSettingsGet(&settings); FlightModeSettingsGet(&settings);
ManualControlCommandData cmd; ManualControlCommandData cmd;
@ -190,7 +190,7 @@ void armHandler(bool newinit)
// only allow arming if it's OK too // only allow arming if it's OK too
if (manualArm && okToArm()) { if (manualArm && okToArm()) {
armedDisarmStart = lastSysTime; armedDisarmStart = sysTime;
armState = ARM_STATE_ARMING_MANUAL; armState = ARM_STATE_ARMING_MANUAL;
} }
break; break;
@ -198,7 +198,7 @@ void armHandler(bool newinit)
case ARM_STATE_ARMING_MANUAL: case ARM_STATE_ARMING_MANUAL:
setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMING); setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMING);
if (manualArm && (timeDifferenceMs(armedDisarmStart, lastSysTime) > settings.ArmingSequenceTime)) { if (manualArm && (timeDifferenceMs(armedDisarmStart, sysTime) > settings.ArmingSequenceTime)) {
armState = ARM_STATE_ARMED; armState = ARM_STATE_ARMED;
} else if (!manualArm) { } else if (!manualArm) {
armState = ARM_STATE_DISARMED; armState = ARM_STATE_DISARMED;
@ -208,27 +208,27 @@ void armHandler(bool newinit)
case ARM_STATE_ARMED: case ARM_STATE_ARMED:
// When we get here, the throttle is low, // When we get here, the throttle is low,
// we go immediately to disarming due to timeout, also when the disarming mechanism is not enabled // 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; armState = ARM_STATE_DISARMING_TIMEOUT;
setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMED); setArmedIfChanged(FLIGHTSTATUS_ARMED_ARMED);
break; break;
case ARM_STATE_DISARMING_TIMEOUT: case ARM_STATE_DISARMING_TIMEOUT:
// We get here when armed while throttle low, even when the arming timeout is not enabled // 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; armState = ARM_STATE_DISARMED;
} }
// Switch to disarming due to manual control when needed // Switch to disarming due to manual control when needed
if (manualDisarm) { if (manualDisarm) {
armedDisarmStart = lastSysTime; armedDisarmStart = sysTime;
armState = ARM_STATE_DISARMING_MANUAL; armState = ARM_STATE_DISARMING_MANUAL;
} }
break; break;
case ARM_STATE_DISARMING_MANUAL: case ARM_STATE_DISARMING_MANUAL:
// arming switch disarms immediately, // arming switch disarms immediately,
if (manualDisarm && (armSwitch || (timeDifferenceMs(armedDisarmStart, lastSysTime) > settings.DisarmingSequenceTime))) { if (manualDisarm && (armSwitch || (timeDifferenceMs(armedDisarmStart, sysTime) > settings.DisarmingSequenceTime))) {
armState = ARM_STATE_DISARMED; armState = ARM_STATE_DISARMED;
} else if (!manualDisarm) { } else if (!manualDisarm) {
armState = ARM_STATE_ARMED; armState = ARM_STATE_ARMED;

View File

@ -83,6 +83,14 @@ static controlHandler handler_ALTITUDE = {
}, },
.handler = &altitudeHandler, .handler = &altitudeHandler,
}; };
static controlHandler handler_AUTOTUNE = {
.controlChain = {
.Stabilization = false,
.PathFollower = false,
.PathPlanner = false,
},
.handler = NULL,
};
static controlHandler handler_PATHFOLLOWER = { static controlHandler handler_PATHFOLLOWER = {
.controlChain = { .controlChain = {
@ -127,6 +135,8 @@ int32_t ManualControlStart()
ManualControlSettingsConnectCallback(configurationUpdatedCb); ManualControlSettingsConnectCallback(configurationUpdatedCb);
ManualControlCommandConnectCallback(commandUpdatedCb); ManualControlCommandConnectCallback(commandUpdatedCb);
// clear alarms
AlarmsClear(SYSTEMALARMS_ALARM_MANUALCONTROL);
// Make sure unarmed on power up // Make sure unarmed on power up
armHandler(true); armHandler(true);
@ -207,19 +217,19 @@ static void manualControlTask(void)
handler = &handler_ALTITUDE; handler = &handler_ALTITUDE;
break; break;
case FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE: case FLIGHTSTATUS_FLIGHTMODE_AUTOTUNE:
handler = NULL; handler = &handler_AUTOTUNE;
break; break;
// There is no default, so if a flightmode is forgotten the compiler can throw a warning! // There is no default, so if a flightmode is forgotten the compiler can throw a warning!
} }
if (handler) { bool newinit = false;
bool newinit = false; if (flightStatus.FlightMode != newMode) {
if (flightStatus.FlightMode != newMode) { flightStatus.ControlChain = handler->controlChain;
flightStatus.ControlChain = handler->controlChain; flightStatus.FlightMode = newMode;
flightStatus.FlightMode = newMode; FlightStatusSet(&flightStatus);
FlightStatusSet(&flightStatus); newinit = true;
newinit = true; }
} if (handler->handler) {
handler->handler(newinit); handler->handler(newinit);
} }
} }

View File

@ -120,7 +120,7 @@ void pathFollowerHandler(bool newinit)
#else /* if defined(REVOLUTION) */ #else /* if defined(REVOLUTION) */
void pathFollowerHandler(__attribute__((unused)) bool newinit) 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 #endif // REVOLUTION

View File

@ -80,6 +80,7 @@ void stabilizedHandler(bool newinit)
break; break;
default: default:
// Major error, this should not occur because only enter this block when one of these is true // 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); stab_settings = cast_struct_to_array(settings.Stabilization1Settings, settings.Stabilization1Settings.Roll);
return; return;
} }

View File

@ -260,7 +260,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
&& (settings.ChannelGroups.FlightMode >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE && (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_INVALID
|| cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_NODRIVER))) { || 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; cmd.Connected = MANUALCONTROLCOMMAND_CONNECTED_FALSE;
ManualControlCommandSet(&cmd); ManualControlCommandSet(&cmd);
@ -324,32 +324,32 @@ static void receiverTask(__attribute__((unused)) void *parameters)
if (settings.FailsafeFlightModeSwitchPosition >= 0 && settings.FailsafeFlightModeSwitchPosition < settings.FlightModeNumber) { if (settings.FailsafeFlightModeSwitchPosition >= 0 && settings.FailsafeFlightModeSwitchPosition < settings.FlightModeNumber) {
cmd.FlightModeSwitchPosition = (uint8_t)settings.FailsafeFlightModeSwitchPosition; cmd.FlightModeSwitchPosition = (uint8_t)settings.FailsafeFlightModeSwitchPosition;
} }
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
AccessoryDesiredData accessory; AccessoryDesiredData accessory;
// Set Accessory 0 // Set Accessory 0
if (settings.ChannelGroups.Accessory0 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) { if (settings.ChannelGroups.Accessory0 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
accessory.AccessoryVal = settings.FailsafeChannel.Accessory0; accessory.AccessoryVal = settings.FailsafeChannel.Accessory0;
if (AccessoryDesiredInstSet(0, &accessory) != 0) { if (AccessoryDesiredInstSet(0, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
// Set Accessory 1 // Set Accessory 1
if (settings.ChannelGroups.Accessory1 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) { if (settings.ChannelGroups.Accessory1 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
accessory.AccessoryVal = settings.FailsafeChannel.Accessory1; accessory.AccessoryVal = settings.FailsafeChannel.Accessory1;
if (AccessoryDesiredInstSet(1, &accessory) != 0) { if (AccessoryDesiredInstSet(1, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
// Set Accessory 2 // Set Accessory 2
if (settings.ChannelGroups.Accessory2 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) { if (settings.ChannelGroups.Accessory2 != MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE) {
accessory.AccessoryVal = settings.FailsafeChannel.Accessory2; accessory.AccessoryVal = settings.FailsafeChannel.Accessory2;
if (AccessoryDesiredInstSet(2, &accessory) != 0) { if (AccessoryDesiredInstSet(2, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
} else if (valid_input_detected) { } else if (valid_input_detected) {
AlarmsClear(SYSTEMALARMS_ALARM_MANUALCONTROL); AlarmsClear(SYSTEMALARMS_ALARM_RECEIVER);
// Scale channels to -1 -> +1 range // Scale channels to -1 -> +1 range
cmd.Roll = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_ROLL]; 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); applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY0, &settings, dT);
#endif #endif
if (AccessoryDesiredInstSet(0, &accessory) != 0) { if (AccessoryDesiredInstSet(0, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
// Set Accessory 1 // Set Accessory 1
@ -421,7 +421,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY1, &settings, dT); applyLPF(&accessory.AccessoryVal, MANUALCONTROLSETTINGS_RESPONSETIME_ACCESSORY1, &settings, dT);
#endif #endif
if (AccessoryDesiredInstSet(1, &accessory) != 0) { if (AccessoryDesiredInstSet(1, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
// Set Accessory 2 // Set Accessory 2
@ -432,7 +432,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
#endif #endif
if (AccessoryDesiredInstSet(2, &accessory) != 0) { if (AccessoryDesiredInstSet(2, &accessory) != 0) {
AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); AlarmsSet(SYSTEMALARMS_ALARM_RECEIVER, SYSTEMALARMS_ALARM_WARNING);
} }
} }
} }

View File

@ -701,7 +701,7 @@
<rect <rect
inkscape:label="#rect4000-8-0-9" 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" 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" width="13.893178"
height="56.637238" height="56.637238"
x="576.71594" x="576.71594"
@ -1135,7 +1135,7 @@
</g> </g>
<g <g
style="display:none" style="display:none"
inkscape:label="ManualControl-OK" inkscape:label="Receiver-OK"
id="layer36" id="layer36"
inkscape:groupmode="layer"> inkscape:groupmode="layer">
<rect <rect
@ -1143,14 +1143,14 @@
x="576.71594" x="576.71594"
height="56.637238" height="56.637238"
width="13.893178" 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" 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" inkscape:label="#rect4000-8-0-9"
transform="translate(-497.66563,-344.28037)" /> transform="translate(-497.66563,-344.28037)" />
</g> </g>
<g <g
style="display:none" style="display:none"
inkscape:label="ManualControl-Warning" inkscape:label="Receiver-Warning"
id="layer33" id="layer33"
inkscape:groupmode="layer"> inkscape:groupmode="layer">
<rect <rect
@ -1158,19 +1158,19 @@
x="576.71594" x="576.71594"
height="56.637238" height="56.637238"
width="13.893178" 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" 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" inkscape:label="#rect4000-8-0-9"
transform="translate(-497.66563,-344.28037)" /> transform="translate(-497.66563,-344.28037)" />
</g> </g>
<g <g
style="display:none" style="display:none"
inkscape:label="ManualControl-Error" inkscape:label="Receiver-Error"
id="layer34" id="layer34"
inkscape:groupmode="layer"> inkscape:groupmode="layer">
<g <g
transform="translate(78,0)" transform="translate(78,0)"
id="ManualControl-Error" id="Receiver-Error"
style="stroke:#cf0e0e;stroke-opacity:1;display:inline" style="stroke:#cf0e0e;stroke-opacity:1;display:inline"
inkscape:label="#g3878"> inkscape:label="#g3878">
<path <path
@ -1185,14 +1185,14 @@
</g> </g>
<g <g
style="display:none" style="display:none"
inkscape:label="ManualControl-Critical" inkscape:label="Receiver-Critical"
id="layer35" id="layer35"
inkscape:groupmode="layer"> inkscape:groupmode="layer">
<rect <rect
transform="translate(-497.66563,-344.28037)" transform="translate(-497.66563,-344.28037)"
inkscape:label="#rect4000-8-0-9" 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" 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" width="13.893178"
height="56.637238" height="56.637238"
x="576.71594" x="576.71594"

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

View File

@ -1,8 +1,8 @@
<RCC> <RCC>
<qresource prefix="/systemhealth"> <qresource prefix="/systemhealth">
<file>html/Actuator-Critical.html</file> <file>html/Actuator-Critical.html</file>
<file>html/ManualControl-Critical.html</file> <file>html/Receiver-Critical.html</file>
<file>html/ManualControl-Warning.html</file> <file>html/Receiver-Warning.html</file>
<file>html/CPU-Critical.html</file> <file>html/CPU-Critical.html</file>
<file>html/CPU-Warning.html</file> <file>html/CPU-Warning.html</file>
<file>html/FlightTime-Error.html</file> <file>html/FlightTime-Error.html</file>
@ -29,8 +29,8 @@
</qresource> </qresource>
<qresource prefix="/systemhealth" lang="fr"> <qresource prefix="/systemhealth" lang="fr">
<file alias="html/Actuator-Critical.html">html/fr/Actuator-Critical.html</file> <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/Receiver-Critical.html">html/fr/Receiver-Critical.html</file>
<file alias="html/ManualControl-Warning.html">html/fr/ManualControl-Warning.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-Critical.html">html/fr/CPU-Critical.html</file>
<file alias="html/CPU-Warning.html">html/fr/CPU-Warning.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> <file alias="html/FlightTime-Error.html">html/fr/FlightTime-Error.html</file>

View File

@ -10,6 +10,7 @@
<elementname>CPUOverload</elementname> <elementname>CPUOverload</elementname>
<elementname>EventSystem</elementname> <elementname>EventSystem</elementname>
<elementname>Telemetry</elementname> <elementname>Telemetry</elementname>
<elementname>Receiver</elementname>
<elementname>ManualControl</elementname> <elementname>ManualControl</elementname>
<elementname>Actuator</elementname> <elementname>Actuator</elementname>
<elementname>Attitude</elementname> <elementname>Attitude</elementname>