From 54d9977eb1df79ca56beb848d1c58626bb7bae3e Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Wed, 11 May 2011 21:43:22 +0200 Subject: [PATCH 01/15] auxillaryControl --- shared/uavobjectdefinition/accessorydesired.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 shared/uavobjectdefinition/accessorydesired.xml diff --git a/shared/uavobjectdefinition/accessorydesired.xml b/shared/uavobjectdefinition/accessorydesired.xml new file mode 100644 index 000000000..2c8559238 --- /dev/null +++ b/shared/uavobjectdefinition/accessorydesired.xml @@ -0,0 +1,12 @@ + + + Desired Auxillary actuator settings. Comes from @ref ManualControlModule. + + + + + + + + + From 13655421035c7625d986e6aed22de077c938d524 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 4 Jun 2011 12:36:33 -0500 Subject: [PATCH 02/15] OP-493: Populate the Accessory Desired from TX --- flight/CopterControl/Makefile | 1 + flight/Modules/ManualControl/manualcontrol.c | 15 +++++++++++++++ flight/OpenPilot/UAVObjects.inc | 1 + .../OpenPilotOSX.xcodeproj/project.pbxproj | 2 ++ .../src/plugins/uavobjects/uavobjects.pro | 6 ++++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index 21fa59f97..349edd2d1 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -140,6 +140,7 @@ endif ## UAVOBJECTS ifndef TESTAPP +SRC += $(OPUAVSYNTHDIR)/accessorydesired.c SRC += $(OPUAVSYNTHDIR)/objectpersistence.c SRC += $(OPUAVSYNTHDIR)/gcstelemetrystats.c SRC += $(OPUAVSYNTHDIR)/flighttelemetrystats.c diff --git a/flight/Modules/ManualControl/manualcontrol.c b/flight/Modules/ManualControl/manualcontrol.c index 63543c67a..4d499b10c 100644 --- a/flight/Modules/ManualControl/manualcontrol.c +++ b/flight/Modules/ManualControl/manualcontrol.c @@ -42,6 +42,7 @@ #include "stabilizationdesired.h" #include "flighttelemetrystats.h" #include "flightstatus.h" +#include "accessorydesired.h" // Private constants #if defined(PIOS_MANUAL_STACK_SIZE) @@ -75,6 +76,7 @@ static ArmState_t armState; static portTickType lastSysTime; // Private functions +static void updateAccessoryDesired(ManualControlCommandData * cmd); static void updateActuatorDesired(ManualControlCommandData * cmd); static void updateStabilizationDesired(ManualControlCommandData * cmd, ManualControlSettingsData * settings); static void processFlightMode(ManualControlSettingsData * settings, float flightMode); @@ -294,17 +296,30 @@ static void manualControlTask(void *parameters) break; case FLIGHTMODE_MANUAL: updateActuatorDesired(&cmd); + updateAccessoryDesired(&cmd); break; case FLIGHTMODE_STABILIZED: updateStabilizationDesired(&cmd, &settings); + updateAccessoryDesired(&cmd); break; case FLIGHTMODE_GUIDANCE: + updateAccessoryDesired(&cmd); // TODO: Implement break; } } } +static void updateAccessoryDesired(ManualControlCommandData * cmd) +{ + AccessoryDesiredData accessory; + AccessoryDesiredGet(&accessory); + accessory.Accessory1 = cmd->Accessory1; + accessory.Accessory2 = cmd->Accessory2; + accessory.Accessory3 = cmd->Accessory3; + AccessoryDesiredSet(&accessory); +} + static void updateActuatorDesired(ManualControlCommandData * cmd) { ActuatorDesiredData actuator; diff --git a/flight/OpenPilot/UAVObjects.inc b/flight/OpenPilot/UAVObjects.inc index 4849367a9..3eb2fa571 100644 --- a/flight/OpenPilot/UAVObjects.inc +++ b/flight/OpenPilot/UAVObjects.inc @@ -24,6 +24,7 @@ # (all architectures) UAVOBJSRCFILENAMES = +UAVOBJSRCFILENAMES += accessorydesired UAVOBJSRCFILENAMES += actuatorcommand UAVOBJSRCFILENAMES += actuatordesired UAVOBJSRCFILENAMES += actuatorsettings diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index 0fc7ccf73..4f2252237 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -2738,6 +2738,7 @@ 65E6E09912E037C800058553 /* pios_adc_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_adc_priv.h; sourceTree = ""; }; 65E8C743139A6D0900E1F979 /* pios_crc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pios_crc.c; sourceTree = ""; }; 65E8C745139A6D1A00E1F979 /* pios_crc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_crc.h; sourceTree = ""; }; + 65E8C788139AA2A800E1F979 /* accessorydesired.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = accessorydesired.xml; sourceTree = ""; }; 65E8EF1F11EEA61E00BBF654 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = ../../OpenPilot/Makefile; sourceTree = SOURCE_ROOT; }; 65E8EF2011EEA61E00BBF654 /* Makefile.posix */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Makefile.posix; path = ../../OpenPilot/Makefile.posix; sourceTree = SOURCE_ROOT; }; 65E8EF5C11EEA61E00BBF654 /* alarms.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = alarms.c; path = ../../OpenPilot/System/alarms.c; sourceTree = SOURCE_ROOT; }; @@ -7418,6 +7419,7 @@ 65C35E4F12EFB2F3004811C2 /* uavobjectdefinition */ = { isa = PBXGroup; children = ( + 65E8C788139AA2A800E1F979 /* accessorydesired.xml */, 65C35E5012EFB2F3004811C2 /* actuatorcommand.xml */, 65C35E5112EFB2F3004811C2 /* actuatordesired.xml */, 65C35E5212EFB2F3004811C2 /* actuatorsettings.xml */, diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro index e895c74ea..8bd7420be 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjects.pro @@ -23,7 +23,8 @@ SOURCES += uavobject.cpp \ OTHER_FILES += UAVObjects.pluginspec # Add in all of the synthetic/generated uavobject files -HEADERS += $$UAVOBJECT_SYNTHETICS/ahrsstatus.h \ +HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \ + $$UAVOBJECT_SYNTHETICS/ahrsstatus.h \ $$UAVOBJECT_SYNTHETICS/ahrscalibration.h \ $$UAVOBJECT_SYNTHETICS/baroaltitude.h \ $$UAVOBJECT_SYNTHETICS/attitudeactual.h \ @@ -69,7 +70,8 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/ahrsstatus.h \ $$UAVOBJECT_SYNTHETICS/flightstatus.h \ $$UAVOBJECT_SYNTHETICS/attitudesettings.h -SOURCES += $$UAVOBJECT_SYNTHETICS/ahrsstatus.cpp \ +SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \ + $$UAVOBJECT_SYNTHETICS/ahrsstatus.cpp \ $$UAVOBJECT_SYNTHETICS/ahrscalibration.cpp \ $$UAVOBJECT_SYNTHETICS/baroaltitude.cpp \ $$UAVOBJECT_SYNTHETICS/attitudeactual.cpp \ From a1d60cb77d34b9f1c1f6f6238b5b7a77f1e65ea7 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 4 Jun 2011 12:52:36 -0500 Subject: [PATCH 03/15] OP-493: Use multiple instances when using multiple accessory channels --- flight/Modules/ManualControl/manualcontrol.c | 32 ++++++++----------- .../uavobjectdefinition/accessorydesired.xml | 4 +-- .../manualcontrolcommand.xml | 6 +--- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/flight/Modules/ManualControl/manualcontrol.c b/flight/Modules/ManualControl/manualcontrol.c index 4d499b10c..4870db6bc 100644 --- a/flight/Modules/ManualControl/manualcontrol.c +++ b/flight/Modules/ManualControl/manualcontrol.c @@ -76,7 +76,6 @@ static ArmState_t armState; static portTickType lastSysTime; // Private functions -static void updateAccessoryDesired(ManualControlCommandData * cmd); static void updateActuatorDesired(ManualControlCommandData * cmd); static void updateStabilizationDesired(ManualControlCommandData * cmd, ManualControlSettingsData * settings); static void processFlightMode(ManualControlSettingsData * settings, float flightMode); @@ -268,10 +267,20 @@ static void manualControlTask(void *parameters) cmd.Throttle = scaledChannel[settings.Throttle]; flightMode = scaledChannel[settings.FlightMode]; - // Set accessory channels - cmd.Accessory1 = (settings.Accessory1 != MANUALCONTROLSETTINGS_ACCESSORY1_NONE) ? scaledChannel[settings.Accessory1] : 0; - cmd.Accessory2 = (settings.Accessory2 != MANUALCONTROLSETTINGS_ACCESSORY2_NONE) ? scaledChannel[settings.Accessory2] : 0; - cmd.Accessory3 = (settings.Accessory3 != MANUALCONTROLSETTINGS_ACCESSORY3_NONE) ? scaledChannel[settings.Accessory3] : 0; + AccessoryDesiredData accessory; + // Set Accessory 1 + accessory.AccessoryVal = scaledChannel[settings.Accessory1]; + if(AccessoryDesiredInstSet(0, &accessory) != 0) + AccessoryDesiredCreateInstance(); + // Set Accessory 2 + accessory.AccessoryVal = scaledChannel[settings.Accessory2]; + if(AccessoryDesiredInstSet(1, &accessory) != 0) + AccessoryDesiredCreateInstance(); + // Set Accsesory 3 + accessory.AccessoryVal = scaledChannel[settings.Accessory3]; + if(AccessoryDesiredInstSet(2, &accessory) != 0) + AccessoryDesiredCreateInstance(); + processFlightMode(&settings, flightMode); processArm(&cmd, &settings); @@ -296,30 +305,17 @@ static void manualControlTask(void *parameters) break; case FLIGHTMODE_MANUAL: updateActuatorDesired(&cmd); - updateAccessoryDesired(&cmd); break; case FLIGHTMODE_STABILIZED: updateStabilizationDesired(&cmd, &settings); - updateAccessoryDesired(&cmd); break; case FLIGHTMODE_GUIDANCE: - updateAccessoryDesired(&cmd); // TODO: Implement break; } } } -static void updateAccessoryDesired(ManualControlCommandData * cmd) -{ - AccessoryDesiredData accessory; - AccessoryDesiredGet(&accessory); - accessory.Accessory1 = cmd->Accessory1; - accessory.Accessory2 = cmd->Accessory2; - accessory.Accessory3 = cmd->Accessory3; - AccessoryDesiredSet(&accessory); -} - static void updateActuatorDesired(ManualControlCommandData * cmd) { ActuatorDesiredData actuator; diff --git a/shared/uavobjectdefinition/accessorydesired.xml b/shared/uavobjectdefinition/accessorydesired.xml index 2c8559238..87700a459 100644 --- a/shared/uavobjectdefinition/accessorydesired.xml +++ b/shared/uavobjectdefinition/accessorydesired.xml @@ -1,9 +1,7 @@ Desired Auxillary actuator settings. Comes from @ref ManualControlModule. - - - + diff --git a/shared/uavobjectdefinition/manualcontrolcommand.xml b/shared/uavobjectdefinition/manualcontrolcommand.xml index 58d6d9330..ef74c2576 100644 --- a/shared/uavobjectdefinition/manualcontrolcommand.xml +++ b/shared/uavobjectdefinition/manualcontrolcommand.xml @@ -6,11 +6,7 @@ - - - - - + From 8ebd6a83d631758171eb2089f204f2e875e71ac5 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 4 Jun 2011 15:31:06 -0500 Subject: [PATCH 04/15] OP-493: Add support to bypass the mixer and route accessory data straight to outputs. Warning: This has no failsafes like arming. We should discuss if this is appropriate. In addition accessory objects can be routed throught the mixer for collective or flaperon. --- flight/Modules/Actuator/actuator.c | 43 +++++++++++++++++--- shared/uavobjectdefinition/mixersettings.xml | 17 ++++---- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 05ad47e7a..0b127ea85 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -32,6 +32,7 @@ #include "openpilot.h" +#include "accessorydesired.h" #include "actuator.h" #include "actuatorsettings.h" #include "systemsettings.h" @@ -74,7 +75,6 @@ static int16_t scaleChannel(float value, int16_t max, int16_t min, int16_t neutr static void setFailsafe(); static float MixerCurve(const float throttle, const float* curve); static bool set_channel(uint8_t mixer_channel, uint16_t value); - float ProcessMixer(const int index, const float curve1, const float curve2, MixerSettingsData* mixerSettings, ActuatorDesiredData* desired, const float period); @@ -200,7 +200,32 @@ static void actuatorTask(void* parameters) bool spinWhileArmed = MotorsSpinWhileArmed == ACTUATORSETTINGS_MOTORSSPINWHILEARMED_TRUE; float curve1 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve1); - float curve2 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve2); + //The source for the secondary curve is selectable + float curve2; + AccessoryDesiredData accessory; + switch(mixerSettings.Curve2Source) { + case MIXERSETTINGS_CURVE2SOURCE_THROTTLE: + curve2 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve2); + break; + case MIXERSETTINGS_CURVE2SOURCE_ROLL: + curve2 = MixerCurve(desired.Roll,mixerSettings.ThrottleCurve2); + break; + case MIXERSETTINGS_CURVE2SOURCE_PITCH: + curve2 = MixerCurve(desired.Pitch,mixerSettings.ThrottleCurve2); + break; + case MIXERSETTINGS_CURVE2SOURCE_YAW: + curve2 = MixerCurve(desired.Yaw,mixerSettings.ThrottleCurve2); + break; + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1: + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY2: + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY3: + if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1,&accessory) == 0) + curve2 = MixerCurve(accessory.AccessoryVal,mixerSettings.ThrottleCurve2); + else + curve2 = 0; + break; + } + for(int ct=0; ct < MAX_MIX_ACTUATORS; ct++) { if(mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_DISABLED) { @@ -228,7 +253,17 @@ static void actuatorTask(void* parameters) (status[ct] < 0) ) status[ct] = 0; } - + + // If an accessory channel is selected + if( (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY1) || + (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY2) || + (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY3)) { + if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1,&accessory) == 0) + status[ct] = accessory.AccessoryVal; + else + status[ct] = -1; + } + command.Channel[ct] = scaleChannel(status[ct], ChannelMax[ct], ChannelMin[ct], @@ -452,8 +487,6 @@ static void actuator_update_rate(UAVObjEvent * ev) } } - - #if defined(ARCH_POSIX) || defined(ARCH_WIN32) static bool set_channel(uint8_t mixer_channel, uint16_t value) { return true; diff --git a/shared/uavobjectdefinition/mixersettings.xml b/shared/uavobjectdefinition/mixersettings.xml index efe48d090..fd1040806 100644 --- a/shared/uavobjectdefinition/mixersettings.xml +++ b/shared/uavobjectdefinition/mixersettings.xml @@ -6,22 +6,23 @@ + - + - + - + - + - + - + - + - + From a1336e4d03e138794f86ccfc3f3ae55a58525fdd Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 5 Jun 2011 08:34:12 -0500 Subject: [PATCH 05/15] OP-493: Make sure accessory desired is not a single instance object --- flight/Modules/Actuator/actuator.c | 6 +++--- .../uavobjectdefinition/accessorydesired.xml | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 0b127ea85..a4f398302 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -201,7 +201,7 @@ static void actuatorTask(void* parameters) float curve1 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve1); //The source for the secondary curve is selectable - float curve2; + float curve2 = 0; AccessoryDesiredData accessory; switch(mixerSettings.Curve2Source) { case MIXERSETTINGS_CURVE2SOURCE_THROTTLE: @@ -260,8 +260,8 @@ static void actuatorTask(void* parameters) (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY3)) { if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1,&accessory) == 0) status[ct] = accessory.AccessoryVal; - else - status[ct] = -1; + else + status[ct] = -1; } command.Channel[ct] = scaleChannel(status[ct], diff --git a/shared/uavobjectdefinition/accessorydesired.xml b/shared/uavobjectdefinition/accessorydesired.xml index 87700a459..d0a7b0ed8 100644 --- a/shared/uavobjectdefinition/accessorydesired.xml +++ b/shared/uavobjectdefinition/accessorydesired.xml @@ -1,10 +1,10 @@ - - - Desired Auxillary actuator settings. Comes from @ref ManualControlModule. - - - - - - - + + + Desired Auxillary actuator settings. Comes from @ref ManualControlModule. + + + + + + + From 468b7b562d469b0da8a101f6aced512abf555c75 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 5 Jun 2011 10:41:12 -0500 Subject: [PATCH 06/15] OP-493: Small bug in default value for Curve2Source --- shared/uavobjectdefinition/mixersettings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/uavobjectdefinition/mixersettings.xml b/shared/uavobjectdefinition/mixersettings.xml index fd1040806..46aa70cab 100644 --- a/shared/uavobjectdefinition/mixersettings.xml +++ b/shared/uavobjectdefinition/mixersettings.xml @@ -6,7 +6,7 @@ - + From 99b3a629a86b644ca0e57691070ae056014d1258 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 5 Jun 2011 15:22:20 -0500 Subject: [PATCH 07/15] OP-493: Force three AccessoryDesired objects to always exist. Routing to Mixing channel now works. However Accessory desired instances do not show up in GCS. --- flight/Modules/ManualControl/manualcontrol.c | 33 ++++++++++++------- flight/Project/gdb/coptercontrol | 2 +- .../manualcontrolsettings.xml | 2 +- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/flight/Modules/ManualControl/manualcontrol.c b/flight/Modules/ManualControl/manualcontrol.c index 4870db6bc..8b972bc6e 100644 --- a/flight/Modules/ManualControl/manualcontrol.c +++ b/flight/Modules/ManualControl/manualcontrol.c @@ -171,6 +171,11 @@ static void manualControlTask(void *parameters) uint8_t disconnected_count = 0; uint8_t connected_count = 0; + // For now manual instantiate extra instances of Accessory Desired. In future should be done dynamically + // this includes not even registering it if not used + AccessoryDesiredCreateInstance(); + AccessoryDesiredCreateInstance(); + // Make sure unarmed on power up ManualControlCommandGet(&cmd); FlightStatusGet(&flightStatus); @@ -268,18 +273,24 @@ static void manualControlTask(void *parameters) flightMode = scaledChannel[settings.FlightMode]; AccessoryDesiredData accessory; + // Set Accessory 0 + if(settings.Accessory0 != MANUALCONTROLSETTINGS_ACCESSORY0_NONE) { + accessory.AccessoryVal = scaledChannel[settings.Accessory0]; + if(AccessoryDesiredInstSet(0, &accessory) != 0) + AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); + } // Set Accessory 1 - accessory.AccessoryVal = scaledChannel[settings.Accessory1]; - if(AccessoryDesiredInstSet(0, &accessory) != 0) - AccessoryDesiredCreateInstance(); - // Set Accessory 2 - accessory.AccessoryVal = scaledChannel[settings.Accessory2]; - if(AccessoryDesiredInstSet(1, &accessory) != 0) - AccessoryDesiredCreateInstance(); - // Set Accsesory 3 - accessory.AccessoryVal = scaledChannel[settings.Accessory3]; - if(AccessoryDesiredInstSet(2, &accessory) != 0) - AccessoryDesiredCreateInstance(); + if(settings.Accessory1 != MANUALCONTROLSETTINGS_ACCESSORY1_NONE) { + accessory.AccessoryVal = scaledChannel[settings.Accessory1]; + if(AccessoryDesiredInstSet(1, &accessory) != 0) + AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); + } + // Set Accsesory 2 + if(settings.Accessory2 != MANUALCONTROLSETTINGS_ACCESSORY2_NONE) { + accessory.AccessoryVal = scaledChannel[settings.Accessory2]; + if(AccessoryDesiredInstSet(2, &accessory) != 0) + AlarmsSet(SYSTEMALARMS_ALARM_MANUALCONTROL, SYSTEMALARMS_ALARM_WARNING); + } processFlightMode(&settings, flightMode); diff --git a/flight/Project/gdb/coptercontrol b/flight/Project/gdb/coptercontrol index d08282e50..7e7b53453 100644 --- a/flight/Project/gdb/coptercontrol +++ b/flight/Project/gdb/coptercontrol @@ -1,7 +1,7 @@ define connect target remote localhost:3333 monitor cortex_m3 vector_catch all - file ./build/coptercontrol/CopterControl.elf + file ./build/fw_coptercontrol/fw_coptercontrol.elf end #monitor reset halt diff --git a/shared/uavobjectdefinition/manualcontrolsettings.xml b/shared/uavobjectdefinition/manualcontrolsettings.xml index 63488deee..0828932e4 100644 --- a/shared/uavobjectdefinition/manualcontrolsettings.xml +++ b/shared/uavobjectdefinition/manualcontrolsettings.xml @@ -7,9 +7,9 @@ + - From 6c6906d61e45edc3dfde0637ba212dd7466f4bc6 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 5 Jun 2011 15:30:38 -0500 Subject: [PATCH 08/15] OP-493: Switch to using Accessory0:2 to match the InstId --- flight/Modules/Actuator/actuator.c | 12 ++++++------ shared/uavobjectdefinition/mixersettings.xml | 18 +++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index a4f398302..9d21dba5a 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -216,10 +216,10 @@ static void actuatorTask(void* parameters) case MIXERSETTINGS_CURVE2SOURCE_YAW: curve2 = MixerCurve(desired.Yaw,mixerSettings.ThrottleCurve2); break; + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0: case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1: case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY2: - case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY3: - if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1,&accessory) == 0) + if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0,&accessory) == 0) curve2 = MixerCurve(accessory.AccessoryVal,mixerSettings.ThrottleCurve2); else curve2 = 0; @@ -255,10 +255,10 @@ static void actuatorTask(void* parameters) } // If an accessory channel is selected - if( (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY1) || - (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY2) || - (mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_ACCESSORY3)) { - if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1,&accessory) == 0) + if( (mixers[ct].type >= MIXERSETTINGS_MIXER1TYPE_ACCESSORY0) && + (mixers[ct].type <= MIXERSETTINGS_MIXER1TYPE_ACCESSORY2)) + { + if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0,&accessory) == 0) status[ct] = accessory.AccessoryVal; else status[ct] = -1; diff --git a/shared/uavobjectdefinition/mixersettings.xml b/shared/uavobjectdefinition/mixersettings.xml index 46aa70cab..e1a1a6c5a 100644 --- a/shared/uavobjectdefinition/mixersettings.xml +++ b/shared/uavobjectdefinition/mixersettings.xml @@ -6,23 +6,23 @@ - + - + - + - + - + - + - + - + - + From 83916f3a4e863053ae767dca2b1c3010e74942eb Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 6 Jun 2011 10:37:57 -0500 Subject: [PATCH 09/15] Fix bug in UAVTalk where the expected packet length check was incorrect for instances of objects --- .../openpilotgcs/src/plugins/uavtalk/uavtalk.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp index 3cfe6dfe7..6a9d22d5f 100644 --- a/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp +++ b/ground/openpilotgcs/src/plugins/uavtalk/uavtalk.cpp @@ -295,7 +295,7 @@ bool UAVTalk::processInputByte(quint8 rxbyte) } // Check the lengths match - if ((rxPacketLength + rxLength) != packetSize) + if ((rxPacketLength + rxLength + (rxObj->isSingleInstance() ? 0 : 2)) != packetSize) { // packet error - mismatched packet size stats.rxErrors++; rxState = STATE_SYNC; @@ -805,17 +805,3 @@ quint8 UAVTalk::updateCRC(quint8 crc, const quint8* data, qint32 length) crc = crc_table[crc ^ *data++]; return crc; } - - - - - - - - - - - - - - From 1ecd244affb82068cad6b3901e58776ceb996167 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 6 Jun 2011 10:46:07 -0500 Subject: [PATCH 10/15] OP-493 OP-505 OP-511: Fixed bug with the direct mapping where it looked at throttle curve source instead of directly bypassing --- flight/Modules/Actuator/actuator.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 9d21dba5a..1deceab0e 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -254,11 +254,16 @@ static void actuatorTask(void* parameters) status[ct] = 0; } - // If an accessory channel is selected + // If an accessory channel is selected for direct bypass mode + // In this configuration the accessory channel is scaled and mapped + // directly to output. Note: THERE IS NO SAFETY CHECK HERE FOR ARMING + // these also will not be updated in failsafe mode. I'm not sure what + // the correct behavior is since it seems domain specific. I don't love + // this code if( (mixers[ct].type >= MIXERSETTINGS_MIXER1TYPE_ACCESSORY0) && (mixers[ct].type <= MIXERSETTINGS_MIXER1TYPE_ACCESSORY2)) { - if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0,&accessory) == 0) + if(AccessoryDesiredInstGet(mixers[ct].type - MIXERSETTINGS_MIXER1TYPE_ACCESSORY0,&accessory) == 0) status[ct] = accessory.AccessoryVal; else status[ct] = -1; From bdc909497554d83c87fb5677c9725c6b2803d63d Mon Sep 17 00:00:00 2001 From: James Cotton Date: Mon, 6 Jun 2011 10:52:02 -0500 Subject: [PATCH 11/15] OP-493 OP-505 OP-511: Make up to 6 accessory channels so some can go from ManualCommand to a camera module and some could go from that camera module to output (i.e. mixing of inputs to pan tilt with stabilization) --- flight/Modules/Actuator/actuator.c | 3 +++ shared/uavobjectdefinition/mixersettings.xml | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/flight/Modules/Actuator/actuator.c b/flight/Modules/Actuator/actuator.c index 1deceab0e..af8ee06ea 100644 --- a/flight/Modules/Actuator/actuator.c +++ b/flight/Modules/Actuator/actuator.c @@ -219,6 +219,9 @@ static void actuatorTask(void* parameters) case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0: case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY1: case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY2: + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY3: + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY4: + case MIXERSETTINGS_CURVE2SOURCE_ACCESSORY5: if(AccessoryDesiredInstGet(mixerSettings.Curve2Source - MIXERSETTINGS_CURVE2SOURCE_ACCESSORY0,&accessory) == 0) curve2 = MixerCurve(accessory.AccessoryVal,mixerSettings.ThrottleCurve2); else diff --git a/shared/uavobjectdefinition/mixersettings.xml b/shared/uavobjectdefinition/mixersettings.xml index e1a1a6c5a..a93b8c2ff 100644 --- a/shared/uavobjectdefinition/mixersettings.xml +++ b/shared/uavobjectdefinition/mixersettings.xml @@ -6,23 +6,23 @@ - + - + - + - + - + - + - + - + - + From 4a59c03b0e62f3dde9be5abb7ddb3d2db0801cc1 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Tue, 7 Jun 2011 10:31:40 -0500 Subject: [PATCH 12/15] OP-493: Unfortuantely have to change stack alarms for this to work :( --- flight/CopterControl/System/inc/pios_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flight/CopterControl/System/inc/pios_config.h b/flight/CopterControl/System/inc/pios_config.h index 98c900387..392771a26 100644 --- a/flight/CopterControl/System/inc/pios_config.h +++ b/flight/CopterControl/System/inc/pios_config.h @@ -85,8 +85,8 @@ #define AUXUART_BAUDRATE 19200 /* Alarm Thresholds */ -#define HEAP_LIMIT_WARNING 350 -#define HEAP_LIMIT_CRITICAL 250 +#define HEAP_LIMIT_WARNING 220 +#define HEAP_LIMIT_CRITICAL 150 #define CPULOAD_LIMIT_WARNING 80 #define CPULOAD_LIMIT_CRITICAL 95 From 0f5fe543290f4f9d4f049a90643a76863af07699 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 11 Jun 2011 22:31:51 -0500 Subject: [PATCH 13/15] FlashFS: Should clear the 0 sector when wiping flash chip, not 10 bytes in. --- flight/PiOS/Common/pios_flashfs_objlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flight/PiOS/Common/pios_flashfs_objlist.c b/flight/PiOS/Common/pios_flashfs_objlist.c index ee3abe6f9..11a40822a 100644 --- a/flight/PiOS/Common/pios_flashfs_objlist.c +++ b/flight/PiOS/Common/pios_flashfs_objlist.c @@ -105,7 +105,7 @@ int32_t PIOS_FLASHFS_Init() */ static int32_t PIOS_FLASHFS_CleabObjectTableHeader() { - if(PIOS_Flash_W25X_EraseSector(OBJECT_TABLE_START) != 0) + if(PIOS_Flash_W25X_EraseSector(0) != 0) return -1; uint32_t object_table_magic = OBJECT_TABLE_MAGIC; From 404c026188f9c9fb243c3ff56cbfd9776ae38178 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sun, 12 Jun 2011 23:04:35 -0500 Subject: [PATCH 14/15] Patch from Zippe to use cycle timer for CPU monitoring. --- .../CopterControl/System/inc/FreeRTOSConfig.h | 12 +++++++ flight/CopterControl/System/taskmonitor.c | 36 +++++++++++++++---- flight/OpenPilot/System/inc/FreeRTOSConfig.h | 9 +++-- flight/OpenPilot/System/taskmonitor.c | 19 +++++++++- .../Libraries/FreeRTOS/Source/tasks.c | 6 +++- 5 files changed, 70 insertions(+), 12 deletions(-) diff --git a/flight/CopterControl/System/inc/FreeRTOSConfig.h b/flight/CopterControl/System/inc/FreeRTOSConfig.h index b4677fd8d..c05f71ea5 100644 --- a/flight/CopterControl/System/inc/FreeRTOSConfig.h +++ b/flight/CopterControl/System/inc/FreeRTOSConfig.h @@ -71,6 +71,18 @@ configKERNEL_INTERRUPT_PRIORITY setting. Here 15 corresponds to the lowest NVIC value of 255. */ #define configLIBRARY_KERNEL_INTERRUPT_PRIORITY 15 +/* Enable run time stats collection */ +//#if defined(DEBUG) +#define configGENERATE_RUN_TIME_STATS 1 +#define INCLUDE_uxTaskGetRunTime 1 +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()\ +do {\ +(*(unsigned long *)0xe000edfc) |= (1<<24);/* DEMCR |= DEMCR_TRCENA */\ +(*(unsigned long *)0xe0001000) |= 1; /* DWT_CTRL |= DWT_CYCCNT_ENA */\ +} while(0) +#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004)/* DWT_CYCCNT */ +//#endif + /** * @} */ diff --git a/flight/CopterControl/System/taskmonitor.c b/flight/CopterControl/System/taskmonitor.c index e13b20515..8941a616b 100644 --- a/flight/CopterControl/System/taskmonitor.c +++ b/flight/CopterControl/System/taskmonitor.c @@ -35,21 +35,23 @@ // Private variables static xSemaphoreHandle lock; static xTaskHandle handles[TASKINFO_RUNNING_NUMELEM]; +static uint32_t lastMonitorTime; // Private functions /** - * Initialize library + * Initialize library */ int32_t TaskMonitorInitialize(void) { lock = xSemaphoreCreateRecursiveMutex(); memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM); + lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE(); return 0; } /** - * Register a task handle with the library + * Register a task handle with the library */ int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle) { @@ -67,16 +69,30 @@ int32_t TaskMonitorAdd(TaskInfoRunningElem task, xTaskHandle handle) } /** - * Update the status of all tasks + * Update the status of all tasks */ void TaskMonitorUpdateAll(void) { TaskInfoData data; int n; - + // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); - + +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t currentTime; + uint32_t deltaTime; + + /* + * Calculate the amount of elapsed run time between the last time we + * measured and now. Scale so that we can convert task run times + * directly to percentages. + */ + currentTime = portGET_RUN_TIME_COUNTER_VALUE(); + deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */ + lastMonitorTime = currentTime; +#endif + // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { @@ -87,18 +103,24 @@ void TaskMonitorUpdateAll(void) data.StackRemaining[n] = 10000; #else data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + /* Generate run time stats */ + data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime; #endif +#endif + } else { data.Running[n] = TASKINFO_RUNNING_FALSE; data.StackRemaining[n] = 0; + data.RunningTime[n] = 0; } } - + // Update object TaskInfoSet(&data); - + // Done xSemaphoreGiveRecursive(lock); } diff --git a/flight/OpenPilot/System/inc/FreeRTOSConfig.h b/flight/OpenPilot/System/inc/FreeRTOSConfig.h index 6336639a4..3e770e421 100644 --- a/flight/OpenPilot/System/inc/FreeRTOSConfig.h +++ b/flight/OpenPilot/System/inc/FreeRTOSConfig.h @@ -75,9 +75,12 @@ NVIC value of 255. */ #if defined(DEBUG) #define configGENERATE_RUN_TIME_STATS 1 #define INCLUDE_uxTaskGetRunTime 1 -#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() PIOS_RTC_Init() -// Note: Using the tick count defeats the purpose here, need some timer on the scale of 10khz -#define portGET_RUN_TIME_COUNTER_VALUE() PIOS_RTC_Counter() +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()\ +do {\ +(*(unsigned long *)0xe000edfc) |= (1<<24);/* DEMCR |= DEMCR_TRCENA */\ +(*(unsigned long *)0xe0001000) |= 1; /* DWT_CTRL |= DWT_CYCCNT_ENA */\ +} while(0) +#define portGET_RUN_TIME_COUNTER_VALUE() (*(unsigned long *)0xe0001004)/* DWT_CYCCNT */ #endif diff --git a/flight/OpenPilot/System/taskmonitor.c b/flight/OpenPilot/System/taskmonitor.c index bc9651982..d7fa3fde4 100644 --- a/flight/OpenPilot/System/taskmonitor.c +++ b/flight/OpenPilot/System/taskmonitor.c @@ -35,6 +35,7 @@ // Private variables static xSemaphoreHandle lock; static xTaskHandle handles[TASKINFO_RUNNING_NUMELEM]; +static uint32_t lastMonitorTime; // Private functions @@ -45,6 +46,7 @@ int32_t TaskMonitorInitialize(void) { lock = xSemaphoreCreateRecursiveMutex(); memset(handles, 0, sizeof(xTaskHandle)*TASKINFO_RUNNING_NUMELEM); + lastMonitorTime = portGET_RUN_TIME_COUNTER_VALUE(); return 0; } @@ -95,6 +97,20 @@ void TaskMonitorUpdateAll(void) // Lock xSemaphoreTakeRecursive(lock, portMAX_DELAY); +#if ( configGENERATE_RUN_TIME_STATS == 1 ) + uint32_t currentTime; + uint32_t deltaTime; + + /* + * Calculate the amount of elapsed run time between the last time we + * measured and now. Scale so that we can convert task run times + * directly to percentages. + */ + currentTime = portGET_RUN_TIME_COUNTER_VALUE(); + deltaTime = ((currentTime - lastMonitorTime) / 100) ? : 1; /* avoid divide-by-zero if the interval is too small */ + lastMonitorTime = currentTime; +#endif + // Update all task information for (n = 0; n < TASKINFO_RUNNING_NUMELEM; ++n) { @@ -107,7 +123,8 @@ void TaskMonitorUpdateAll(void) data.StackRemaining[n] = uxTaskGetStackHighWaterMark(handles[n]) * 4; #if ( configGENERATE_RUN_TIME_STATS == 1 ) /* Generate run time stats */ - data.RunningTime[n] = 100 * (float) uxTaskGetRunTime(handles[n]) / portGET_RUN_TIME_COUNTER_VALUE(); + data.RunningTime[n] = uxTaskGetRunTime(handles[n]) / deltaTime; + #endif #endif diff --git a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c index de7440f27..865d5e9db 100644 --- a/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c +++ b/flight/PiOS/STM32F10x/Libraries/FreeRTOS/Source/tasks.c @@ -2315,9 +2315,13 @@ tskTCB *pxNewTCB; #if ( INCLUDE_uxTaskGetRunTime == 1 ) unsigned portBASE_TYPE uxTaskGetRunTime( xTaskHandle xTask ) { + unsigned long runTime; + tskTCB *pxTCB; pxTCB = prvGetTCBFromHandle( xTask ); - return pxTCB->ulRunTimeCounter; + runTime = pxTCB->ulRunTimeCounter; + pxTCB->ulRunTimeCounter = 0; + return runTime; } #endif From eecacc57f611523a2f6e8e8df5f244e8b3eeceac Mon Sep 17 00:00:00 2001 From: dankers Date: Sun, 19 Jun 2011 02:34:12 +1000 Subject: [PATCH 15/15] Update deluxe dials from London Flyer, added deluxe horizontal dial Note: these are not used by default, commiting to master directly --- .../Dials/deluxe/lineardial-horizontal.svg | 1329 +++++++++++++++++ artwork/Dials/deluxe/lineardial-vertical.svg | 25 +- .../dials/deluxe/lineardial-horizontal.svg | 1329 +++++++++++++++++ .../dials/deluxe/lineardial-vertical.svg | 25 +- 4 files changed, 2682 insertions(+), 26 deletions(-) create mode 100644 artwork/Dials/deluxe/lineardial-horizontal.svg create mode 100644 ground/openpilotgcs/share/openpilotgcs/dials/deluxe/lineardial-horizontal.svg diff --git a/artwork/Dials/deluxe/lineardial-horizontal.svg b/artwork/Dials/deluxe/lineardial-horizontal.svg new file mode 100644 index 000000000..2f6f71b17 --- /dev/null +++ b/artwork/Dials/deluxe/lineardial-horizontal.svg @@ -0,0 +1,1329 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Edouard Lafargue + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/artwork/Dials/deluxe/lineardial-vertical.svg b/artwork/Dials/deluxe/lineardial-vertical.svg index 11a4e1c93..010283c2c 100644 --- a/artwork/Dials/deluxe/lineardial-vertical.svg +++ b/artwork/Dials/deluxe/lineardial-vertical.svg @@ -30,7 +30,7 @@ style="stop-color:#000000;stop-opacity:1" /> + style="stop-color:#dcaf28;stop-opacity:1" /> + offset="0.38184431" + style="stop-color:#00a000;stop-opacity:1" /> + style="stop-color:#aa0000;stop-opacity:1" />