From 2a93f358073bd2ef245a3ef63006a442712a990d Mon Sep 17 00:00:00 2001 From: peabody124 Date: Fri, 1 Oct 2010 20:28:14 +0000 Subject: [PATCH] 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 --- flight/OpenPilot/Modules/Actuator/actuator.c | 12 ++++++------ .../OpenPilot/UAVObjects/inc/mixersettings.h | 18 +++++++++--------- .../plugins/config/configairframewidget.cpp | 8 ++++---- .../src/plugins/uavobjects/mixersettings.cpp | 16 ++++++++-------- ground/src/plugins/uavobjects/mixersettings.h | 18 +++++++++--------- ground/src/plugins/uavobjects/mixersettings.py | 18 +++++++++--------- ground/src/plugins/uavobjects/mixerstatus.cpp | 16 ++++++++-------- .../uavobjectdefinition/mixersettings.xml | 16 ++++++++-------- .../shared/uavobjectdefinition/mixerstatus.xml | 16 ++++++++-------- 9 files changed, 69 insertions(+), 69 deletions(-) diff --git a/flight/OpenPilot/Modules/Actuator/actuator.c b/flight/OpenPilot/Modules/Actuator/actuator.c index 5798ec26f..732a2dff6 100644 --- a/flight/OpenPilot/Modules/Actuator/actuator.c +++ b/flight/OpenPilot/Modules/Actuator/actuator.c @@ -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 diff --git a/flight/OpenPilot/UAVObjects/inc/mixersettings.h b/flight/OpenPilot/UAVObjects/inc/mixersettings.h index b488c361c..6d4af05fb 100644 --- a/flight/OpenPilot/UAVObjects/inc/mixersettings.h +++ b/flight/OpenPilot/UAVObjects/inc/mixersettings.h @@ -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; diff --git a/ground/src/plugins/config/configairframewidget.cpp b/ground/src/plugins/config/configairframewidget.cpp index 98db3fb01..59eef7807 100644 --- a/ground/src/plugins/config/configairframewidget.cpp +++ b/ground/src/plugins/config/configairframewidget.cpp @@ -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); } /** diff --git a/ground/src/plugins/uavobjects/mixersettings.cpp b/ground/src/plugins/uavobjects/mixersettings.cpp index 405351aae..9eeb85a45 100644 --- a/ground/src/plugins/uavobjects/mixersettings.cpp +++ b/ground/src/plugins/uavobjects/mixersettings.cpp @@ -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); diff --git a/ground/src/plugins/uavobjects/mixersettings.h b/ground/src/plugins/uavobjects/mixersettings.h index 19e789181..05bea39cc 100644 --- a/ground/src/plugins/uavobjects/mixersettings.h +++ b/ground/src/plugins/uavobjects/mixersettings.h @@ -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; diff --git a/ground/src/plugins/uavobjects/mixersettings.py b/ground/src/plugins/uavobjects/mixersettings.py index cd76141c0..90a377a07 100644 --- a/ground/src/plugins/uavobjects/mixersettings.py +++ b/ground/src/plugins/uavobjects/mixersettings.py @@ -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 diff --git a/ground/src/plugins/uavobjects/mixerstatus.cpp b/ground/src/plugins/uavobjects/mixerstatus.cpp index 548972c62..677963f36 100644 --- a/ground/src/plugins/uavobjects/mixerstatus.cpp +++ b/ground/src/plugins/uavobjects/mixerstatus.cpp @@ -44,28 +44,28 @@ MixerStatus::MixerStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) QList 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); diff --git a/ground/src/shared/uavobjectdefinition/mixersettings.xml b/ground/src/shared/uavobjectdefinition/mixersettings.xml index 2b71d7286..8d537e3a8 100644 --- a/ground/src/shared/uavobjectdefinition/mixersettings.xml +++ b/ground/src/shared/uavobjectdefinition/mixersettings.xml @@ -8,21 +8,21 @@ - + - + - + - + - + - + - + - + diff --git a/ground/src/shared/uavobjectdefinition/mixerstatus.xml b/ground/src/shared/uavobjectdefinition/mixerstatus.xml index 7ed04e486..d87ba1a11 100644 --- a/ground/src/shared/uavobjectdefinition/mixerstatus.xml +++ b/ground/src/shared/uavobjectdefinition/mixerstatus.xml @@ -1,14 +1,14 @@ Status for the matrix mixer showing the output of each mixer after all scaling - - - - - - - - + + + + + + + +