1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

Flight: Added ability to use a third accessory input. Currently using that to select tuning roll/pitch bias and PID tuning. I also _STRONGLY_ recommend if you enable these accessory channels (and thus these features) you make the saved meta data for the StabilizationSettings and AttitudeSettings read-only, so only on flights where you mean to can you change these settings. I'm also not convinced about the interface - it seems like flicking TX switches to get into adjustments is a recipe for disaster. Probably need to just control through GCS.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1526 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-04 17:08:02 +00:00 committed by peabody124
parent 45e8131a30
commit c21d058110
12 changed files with 87 additions and 10 deletions

View File

@ -152,6 +152,12 @@ static void manualControlTask(void* parameters)
settings.ChannelMin[settings.Accessory2], settings.ChannelNeutral[settings.Accessory2] );
else
cmd.Accessory2 = 0;
if(settings.Accessory3 != MANUALCONTROLSETTINGS_ACCESSORY3_NONE)
cmd.Accessory3 = scaleChannel( cmd.Channel[settings.Accessory3], settings.ChannelMax[settings.Accessory3],
settings.ChannelMin[settings.Accessory3], settings.ChannelNeutral[settings.Accessory3] );
else
cmd.Accessory3 = 0;
// Update flight mode
@ -223,13 +229,23 @@ static void manualControlTask(void* parameters)
AttitudeDesiredSet(&attitude);
}
if( 1 ) { //TODO: Make what happens here depend on GCS
if( cmd.Accessory3 < -.5 ) { //TODO: Make what happens here depend on GCS
AttitudeSettingsData attitudeSettings;
AttitudeSettingsGet(&attitudeSettings);
// Hard coding a maximum bias of 30 for now... maybe mistake
attitudeSettings.PitchBias = cmd.Accessory1 * 30;
attitudeSettings.RollBias = cmd.Accessory2 * 30;
// Hard coding a maximum bias of 15 for now... maybe mistake
attitudeSettings.PitchBias = cmd.Accessory1 * 15;
attitudeSettings.RollBias = cmd.Accessory2 * 15;
AttitudeSettingsSet(&attitudeSettings);
} else if (cmd.Accessory3 > .9) {
// REALLY don't want to end up here accidentally. I've also saved by meta for Stabilization setting to be
// flight read only by default
StabilizationSettingsData stabSettings;
StabilizationSettingsGet(&stabSettings);
if(cmd.Accessory1 > 0)
stabSettings.PitchKp = cmd.Accessory1 * 0.05;
if(cmd.Accessory2 > 0)
stabSettings.RollKp = cmd.Accessory2 * 0.05;
StabilizationSettingsSet(&stabSettings);
}
}
}

View File

