mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
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.
This commit is contained in:
parent
a1d60cb77d
commit
8ebd6a83d6
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "openpilot.h"
|
#include "openpilot.h"
|
||||||
|
#include "accessorydesired.h"
|
||||||
#include "actuator.h"
|
#include "actuator.h"
|
||||||
#include "actuatorsettings.h"
|
#include "actuatorsettings.h"
|
||||||
#include "systemsettings.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 void setFailsafe();
|
||||||
static float MixerCurve(const float throttle, const float* curve);
|
static float MixerCurve(const float throttle, const float* curve);
|
||||||
static bool set_channel(uint8_t mixer_channel, uint16_t value);
|
static bool set_channel(uint8_t mixer_channel, uint16_t value);
|
||||||
|
|
||||||
float ProcessMixer(const int index, const float curve1, const float curve2,
|
float ProcessMixer(const int index, const float curve1, const float curve2,
|
||||||
MixerSettingsData* mixerSettings, ActuatorDesiredData* desired,
|
MixerSettingsData* mixerSettings, ActuatorDesiredData* desired,
|
||||||
const float period);
|
const float period);
|
||||||
@ -200,7 +200,32 @@ static void actuatorTask(void* parameters)
|
|||||||
bool spinWhileArmed = MotorsSpinWhileArmed == ACTUATORSETTINGS_MOTORSSPINWHILEARMED_TRUE;
|
bool spinWhileArmed = MotorsSpinWhileArmed == ACTUATORSETTINGS_MOTORSSPINWHILEARMED_TRUE;
|
||||||
|
|
||||||
float curve1 = MixerCurve(desired.Throttle,mixerSettings.ThrottleCurve1);
|
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++)
|
for(int ct=0; ct < MAX_MIX_ACTUATORS; ct++)
|
||||||
{
|
{
|
||||||
if(mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_DISABLED) {
|
if(mixers[ct].type == MIXERSETTINGS_MIXER1TYPE_DISABLED) {
|
||||||
@ -228,7 +253,17 @@ static void actuatorTask(void* parameters)
|
|||||||
(status[ct] < 0) )
|
(status[ct] < 0) )
|
||||||
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],
|
command.Channel[ct] = scaleChannel(status[ct],
|
||||||
ChannelMax[ct],
|
ChannelMax[ct],
|
||||||
ChannelMin[ct],
|
ChannelMin[ct],
|
||||||
@ -452,8 +487,6 @@ static void actuator_update_rate(UAVObjEvent * ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
|
#if defined(ARCH_POSIX) || defined(ARCH_WIN32)
|
||||||
static bool set_channel(uint8_t mixer_channel, uint16_t value) {
|
static bool set_channel(uint8_t mixer_channel, uint16_t value) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,22 +6,23 @@
|
|||||||
<field name="AccelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
|
<field name="AccelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
|
||||||
<field name="DecelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
|
<field name="DecelTime" units="ms" type="float" elements="1" defaultvalue="0"/>
|
||||||
<field name="ThrottleCurve1" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
|
<field name="ThrottleCurve1" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
|
||||||
|
<field name="Curve2Source" units="" type="enum" elements="1" options="Throttle,Roll,Pitch,Yaw,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="ThrottleCurve2" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
|
<field name="ThrottleCurve2" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="0,0.25,0.5,0.75,1"/>
|
||||||
<field name="Mixer1Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer1Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer1Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer1Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer2Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer2Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer2Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer2Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer3Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer3Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer3Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer3Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer4Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer4Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer4Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer4Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer5Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer5Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer5Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer5Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer6Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer6Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer6Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer6Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer7Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer7Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer7Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer7Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<field name="Mixer8Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
|
<field name="Mixer8Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo,Accessory1,Accessory2,Accessory3" defaultvalue="Disabled"/>
|
||||||
<field name="Mixer8Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
<field name="Mixer8Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user