1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

UAVObjects/MixerSettings: Have values as int8, don't need float resolution

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1832 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-10-01 20:28:14 +00:00 committed by peabody124
parent 683aa2b480
commit 2a93f35807
9 changed files with 69 additions and 69 deletions

View File

@ -69,7 +69,7 @@ float ProcessMixer(const int index, const float curve1, const float curve2,
//this structure is equivalent to the UAVObjects for one mixer.
typedef struct {
uint8_t type;
float matrix[5];
int8_t matrix[5];
} __attribute__((packed)) Mixer_t;
@ -226,11 +226,11 @@ float ProcessMixer(const int index, const float curve1, const float curve2,
static float filterAccumulator[MAX_MIX_ACTUATORS]={0,0,0,0,0,0,0,0};
Mixer_t * mixers = (Mixer_t *)&mixerSettings->Mixer0Type; //pointer to array of mixers in UAVObjects
Mixer_t * mixer = &mixers[index];
float result = (mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_THROTTLECURVE1] * curve1) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_THROTTLECURVE2] * curve2) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_ROLL] * desired->Roll) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_PITCH] * desired->Pitch) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_YAW] * desired->Yaw);
float result = (mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_THROTTLECURVE1] / 128.0f * curve1) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_THROTTLECURVE2] / 128.0f * curve2) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_ROLL] / 128.0f * desired->Roll) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_PITCH] / 128.0f * desired->Pitch) +
(mixer->matrix[MIXERSETTINGS_MIXER0VECTOR_YAW] / 128.0f * desired->Yaw);
if(mixer->type == MIXERSETTINGS_MIXER0TYPE_MOTOR)
{
if(result < 0) //idle throttle

View File

@ -41,7 +41,7 @@
#define MIXERSETTINGS_H
// Object constants
#define MIXERSETTINGS_OBJID 3818217990U
#define MIXERSETTINGS_OBJID 1945801048U
#define MIXERSETTINGS_NAME "MixerSettings"
#define MIXERSETTINGS_METANAME "MixerSettingsMeta"
#define MIXERSETTINGS_ISSINGLEINST 1
@ -78,21 +78,21 @@ typedef struct {
float ThrottleCurve1[5];
float ThrottleCurve2[5];
uint8_t Mixer0Type;
float Mixer0Vector[5];
int8_t Mixer0Vector[5];
uint8_t Mixer1Type;
float Mixer1Vector[5];
int8_t Mixer1Vector[5];
uint8_t Mixer2Type;
float Mixer2Vector[5];
int8_t Mixer2Vector[5];
uint8_t Mixer3Type;
float Mixer3Vector[5];
int8_t Mixer3Vector[5];
uint8_t Mixer4Type;
float Mixer4Vector[5];
int8_t Mixer4Vector[5];
uint8_t Mixer5Type;
float Mixer5Vector[5];
int8_t Mixer5Vector[5];
uint8_t Mixer6Type;
float Mixer6Vector[5];
int8_t Mixer6Vector[5];
uint8_t Mixer7Type;
float Mixer7Vector[5];
int8_t Mixer7Vector[5];
} __attribute__((packed)) MixerSettingsData;

View File

@ -910,13 +910,13 @@ void ConfigAirframeWidget::setupQuadMotor(int channel, double pitch, double roll
// First of all reset the vector
resetField(field);
int ti = field->getElementNames().indexOf("ThrottleCurve1");
field->setValue(1, ti);
field->setValue(127, ti);
ti = field->getElementNames().indexOf("Roll");
field->setValue(roll,ti);
field->setValue(roll*127,ti);
ti = field->getElementNames().indexOf("Pitch");
field->setValue(pitch,ti);
field->setValue(pitch*127,ti);
ti = field->getElementNames().indexOf("Yaw");
field->setValue(yaw,ti);
field->setValue(yaw*127,ti);
}
/**

View File

@ -81,7 +81,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer0VectorElemNames.append("Roll");
Mixer0VectorElemNames.append("Pitch");
Mixer0VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer0Vector"), QString(""), UAVObjectField::FLOAT32, Mixer0VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer0Vector"), QString(""), UAVObjectField::INT8, Mixer0VectorElemNames, QStringList()) );
QStringList Mixer1TypeElemNames;
Mixer1TypeElemNames.append("0");
QStringList Mixer1TypeEnumOptions;
@ -95,7 +95,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer1VectorElemNames.append("Roll");
Mixer1VectorElemNames.append("Pitch");
Mixer1VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer1Vector"), QString(""), UAVObjectField::FLOAT32, Mixer1VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer1Vector"), QString(""), UAVObjectField::INT8, Mixer1VectorElemNames, QStringList()) );
QStringList Mixer2TypeElemNames;
Mixer2TypeElemNames.append("0");
QStringList Mixer2TypeEnumOptions;
@ -109,7 +109,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer2VectorElemNames.append("Roll");
Mixer2VectorElemNames.append("Pitch");
Mixer2VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer2Vector"), QString(""), UAVObjectField::FLOAT32, Mixer2VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer2Vector"), QString(""), UAVObjectField::INT8, Mixer2VectorElemNames, QStringList()) );
QStringList Mixer3TypeElemNames;
Mixer3TypeElemNames.append("0");
QStringList Mixer3TypeEnumOptions;
@ -123,7 +123,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer3VectorElemNames.append("Roll");
Mixer3VectorElemNames.append("Pitch");
Mixer3VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer3Vector"), QString(""), UAVObjectField::FLOAT32, Mixer3VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer3Vector"), QString(""), UAVObjectField::INT8, Mixer3VectorElemNames, QStringList()) );
QStringList Mixer4TypeElemNames;
Mixer4TypeElemNames.append("0");
QStringList Mixer4TypeEnumOptions;
@ -137,7 +137,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer4VectorElemNames.append("Roll");
Mixer4VectorElemNames.append("Pitch");
Mixer4VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer4Vector"), QString(""), UAVObjectField::FLOAT32, Mixer4VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer4Vector"), QString(""), UAVObjectField::INT8, Mixer4VectorElemNames, QStringList()) );
QStringList Mixer5TypeElemNames;
Mixer5TypeElemNames.append("0");
QStringList Mixer5TypeEnumOptions;
@ -151,7 +151,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer5VectorElemNames.append("Roll");
Mixer5VectorElemNames.append("Pitch");
Mixer5VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer5Vector"), QString(""), UAVObjectField::FLOAT32, Mixer5VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer5Vector"), QString(""), UAVObjectField::INT8, Mixer5VectorElemNames, QStringList()) );
QStringList Mixer6TypeElemNames;
Mixer6TypeElemNames.append("0");
QStringList Mixer6TypeEnumOptions;
@ -165,7 +165,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer6VectorElemNames.append("Roll");
Mixer6VectorElemNames.append("Pitch");
Mixer6VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer6Vector"), QString(""), UAVObjectField::FLOAT32, Mixer6VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer6Vector"), QString(""), UAVObjectField::INT8, Mixer6VectorElemNames, QStringList()) );
QStringList Mixer7TypeElemNames;
Mixer7TypeElemNames.append("0");
QStringList Mixer7TypeEnumOptions;
@ -179,7 +179,7 @@ MixerSettings::MixerSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
Mixer7VectorElemNames.append("Roll");
Mixer7VectorElemNames.append("Pitch");
Mixer7VectorElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("Mixer7Vector"), QString(""), UAVObjectField::FLOAT32, Mixer7VectorElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer7Vector"), QString(""), UAVObjectField::INT8, Mixer7VectorElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);

View File

@ -50,21 +50,21 @@ public:
float ThrottleCurve1[5];
float ThrottleCurve2[5];
quint8 Mixer0Type;
float Mixer0Vector[5];
qint8 Mixer0Vector[5];
quint8 Mixer1Type;
float Mixer1Vector[5];
qint8 Mixer1Vector[5];
quint8 Mixer2Type;
float Mixer2Vector[5];
qint8 Mixer2Vector[5];
quint8 Mixer3Type;
float Mixer3Vector[5];
qint8 Mixer3Vector[5];
quint8 Mixer4Type;
float Mixer4Vector[5];
qint8 Mixer4Vector[5];
quint8 Mixer5Type;
float Mixer5Vector[5];
qint8 Mixer5Vector[5];
quint8 Mixer6Type;
float Mixer6Vector[5];
qint8 Mixer6Vector[5];
quint8 Mixer7Type;
float Mixer7Vector[5];
qint8 Mixer7Vector[5];
} __attribute__((packed)) DataFields;
@ -150,7 +150,7 @@ public:
// Constants
static const quint32 OBJID = 3818217990U;
static const quint32 OBJID = 1945801048U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 1;

View File

@ -120,7 +120,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer0Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -147,7 +147,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer1Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -174,7 +174,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer2Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -201,7 +201,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer3Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -228,7 +228,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer4Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -255,7 +255,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer5Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -282,7 +282,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer6Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -309,7 +309,7 @@ _fields = [ \
),
uavobject.UAVObjectField(
'Mixer7Vector',
'f',
'b',
5,
[
'ThrottleCurve1',
@ -326,7 +326,7 @@ _fields = [ \
class MixerSettings(uavobject.UAVObject):
## Object constants
OBJID = 3818217990
OBJID = 1945801048
NAME = "MixerSettings"
METANAME = "MixerSettingsMeta"
ISSINGLEINST = 1

View File

@ -44,28 +44,28 @@ MixerStatus::MixerStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
QList<UAVObjectField*> fields;
QStringList Mixer0ElemNames;
Mixer0ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer0"), QString("us"), UAVObjectField::FLOAT32, Mixer0ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer0"), QString(""), UAVObjectField::FLOAT32, Mixer0ElemNames, QStringList()) );
QStringList Mixer1ElemNames;
Mixer1ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer1"), QString("us"), UAVObjectField::FLOAT32, Mixer1ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer1"), QString(""), UAVObjectField::FLOAT32, Mixer1ElemNames, QStringList()) );
QStringList Mixer2ElemNames;
Mixer2ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer2"), QString("us"), UAVObjectField::FLOAT32, Mixer2ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer2"), QString(""), UAVObjectField::FLOAT32, Mixer2ElemNames, QStringList()) );
QStringList Mixer3ElemNames;
Mixer3ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer3"), QString("us"), UAVObjectField::FLOAT32, Mixer3ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer3"), QString(""), UAVObjectField::FLOAT32, Mixer3ElemNames, QStringList()) );
QStringList Mixer4ElemNames;
Mixer4ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer4"), QString("us"), UAVObjectField::FLOAT32, Mixer4ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer4"), QString(""), UAVObjectField::FLOAT32, Mixer4ElemNames, QStringList()) );
QStringList Mixer5ElemNames;
Mixer5ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer5"), QString("us"), UAVObjectField::FLOAT32, Mixer5ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer5"), QString(""), UAVObjectField::FLOAT32, Mixer5ElemNames, QStringList()) );
QStringList Mixer6ElemNames;
Mixer6ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer6"), QString("us"), UAVObjectField::FLOAT32, Mixer6ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer6"), QString(""), UAVObjectField::FLOAT32, Mixer6ElemNames, QStringList()) );
QStringList Mixer7ElemNames;
Mixer7ElemNames.append("0");
fields.append( new UAVObjectField(QString("Mixer7"), QString("us"), UAVObjectField::FLOAT32, Mixer7ElemNames, QStringList()) );
fields.append( new UAVObjectField(QString("Mixer7"), QString(""), UAVObjectField::FLOAT32, Mixer7ElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);

View File

@ -8,21 +8,21 @@
<field name="ThrottleCurve1" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="-10"/>
<field name="ThrottleCurve2" units="percent" type="float" elements="5" elementnames="0,25,50,75,100" defaultvalue="-10"/>
<field name="Mixer0Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
<field name="Mixer0Vector" units="" type="float" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
<field name="Mixer0Vector" units="" type="int8" elements="5" elementnames="ThrottleCurve1,ThrottleCurve2,Roll,Pitch,Yaw" defaultvalue="0"/>
<field name="Mixer1Type" units="" type="enum" elements="1" options="Disabled,Motor,Servo" defaultvalue="Disabled"/>
<field name="Mixer1Vector" units="" type="float" 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="Mixer2Vector" units="" type="float" 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="Mixer3Vector" units="" type="float" 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="Mixer4Vector" units="" type="float" 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="Mixer5Vector" units="" type="float" 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="Mixer6Vector" units="" type="float" 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="Mixer7Vector" units="" type="float" 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"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>

View File

@ -1,14 +1,14 @@
<xml>
<object name="MixerStatus" singleinstance="true" settings="false">
<description>Status for the matrix mixer showing the output of each mixer after all scaling</description>
<field name="Mixer0" units="us" type="float" elements="1"/>
<field name="Mixer1" units="us" type="float" elements="1"/>
<field name="Mixer2" units="us" type="float" elements="1"/>
<field name="Mixer3" units="us" type="float" elements="1"/>
<field name="Mixer4" units="us" type="float" elements="1"/>
<field name="Mixer5" units="us" type="float" elements="1"/>
<field name="Mixer6" units="us" type="float" elements="1"/>
<field name="Mixer7" units="us" type="float" elements="1"/>
<field name="Mixer0" units="" type="float" elements="1"/>
<field name="Mixer1" units="" type="float" elements="1"/>
<field name="Mixer2" units="" type="float" elements="1"/>
<field name="Mixer3" units="" type="float" elements="1"/>
<field name="Mixer4" units="" type="float" elements="1"/>
<field name="Mixer5" units="" type="float" elements="1"/>
<field name="Mixer6" units="" type="float" elements="1"/>
<field name="Mixer7" units="" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="1000"/>