@ -41,7 +41,7 @@
#define MANUALCONTROLCOMMAND_H
// Object constants
#define MANUALCONTROLCOMMAND_OBJID 540381354U
#define MANUALCONTROLCOMMAND_OBJID 1289277596U
#define MANUALCONTROLCOMMAND_NAME "ManualControlCommand"
#define MANUALCONTROLCOMMAND_METANAME "ManualControlCommandMeta"
#define MANUALCONTROLCOMMAND_ISSINGLEINST 1
@ -79,6 +79,7 @@ typedef struct {
uint8_t FlightMode;
float Accessory1;
float Accessory2;
float Accessory3;
int16_t Channel[8];
} __attribute__((packed)) ManualControlCommandData;
@ -96,6 +97,7 @@ typedef enum { MANUALCONTROLCOMMAND_CONNECTED_FALSE=0, MANUALCONTROLCOMMAND_CONN
typedef enum { MANUALCONTROLCOMMAND_FLIGHTMODE_MANUAL=0, MANUALCONTROLCOMMAND_FLIGHTMODE_STABILIZED=1, MANUALCONTROLCOMMAND_FLIGHTMODE_AUTO=2 } ManualControlCommandFlightModeOptions;
// Field Accessory1 information
// Field Accessory2 information
// Field Accessory3 information
// Field Channel information
/* Number of elements for field Channel */
#define MANUALCONTROLCOMMAND_CHANNEL_NUMELEM 8

View File

@ -41,7 +41,7 @@
#define MANUALCONTROLSETTINGS_H
// Object constants
#define MANUALCONTROLSETTINGS_OBJID 2185031164U
#define MANUALCONTROLSETTINGS_OBJID 1845767664U
#define MANUALCONTROLSETTINGS_NAME "ManualControlSettings"
#define MANUALCONTROLSETTINGS_METANAME "ManualControlSettingsMeta"
#define MANUALCONTROLSETTINGS_ISSINGLEINST 1
@ -79,6 +79,7 @@ typedef struct {
uint8_t FlightMode;
uint8_t Accessory1;
uint8_t Accessory2;
uint8_t Accessory3;
int16_t ChannelMax[8];
int16_t ChannelNeutral[8];
int16_t ChannelMin[8];
@ -110,6 +111,9 @@ typedef enum { MANUALCONTROLSETTINGS_ACCESSORY1_CHANNEL0=0, MANUALCONTROLSETTING
// Field Accessory2 information
/* Enumeration options for field Accessory2 */
typedef enum { MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL0=0, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL1=1, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL2=2, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL3=3, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL4=4, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL5=5, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL6=6, MANUALCONTROLSETTINGS_ACCESSORY2_CHANNEL7=7, MANUALCONTROLSETTINGS_ACCESSORY2_NONE=8 } ManualControlSettingsAccessory2Options;
// Field Accessory3 information
/* Enumeration options for field Accessory3 */
typedef enum { MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL0=0, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL1=1, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL2=2, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL3=3, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL4=4, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL5=5, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL6=6, MANUALCONTROLSETTINGS_ACCESSORY3_CHANNEL7=7, MANUALCONTROLSETTINGS_ACCESSORY3_NONE=8 } ManualControlSettingsAccessory3Options;
// Field ChannelMax information
/* Number of elements for field ChannelMax */
#define MANUALCONTROLSETTINGS_CHANNELMAX_NUMELEM 8

View File

@ -88,6 +88,7 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId)
data.FlightMode = 4;
data.Accessory1 = 8;
data.Accessory2 = 8;
data.Accessory3 = 8;
data.ChannelMax[0] = 2000;
data.ChannelMax[1] = 2000;
data.ChannelMax[2] = 2000;

View File

@ -73,6 +73,9 @@ ManualControlCommand::ManualControlCommand(): UAVDataObject(OBJID, ISSINGLEINST,
QStringList Accessory2ElemNames;
Accessory2ElemNames.append("0");
fields.append( new UAVObjectField(QString("Accessory2"), QString("%"), UAVObjectField::FLOAT32, Accessory2ElemNames, QStringList()) );
QStringList Accessory3ElemNames;
Accessory3ElemNames.append("0");
fields.append( new UAVObjectField(QString("Accessory3"), QString("%"), UAVObjectField::FLOAT32, Accessory3ElemNames, QStringList()) );
QStringList ChannelElemNames;
ChannelElemNames.append("0");
ChannelElemNames.append("1");

View File

@ -51,6 +51,7 @@ public:
quint8 FlightMode;
float Accessory1;
float Accessory2;
float Accessory3;
qint16 Channel[8];
} __attribute__((packed)) DataFields;
@ -68,13 +69,14 @@ public:
typedef enum { FLIGHTMODE_MANUAL=0, FLIGHTMODE_STABILIZED=1, FLIGHTMODE_AUTO=2 } FlightModeOptions;
// Field Accessory1 information
// Field Accessory2 information
// Field Accessory3 information
// Field Channel information
/* Number of elements for field Channel */
static const quint32 CHANNEL_NUMELEM = 8;
// Constants
static const quint32 OBJID = 540381354U;
static const quint32 OBJID = 1289277596U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;

View File

@ -122,6 +122,16 @@ _fields = [ \
{
}
),
uavobject.UAVObjectField(
'Accessory3',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'Channel',
'h',
@ -144,7 +154,7 @@ _fields = [ \
class ManualControlCommand(uavobject.UAVObject):
## Object constants
OBJID = 540381354
OBJID = 1289277596
NAME = "ManualControlCommand"
METANAME = "ManualControlCommandMeta"
ISSINGLEINST = 1

View File

@ -140,6 +140,19 @@ ManualControlSettings::ManualControlSettings(): UAVDataObject(OBJID, ISSINGLEINS
Accessory2EnumOptions.append("Channel7");
Accessory2EnumOptions.append("None");
fields.append( new UAVObjectField(QString("Accessory2"), QString("channel"), UAVObjectField::ENUM, Accessory2ElemNames, Accessory2EnumOptions) );
QStringList Accessory3ElemNames;
Accessory3ElemNames.append("0");
QStringList Accessory3EnumOptions;
Accessory3EnumOptions.append("Channel0");
Accessory3EnumOptions.append("Channel1");
Accessory3EnumOptions.append("Channel2");
Accessory3EnumOptions.append("Channel3");
Accessory3EnumOptions.append("Channel4");
Accessory3EnumOptions.append("Channel5");
Accessory3EnumOptions.append("Channel6");
Accessory3EnumOptions.append("Channel7");
Accessory3EnumOptions.append("None");
fields.append( new UAVObjectField(QString("Accessory3"), QString("channel"), UAVObjectField::ENUM, Accessory3ElemNames, Accessory3EnumOptions) );
QStringList ChannelMaxElemNames;
ChannelMaxElemNames.append("0");
ChannelMaxElemNames.append("1");
@ -211,6 +224,7 @@ void ManualControlSettings::setDefaultFieldValues()
data.FlightMode = 4;
data.Accessory1 = 8;
data.Accessory2 = 8;
data.Accessory3 = 8;
data.ChannelMax[0] = 2000;
data.ChannelMax[1] = 2000;
data.ChannelMax[2] = 2000;

View File

@ -51,6 +51,7 @@ public:
quint8 FlightMode;
quint8 Accessory1;
quint8 Accessory2;
quint8 Accessory3;
qint16 ChannelMax[8];
qint16 ChannelNeutral[8];
qint16 ChannelMin[8];
@ -82,6 +83,9 @@ public:
// Field Accessory2 information
/* Enumeration options for field Accessory2 */
typedef enum { ACCESSORY2_CHANNEL0=0, ACCESSORY2_CHANNEL1=1, ACCESSORY2_CHANNEL2=2, ACCESSORY2_CHANNEL3=3, ACCESSORY2_CHANNEL4=4, ACCESSORY2_CHANNEL5=5, ACCESSORY2_CHANNEL6=6, ACCESSORY2_CHANNEL7=7, ACCESSORY2_NONE=8 } Accessory2Options;
// Field Accessory3 information
/* Enumeration options for field Accessory3 */
typedef enum { ACCESSORY3_CHANNEL0=0, ACCESSORY3_CHANNEL1=1, ACCESSORY3_CHANNEL2=2, ACCESSORY3_CHANNEL3=3, ACCESSORY3_CHANNEL4=4, ACCESSORY3_CHANNEL5=5, ACCESSORY3_CHANNEL6=6, ACCESSORY3_CHANNEL7=7, ACCESSORY3_NONE=8 } Accessory3Options;
// Field ChannelMax information
/* Number of elements for field ChannelMax */
static const quint32 CHANNELMAX_NUMELEM = 8;
@ -94,7 +98,7 @@ public:
// Constants
static const quint32 OBJID = 2185031164U;
static const quint32 OBJID = 1845767664U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 1;

View File

@ -183,6 +183,25 @@ _fields = [ \
'8' : 'None',
}
),
uavobject.UAVObjectField(
'Accessory3',
'b',
1,
[
'0',
],
{
'0' : 'Channel0',
'1' : 'Channel1',
'2' : 'Channel2',
'3' : 'Channel3',
'4' : 'Channel4',
'5' : 'Channel5',
'6' : 'Channel6',
'7' : 'Channel7',
'8' : 'None',
}
),
uavobject.UAVObjectField(
'ChannelMax',
'h',
@ -239,7 +258,7 @@ _fields = [ \
class ManualControlSettings(uavobject.UAVObject):
## Object constants
OBJID = 2185031164
OBJID = 1845767664
NAME = "ManualControlSettings"
METANAME = "ManualControlSettingsMeta"
ISSINGLEINST = 1

View File

@ -9,6 +9,7 @@
<field name="FlightMode" units="" type="enum" elements="1" options="Manual,Stabilized,Auto"/>
<field name="Accessory1" units="%" type="float" elements="1"/>
<field name="Accessory2" units="%" type="float" elements="1"/>
<field name="Accessory3" units="%" type="float" elements="1"/>
<field name="Channel" units="us" type="int16" elements="8"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>

View File

@ -9,6 +9,7 @@
<field name="FlightMode" units="channel" type="enum" elements="1" options="Channel0,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,None" defaultvalue="Channel4"/>
<field name="Accessory1" units="channel" type="enum" elements="1" options="Channel0,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,None" defaultvalue="None"/>
<field name="Accessory2" units="channel" type="enum" elements="1" options="Channel0,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,None" defaultvalue="None"/>
<field name="Accessory3" units="channel" type="enum" elements="1" options="Channel0,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,None" defaultvalue="None"/>
<field name="ChannelMax" units="us" type="int16" elements="8" defaultvalue="2000"/>
<field name="ChannelNeutral" units="us" type="int16" elements="8" defaultvalue="1500"/>
<field name="ChannelMin" units="us" type="int16" elements="8" defaultvalue="1000"/>