From 8ebd6a83d631758171eb2089f204f2e875e71ac5 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Sat, 4 Jun 2011 15:31:06 -0500 Subject: [PATCH] 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 @@ + - + - + - + - + - + - + - + - +