From f950b9f6c0baa0f1d4ac9d21cb303ce94f03adcd Mon Sep 17 00:00:00 2001 From: peabody124 Date: Thu, 4 Nov 2010 02:30:53 +0000 Subject: [PATCH] Flight/ManualControl: Make it so the disarmed signal itself changes when GCS lost. Warning though: it takes ~5-10 seconds for the flight telemetry status to go from connected so this solution still isn't great. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2070 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Modules/Actuator/actuator.c | 11 +--------- .../Modules/ManualControl/manualcontrol.c | 13 ++++++++++++ .../OpenPilotOSX.xcodeproj/project.pbxproj | 20 +++++++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/flight/OpenPilot/Modules/Actuator/actuator.c b/flight/OpenPilot/Modules/Actuator/actuator.c index b23118a4b..998048b02 100644 --- a/flight/OpenPilot/Modules/Actuator/actuator.c +++ b/flight/OpenPilot/Modules/Actuator/actuator.c @@ -36,7 +36,6 @@ //#include "vtolsettings.h" #include "systemsettings.h" #include "actuatordesired.h" -#include "flighttelemetrystats.h" #include "actuatorcommand.h" #include "manualcontrolcommand.h" #include "mixersettings.h" @@ -180,15 +179,7 @@ static void actuatorTask(void* parameters) AlarmsClear(SYSTEMALARMS_ALARM_ACTUATOR); bool armed = manualControl.Armed == MANUALCONTROLCOMMAND_ARMED_TRUE; - if(ManualControlCommandReadOnly(&manualControl)) { - /* when being controlled by GCS check for connection still intact */ - /* eventually this lost connection (like lost RX) will trigger */ - /* a failsafe flight pattern */ - FlightTelemetryStatsData flightStats; - FlightTelemetryStatsGet(&flightStats); - armed &= (flightStats.Status == FLIGHTTELEMETRYSTATS_STATUS_CONNECTED); - } - armed &= desired.Throttle > 0.05; //zero throttle stops the motors + armed &= desired.Throttle > 0.00; //zero throttle stops the motors float curve1 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve1); float curve2 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve2); diff --git a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c index 85fb7c679..da216e326 100644 --- a/flight/OpenPilot/Modules/ManualControl/manualcontrol.c +++ b/flight/OpenPilot/Modules/ManualControl/manualcontrol.c @@ -41,6 +41,7 @@ #include "actuatordesired.h" #include "attitudedesired.h" #include "ahrssettings.h" +#include "flighttelemetrystats.h" // Private constants #define STACK_SIZE configMINIMAL_STACK_SIZE @@ -110,6 +111,18 @@ static void manualControlTask(void *parameters) ManualControlSettingsGet(&settings); StabilizationSettingsGet(&stabSettings); + if (ManualControlCommandReadOnly(&cmd)) { + FlightTelemetryStatsData flightTelemStats; + FlightTelemetryStatsGet(&flightTelemStats); + if(flightTelemStats.Status != FLIGHTTELEMETRYSTATS_STATUS_CONNECTED) { + /* trying to fly via GCS and lost connection. fall back to transmitter */ + UAVObjMetadata metadata; + UAVObjGetMetadata(&cmd, &metadata); + metadata.access = ACCESS_READWRITE; + UAVObjSetMetadata(&cmd, &metadata); + } + } + if (!ManualControlCommandReadOnly(&cmd)) { // Check settings, if error raise alarm if (settings.Roll >= MANUALCONTROLSETTINGS_ROLL_NONE || diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index badad3def..32cf2d3a6 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -28,6 +28,8 @@ 651CF9F1120B700D00EEFD70 /* pios_usb_hid_prop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_prop.h; sourceTree = ""; }; 651CF9F2120B700D00EEFD70 /* pios_usb_hid_pwr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_usb_hid_pwr.h; sourceTree = ""; }; 651CF9F3120B700D00EEFD70 /* usb_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = usb_conf.h; sourceTree = ""; }; + 651F32ED1281DE7E00D065F8 /* firmwareiap.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = firmwareiap.c; sourceTree = ""; }; + 651F32EF1281DE7E00D065F8 /* firmwareiap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = firmwareiap.h; sourceTree = ""; }; 65209A1812208B0600453371 /* baroaltitude.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = baroaltitude.xml; sourceTree = ""; }; 65209A1912208B0600453371 /* gpsposition.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = gpsposition.xml; sourceTree = ""; }; 6526645A122DF972006F9A3C /* pios_i2c_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_i2c_priv.h; sourceTree = ""; }; @@ -2920,6 +2922,23 @@ path = inc; sourceTree = ""; }; + 651F32EC1281DE7E00D065F8 /* FirmwareIAP */ = { + isa = PBXGroup; + children = ( + 651F32ED1281DE7E00D065F8 /* firmwareiap.c */, + 651F32EE1281DE7E00D065F8 /* inc */, + ); + path = FirmwareIAP; + sourceTree = ""; + }; + 651F32EE1281DE7E00D065F8 /* inc */ = { + isa = PBXGroup; + children = ( + 651F32EF1281DE7E00D065F8 /* firmwareiap.h */, + ); + path = inc; + sourceTree = ""; + }; 65632CBE124E09D900469B77 /* Guidance */ = { isa = PBXGroup; children = ( @@ -6846,6 +6865,7 @@ 65E8EF2E11EEA61E00BBF654 /* Attitude */, 65E8EF3011EEA61E00BBF654 /* Battery */, 65E8EF3411EEA61E00BBF654 /* Example */, + 651F32EC1281DE7E00D065F8 /* FirmwareIAP */, 65E8EF3D11EEA61E00BBF654 /* GPS */, 65632CBE124E09D900469B77 /* Guidance */, 65E8EF4311EEA61E00BBF654 /* ManualControl */,