From c066fdc5e66cf2bc564bec10703f071685c97a59 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 9 May 2012 15:24:15 -0700 Subject: [PATCH 01/15] add support for output channel assignment descriptions for helicp --- .../src/plugins/config/configoutputwidget.cpp | 165 ++++++++++++++---- .../src/plugins/config/configoutputwidget.h | 4 +- 2 files changed, 131 insertions(+), 38 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index 718965f7d..ab2419f54 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -39,9 +39,11 @@ #include #include #include +#include "mixersettings.h" #include "actuatorcommand.h" #include "actuatorsettings.h" #include "systemalarms.h" +#include "systemsettings.h" #include "uavsettingsimportexport/uavsettingsimportexportfactory.h" ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent),wasItMe(false) @@ -56,9 +58,6 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren UAVSettingsImportExportFactory * importexportplugin = pm->getObject(); connect(importexportplugin,SIGNAL(importAboutToBegin()),this,SLOT(stopTests())); - addApplySaveButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD); - addUAVObject("ActuatorSettings"); - // NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10. // Register for ActuatorSettings changes: for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) @@ -246,33 +245,50 @@ void ConfigOutputWidget::refreshWidgetsValues() { bool dirty=isDirty(); - // Reset all channel assignements: - QList outputChannelForms = findChildren(); - foreach(OutputChannelForm *outputChannelForm, outputChannelForms) - { - outputChannelForm->setAssignment("-"); - } - - // FIXME: Use static accessor method for retrieving channel assignments - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Q_ASSERT(pm); - UAVObjectManager *objManager = pm->getObject(); - Q_ASSERT(objManager); - - // Get the channel assignements: - UAVDataObject * obj = dynamic_cast(objManager->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - QList fieldList = obj->getFields(); - foreach (UAVObjectField* field, fieldList) { - if (field->getUnits().contains("channel")) { - assignOutputChannel(obj,field->getName()); - } - } + // Get System Settings + SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + // Get Actuator Settings ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager()); Q_ASSERT(actuatorSettings); ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); + // get helicp channel descriptions based on mixer settings + QStringList heliChannelDesc = getChannelDescriptions(); + + // Initialize output forms + QList outputChannelForms = findChildren(); + foreach(OutputChannelForm *outputChannelForm, outputChannelForms) + { + // init channel description + if (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_HELICP) + outputChannelForm->setAssignment(heliChannelDesc[outputChannelForm->index()]); + else + outputChannelForm->setAssignment("-"); + + // init min,max,neutral + int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()]; + int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()]; + outputChannelForm->minmax(minValue, maxValue); + + int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()]; + outputChannelForm->neutral(neutral); + } + + // non-helicp channel descriptions + if (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_HELICP) + { + // get channel descriptions based on units=channel and fieldname + QList fieldList = actuatorSettings->getFields(); + foreach (UAVObjectField* field, fieldList) { + if (field->getUnits().contains("channel")) { + assignOutputChannel(actuatorSettings,field->getName()); + } + } + } + // Get the SpinWhileArmed setting m_config->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE); @@ -288,6 +304,8 @@ void ConfigOutputWidget::refreshWidgetsValues() m_config->cb_outputRate1->setCurrentIndex(m_config->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]))); m_config->cb_outputRate2->setCurrentIndex(m_config->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]))); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + Q_ASSERT(pm); UAVObjectUtilManager* utilMngr = pm->getObject(); if (utilMngr) { int board = utilMngr->getBoardModel(); @@ -328,17 +346,6 @@ void ConfigOutputWidget::refreshWidgetsValues() } } - // Get Channel ranges: - foreach(OutputChannelForm *outputChannelForm, outputChannelForms) - { - int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()]; - int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()]; - outputChannelForm->minmax(minValue, maxValue); - - int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()]; - outputChannelForm->neutral(neutral); - } - setDirty(dirty); } @@ -368,6 +375,92 @@ void ConfigOutputWidget::updateObjectsFromWidgets() // Apply settings actuatorSettings->setData(actuatorSettingsData); } +QStringList ConfigOutputWidget::getChannelDescriptions() +{ + QStringList channelDesc; + int MixerDataFromHeli[8][5]; + quint8 MixerOutputType[8]; + int i; + + // Get existing mixer settings + MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); + Q_ASSERT(mixerSettings); + MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); + + //go through the user data and update the mixer matrix + for (i=0;i<5;i++) + { + MixerDataFromHeli[0][i] = mixerSettingsData.Mixer1Vector[i]; + MixerDataFromHeli[1][i] = mixerSettingsData.Mixer2Vector[i]; + MixerDataFromHeli[2][i] = mixerSettingsData.Mixer3Vector[i]; + MixerDataFromHeli[3][i] = mixerSettingsData.Mixer4Vector[i]; + MixerDataFromHeli[4][i] = mixerSettingsData.Mixer5Vector[i]; + MixerDataFromHeli[5][i] = mixerSettingsData.Mixer6Vector[i]; + MixerDataFromHeli[6][i] = mixerSettingsData.Mixer7Vector[i]; + MixerDataFromHeli[7][i] = mixerSettingsData.Mixer8Vector[i]; + } + + MixerOutputType[0] = mixerSettingsData.Mixer1Type; + MixerOutputType[1] = mixerSettingsData.Mixer2Type; + MixerOutputType[2] = mixerSettingsData.Mixer3Type; + MixerOutputType[3] = mixerSettingsData.Mixer4Type; + MixerOutputType[4] = mixerSettingsData.Mixer5Type; + MixerOutputType[5] = mixerSettingsData.Mixer6Type; + MixerOutputType[6] = mixerSettingsData.Mixer7Type; + MixerOutputType[7] = mixerSettingsData.Mixer8Type; + + for (i=1; i <= (int)(ActuatorCommand::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + //process the data from the mixer and try to figure out the settings... + for (i=0;i<8;i++) + { + //check if this is the engine... Throttle only + if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_MOTOR)&& + (MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1 + (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 + (MixerDataFromHeli[i][2]==0)&&//Roll + (MixerDataFromHeli[i][3]==0)&&//Pitch + (MixerDataFromHeli[i][4]==0))//Yaw + { + channelDesc[i] = "Throttle"; + } + else if ((MixerDataFromHeli[i][0]>0)&& //ThrottleCurve1 + (MixerDataFromHeli[i][2]!=0)&&//Roll + (MixerDataFromHeli[i][3]!=0)) //Pitch + { + channelDesc[i] = "Collective"; + } + //check if this is the tail servo... + else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& + (MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1 + (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 + (MixerDataFromHeli[i][2]==0)&&//Roll + (MixerDataFromHeli[i][3]==0)&&//Pitch + (MixerDataFromHeli[i][4]>0))//Yaw + { + channelDesc[i] = "Tail"; + } + //check if this is the elevator servo... + else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& + (MixerDataFromHeli[i][2]==0)&&//Roll + (MixerDataFromHeli[i][3]!=0))//Pitch + { + channelDesc[i] = "Elevator"; + } + //check if this is a swashplate servo... + else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& + (MixerDataFromHeli[i][2]!=0))//Roll + { + channelDesc[i] = QString("%1%2").arg("Roll").arg(i); + } + + } + + return channelDesc; +} void ConfigOutputWidget::openHelp() { diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index b20839aa4..1571792af 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -57,8 +57,8 @@ private: void assignChannel(UAVDataObject *obj, QString str); void assignOutputChannel(UAVDataObject *obj, QString str); - OutputChannelForm* getOutputChannelForm(const int index) const; - + OutputChannelForm* getOutputChannelForm(const int index) const; + QStringList getChannelDescriptions(); int mccDataRate; UAVObject::Metadata accInitialData; From 3a3dc4b888837d63f9a50e8faf13837a4c82f73e Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Fri, 11 May 2012 21:48:46 -0700 Subject: [PATCH 02/15] extend GUIConfigData to support all vehicle types; add GUIConfigDataManager class to get/set --- .../config/cfg_vehicletypes/guiconfigdata.cpp | 213 ++++++++++++++++++ .../config/cfg_vehicletypes/guiconfigdata.h | 131 +++++++++++ .../src/plugins/config/config.pro | 6 +- 3 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp new file mode 100644 index 000000000..43630d4ae --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp @@ -0,0 +1,213 @@ + +/** + ****************************************************************************** + * + * @file guiconfigdata.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief bit storage of config ui settings + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "guiconfigdata.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" + +#include "systemsettings.h" + +#include + +GUIConfigDataManager::GUIConfigDataManager() +{ +} + +GUIConfigDataManager::~GUIConfigDataManager() +{ + // Do nothing +} + +GUIConfigDataUnion GUIConfigDataManager::GetConfigData() { + + int i; + GUIConfigDataUnion configData; + + // get an instance of systemsettings + SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + // copy systemsettings -> local configData + for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) + configData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; + + // sanity check + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == + (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + + return configData; +} + +void GUIConfigDataManager::SetConfigData(GUIConfigDataUnion configData) { + + int i; + + // sanity check + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == + (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + + // get an instance of systemsettings + SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + // copy parameter configData -> systemsettings + for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) + systemSettingsData.GUIConfigData[i] = configData.UAVObject[i]; + + systemSettings->setData(systemSettingsData); + systemSettings->updated(); +} + +QStringList GUIConfigDataManager::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(GUIConfigDataManager::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + // get systemsettings for airframe type + SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + switch (systemSettingsData.AirframeType) + { + // fixed wing + case SystemSettings::AIRFRAMETYPE_FIXEDWING: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: + { + if (configData.fixed.FixedWingPitch1 > 0) + channelDesc[configData.fixed.FixedWingPitch1-1] = QString("FixedWingPitch1"); + if (configData.fixed.FixedWingPitch2 > 0) + channelDesc[configData.fixed.FixedWingPitch2-1] = QString("FixedWingPitch2"); + if (configData.fixed.FixedWingRoll1 > 0) + channelDesc[configData.fixed.FixedWingRoll1-1] = QString("FixedWingRoll1"); + if (configData.fixed.FixedWingRoll2 > 0) + channelDesc[configData.fixed.FixedWingRoll2-1] = QString("FixedWingRoll2"); + if (configData.fixed.FixedWingYaw1 > 0) + channelDesc[configData.fixed.FixedWingYaw1-1] = QString("FixedWingYaw1"); + if (configData.fixed.FixedWingYaw2 > 0) + channelDesc[configData.fixed.FixedWingYaw2-1] = QString("FixedWingYaw2"); + if (configData.fixed.FixedWingThrottle > 0) + channelDesc[configData.fixed.FixedWingThrottle-1] = QString("FixedWingThrottle"); + + return channelDesc; + } + break; + + // helicp + case SystemSettings::AIRFRAMETYPE_HELICP: + { + channelDesc[configData.heli.Throttle] = QString("Throttle"); + channelDesc[configData.heli.Tail] = QString("Tail"); + + switch(configData.heli.FirstServoIndex) + { + case 0: //front + channelDesc[configData.heli.ServoIndexW] = QString("Elevator"); + channelDesc[configData.heli.ServoIndexX] = QString("Roll1"); + channelDesc[configData.heli.ServoIndexY] = QString("Roll2"); + break; + + case 1: //right + channelDesc[configData.heli.ServoIndexW] = QString("ServoW"); + channelDesc[configData.heli.ServoIndexX] = QString("ServoX"); + channelDesc[configData.heli.ServoIndexY] = QString("ServoY"); + break; + + case 2: //rear + channelDesc[configData.heli.ServoIndexW] = QString("Elevator"); + channelDesc[configData.heli.ServoIndexX] = QString("Roll1"); + channelDesc[configData.heli.ServoIndexY] = QString("Roll2"); + break; + + case 3: //left + channelDesc[configData.heli.ServoIndexW] = QString("ServoW"); + channelDesc[configData.heli.ServoIndexX] = QString("ServoX"); + channelDesc[configData.heli.ServoIndexY] = QString("ServoY"); + break; + + } + if (configData.heli.ServoIndexZ < 8) + channelDesc[configData.heli.ServoIndexZ] = QString("ServoZ"); + + return channelDesc; + } + break; + + //multirotor + case SystemSettings::AIRFRAMETYPE_VTOL: + case SystemSettings::AIRFRAMETYPE_TRI: + case SystemSettings::AIRFRAMETYPE_QUADX: + case SystemSettings::AIRFRAMETYPE_QUADP: + case SystemSettings::AIRFRAMETYPE_OCTOV: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: + case SystemSettings::AIRFRAMETYPE_OCTO: + case SystemSettings::AIRFRAMETYPE_HEXAX: + case SystemSettings::AIRFRAMETYPE_HEXACOAX: + case SystemSettings::AIRFRAMETYPE_HEXA: + { + channelDesc[configData.multi.VTOLMotorN] = QString("VTOLMotorN"); + channelDesc[configData.multi.VTOLMotorNE] = QString("VTOLMotorNE"); + channelDesc[configData.multi.VTOLMotorNW] = QString("VTOLMotorNW"); + channelDesc[configData.multi.VTOLMotorS] = QString("VTOLMotorS"); + channelDesc[configData.multi.VTOLMotorSE] = QString("VTOLMotorSE"); + channelDesc[configData.multi.VTOLMotorSW] = QString("VTOLMotorSW"); + channelDesc[configData.multi.VTOLMotorW] = QString("VTOLMotorW"); + channelDesc[configData.multi.VTOLMotorE] = QString("VTOLMotorE"); + return channelDesc; + } + break; + + // ground + + } + + return channelDesc; +} +/** + * Util function to get a pointer to the object manager + * @return pointer to the UAVObjectManager + */ +UAVObjectManager* GUIConfigDataManager::getObjectManager() { + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager * objMngr = pm->getObject(); + Q_ASSERT(objMngr); + return objMngr; +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h new file mode 100644 index 000000000..287bfcb67 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h @@ -0,0 +1,131 @@ +/** + ****************************************************************************** + * + * @file guiconfigdata.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief bit storage of config ui settings + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef GUICONFIGDATA_H +#define GUICONFIGDATA_H + + +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" + +typedef struct { + uint VTOLMotorN:4; + uint VTOLMotorS:4; + uint VTOLMotorE:4; + uint VTOLMotorW:4; + uint VTOLMotorNW:4; + uint VTOLMotorNE:4; + uint VTOLMotorSW:4; + uint VTOLMotorSE:4; //32bits + uint TRIYaw:4; + quint32 padding:28; //64bits + quint32 padding1; + quint32 padding2; //128bits +} __attribute__((packed)) multiGUISettingsStruct; + +typedef struct { + uint SwasplateType:3; + uint FirstServoIndex:2; + uint CorrectionAngle:9; + uint ccpmCollectivePassthroughState:1; + uint ccpmLinkCyclicState:1; + uint ccpmLinkRollState:1; + uint SliderValue0:7; + uint SliderValue1:7; + uint SliderValue2:7;//41bits + uint ServoIndexW:4; + uint ServoIndexX:4; + uint ServoIndexY:4; + uint ServoIndexZ:4;//57bits + uint Throttle:4; + uint Tail:4; //65bits + quint32 padding:31; //96bits + quint32 padding1; //128bits +} __attribute__((packed)) heliGUISettingsStruct; + +typedef struct { + uint FixedWingThrottle:4; + uint FixedWingRoll1:4; + uint FixedWingRoll2:4; + uint FixedWingPitch1:4; + uint FixedWingPitch2:4; + uint FixedWingYaw1:4; + uint FixedWingYaw2:4; + uint padding:4; //32bits + quint32 padding1; + quint32 padding2; + quint32 padding3; //128bits +} __attribute__((packed)) fixedGUISettingsStruct; + +typedef struct { + uint GroundVehicleThrottle1:4; + uint GroundVehicleThrottle2:4; + uint GroundVehicleSteering1:4; + uint GroundVehicleSteering2:4; + uint padding:16; //32bits + quint32 padding1; + quint32 padding2; + quint32 padding3; //128bits +} __attribute__((packed)) groundGUISettingsStruct; + +typedef union +{ + uint UAVObject[4]; //32bits * 4 + heliGUISettingsStruct heli; //128bits + fixedGUISettingsStruct fixed; + multiGUISettingsStruct multi; + groundGUISettingsStruct ground; +} GUIConfigDataUnion; + +class GUIConfigDataManager: public QObject +{ + Q_OBJECT + + public: + GUIConfigDataManager(); + ~GUIConfigDataManager(); + + static const quint32 CHANNEL_NUMELEM = 10; + + friend class ConfigTaskWidget; + + private: + + + private slots: + UAVObjectManager* getObjectManager(); + + public slots: + GUIConfigDataUnion GetConfigData(); + void SetConfigData(GUIConfigDataUnion configData); + QStringList getChannelDescriptions(); + +protected: + +}; + +#endif // GUICONFIGDATA_H diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 52a2b394a..c90640517 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -31,7 +31,8 @@ HEADERS += configplugin.h \ configcamerastabilizationwidget.h \ configtxpidwidget.h \ outputchannelform.h \ - config_global.h + config_global.h \ + cfg_vehicletypes/guiconfigdata.h SOURCES += configplugin.cpp \ configgadgetconfiguration.cpp \ configgadgetwidget.cpp \ @@ -60,7 +61,8 @@ SOURCES += configplugin.cpp \ cfg_vehicletypes/configgroundvehiclewidget.cpp \ cfg_vehicletypes/configfixedwingwidget.cpp \ cfg_vehicletypes/configccpmwidget.cpp \ - outputchannelform.cpp + outputchannelform.cpp \ + cfg_vehicletypes/guiconfigdata.cpp FORMS += airframe.ui \ cc_hw_settings.ui \ pro_hw_settings.ui \ From 5e07e742ef3a82e50adbac3fd433f2a9c889e9b5 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Fri, 11 May 2012 21:53:02 -0700 Subject: [PATCH 03/15] revised to use GUIConfigManager.GetChannelDescriptions --- .../src/plugins/config/configoutputwidget.cpp | 111 +----------------- .../src/plugins/config/configoutputwidget.h | 4 +- 2 files changed, 5 insertions(+), 110 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index ab2419f54..48e7f487c 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -245,28 +245,19 @@ void ConfigOutputWidget::refreshWidgetsValues() { bool dirty=isDirty(); - // Get System Settings - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - // Get Actuator Settings ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager()); Q_ASSERT(actuatorSettings); ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); // get helicp channel descriptions based on mixer settings - QStringList heliChannelDesc = getChannelDescriptions(); + QStringList ChannelDesc = GUIManager.getChannelDescriptions(); // Initialize output forms QList outputChannelForms = findChildren(); foreach(OutputChannelForm *outputChannelForm, outputChannelForms) { - // init channel description - if (systemSettingsData.AirframeType == SystemSettings::AIRFRAMETYPE_HELICP) - outputChannelForm->setAssignment(heliChannelDesc[outputChannelForm->index()]); - else - outputChannelForm->setAssignment("-"); + outputChannelForm->setAssignment(ChannelDesc[outputChannelForm->index()]); // init min,max,neutral int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()]; @@ -277,18 +268,6 @@ void ConfigOutputWidget::refreshWidgetsValues() outputChannelForm->neutral(neutral); } - // non-helicp channel descriptions - if (systemSettingsData.AirframeType != SystemSettings::AIRFRAMETYPE_HELICP) - { - // get channel descriptions based on units=channel and fieldname - QList fieldList = actuatorSettings->getFields(); - foreach (UAVObjectField* field, fieldList) { - if (field->getUnits().contains("channel")) { - assignOutputChannel(actuatorSettings,field->getName()); - } - } - } - // Get the SpinWhileArmed setting m_config->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE); @@ -375,92 +354,6 @@ void ConfigOutputWidget::updateObjectsFromWidgets() // Apply settings actuatorSettings->setData(actuatorSettingsData); } -QStringList ConfigOutputWidget::getChannelDescriptions() -{ - QStringList channelDesc; - int MixerDataFromHeli[8][5]; - quint8 MixerOutputType[8]; - int i; - - // Get existing mixer settings - MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); - Q_ASSERT(mixerSettings); - MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); - - //go through the user data and update the mixer matrix - for (i=0;i<5;i++) - { - MixerDataFromHeli[0][i] = mixerSettingsData.Mixer1Vector[i]; - MixerDataFromHeli[1][i] = mixerSettingsData.Mixer2Vector[i]; - MixerDataFromHeli[2][i] = mixerSettingsData.Mixer3Vector[i]; - MixerDataFromHeli[3][i] = mixerSettingsData.Mixer4Vector[i]; - MixerDataFromHeli[4][i] = mixerSettingsData.Mixer5Vector[i]; - MixerDataFromHeli[5][i] = mixerSettingsData.Mixer6Vector[i]; - MixerDataFromHeli[6][i] = mixerSettingsData.Mixer7Vector[i]; - MixerDataFromHeli[7][i] = mixerSettingsData.Mixer8Vector[i]; - } - - MixerOutputType[0] = mixerSettingsData.Mixer1Type; - MixerOutputType[1] = mixerSettingsData.Mixer2Type; - MixerOutputType[2] = mixerSettingsData.Mixer3Type; - MixerOutputType[3] = mixerSettingsData.Mixer4Type; - MixerOutputType[4] = mixerSettingsData.Mixer5Type; - MixerOutputType[5] = mixerSettingsData.Mixer6Type; - MixerOutputType[6] = mixerSettingsData.Mixer7Type; - MixerOutputType[7] = mixerSettingsData.Mixer8Type; - - for (i=1; i <= (int)(ActuatorCommand::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); - } - - //process the data from the mixer and try to figure out the settings... - for (i=0;i<8;i++) - { - //check if this is the engine... Throttle only - if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_MOTOR)&& - (MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1 - (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 - (MixerDataFromHeli[i][2]==0)&&//Roll - (MixerDataFromHeli[i][3]==0)&&//Pitch - (MixerDataFromHeli[i][4]==0))//Yaw - { - channelDesc[i] = "Throttle"; - } - else if ((MixerDataFromHeli[i][0]>0)&& //ThrottleCurve1 - (MixerDataFromHeli[i][2]!=0)&&//Roll - (MixerDataFromHeli[i][3]!=0)) //Pitch - { - channelDesc[i] = "Collective"; - } - //check if this is the tail servo... - else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& - (MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1 - (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 - (MixerDataFromHeli[i][2]==0)&&//Roll - (MixerDataFromHeli[i][3]==0)&&//Pitch - (MixerDataFromHeli[i][4]>0))//Yaw - { - channelDesc[i] = "Tail"; - } - //check if this is the elevator servo... - else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& - (MixerDataFromHeli[i][2]==0)&&//Roll - (MixerDataFromHeli[i][3]!=0))//Pitch - { - channelDesc[i] = "Elevator"; - } - //check if this is a swashplate servo... - else if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& - (MixerDataFromHeli[i][2]!=0))//Roll - { - channelDesc[i] = QString("%1%2").arg("Roll").arg(i); - } - - } - - return channelDesc; -} void ConfigOutputWidget::openHelp() { diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index 1571792af..3881b8f36 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -33,6 +33,7 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "uavobjectutilmanager.h" +#include "cfg_vehicletypes/guiconfigdata.h" #include #include @@ -58,11 +59,12 @@ private: void assignChannel(UAVDataObject *obj, QString str); void assignOutputChannel(UAVDataObject *obj, QString str); OutputChannelForm* getOutputChannelForm(const int index) const; - QStringList getChannelDescriptions(); int mccDataRate; UAVObject::Metadata accInitialData; + GUIConfigDataManager GUIManager; + bool firstUpdate; bool wasItMe; From ed54716436ecb7e5f0703a6ab31d1fd44b36be4c Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Mon, 14 May 2012 10:05:40 -0700 Subject: [PATCH 04/15] add gui config data bit storage to fixedwing,multirotor,ground vehicles --- .../cfg_vehicletypes/configccpmwidget.cpp | 54 ++-- .../cfg_vehicletypes/configccpmwidget.h | 48 +-- .../configfixedwingwidget.cpp | 177 ++++------- .../configgroundvehiclewidget.cpp | 138 +++------ .../configmultirotorwidget.cpp | 276 ++++++++---------- .../config/cfg_vehicletypes/guiconfigdata.cpp | 131 ++++++++- .../config/cfg_vehicletypes/guiconfigdata.h | 17 +- .../config/configvehicletypewidget.cpp | 12 +- .../plugins/config/configvehicletypewidget.h | 6 +- shared/uavobjectdefinition/systemsettings.xml | 2 +- 10 files changed, 428 insertions(+), 433 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 6d7a974c2..00da51f44 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -25,7 +25,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configccpmwidget.h" -#include "mixersettings.h" +//#include "mixersettings.h" #include #include @@ -892,7 +892,7 @@ void ConfigccpmWidget::UpdateMixer() } } - if (GUIConfigData.heli.SwasplateType>0) + if (GUIConfigData.heli.SwashplateType>0) {//not advanced settings //get the channel data from the ui MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex(); @@ -999,7 +999,7 @@ void ConfigccpmWidget::UpdateCCPMOptionsFromUI() if (updatingFromHardware) return; //get the user options //swashplate config - GUIConfigData.heli.SwasplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; + GUIConfigData.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; GUIConfigData.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); //ccpm mixing options @@ -1036,12 +1036,17 @@ void ConfigccpmWidget::UpdateCCPMOptionsFromUI() GUIConfigData.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex(); GUIConfigData.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex(); GUIConfigData.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex(); + + //throttle + GUIConfigData.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex(); + //tail + GUIConfigData.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex(); } void ConfigccpmWidget::UpdateCCPMUIFromOptions() { //swashplate config - m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - (GUIConfigData.heli.SwasplateType +1)); + m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - (GUIConfigData.heli.SwashplateType +1)); m_ccpm->ccpmSingleServo->setCurrentIndex(GUIConfigData.heli.FirstServoIndex); //ccpm mixing options @@ -1070,6 +1075,10 @@ void ConfigccpmWidget::UpdateCCPMUIFromOptions() m_ccpm->ccpmServoYChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexY); m_ccpm->ccpmServoZChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexZ); + //throttle + m_ccpm->ccpmEngineChannel->setCurrentIndex(GUIConfigData.heli.Throttle); + //tail + m_ccpm->ccpmTailChannel->setCurrentIndex((GUIConfigData.heli.Tail)); } @@ -1117,15 +1126,17 @@ void ConfigccpmWidget::requestccpmUpdate() unsigned int i,j; - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); +// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); +// Q_ASSERT(systemSettings); +// SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == - (sizeof(GUIConfigData.UAVObject) / sizeof(GUIConfigData.UAVObject[0]))); +// Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == +// (sizeof(GUIConfigData.UAVObject) / sizeof(GUIConfigData.UAVObject[0]))); - for(i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++) - GUIConfigData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; +// for(i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++) +// GUIConfigData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; + + GUIConfigData = GUIManager.GetConfigData(); UpdateCCPMUIFromOptions(); @@ -1178,7 +1189,7 @@ void ConfigccpmWidget::requestccpmUpdate() (MixerDataFromHeli[i][4]==0))//Yaw { EngineChannel = i; - m_ccpm->ccpmEngineChannel->setCurrentIndex(i); + //m_ccpm->ccpmEngineChannel->setCurrentIndex(i); } //check if this is the tail rotor... REVO and YAW @@ -1190,7 +1201,7 @@ void ConfigccpmWidget::requestccpmUpdate() (MixerDataFromHeli[i][4]!=0))//Yaw { TailRotorChannel = i; - m_ccpm->ccpmTailChannel->setCurrentIndex(i); + //m_ccpm->ccpmTailChannel->setCurrentIndex(i); m_ccpm->ccpmRevoSlider->setValue((MixerDataFromHeli[i][0]*100)/127); m_ccpm->ccpmREVOspinBox->setValue((MixerDataFromHeli[i][0]*100)/127); } @@ -1239,14 +1250,17 @@ void ConfigccpmWidget::sendccpmUpdate() UpdateCCPMOptionsFromUI(); + GUIManager.SetConfigData(GUIConfigData); + // Store the data required to reconstruct - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - systemSettingsData.GUIConfigData[0] = GUIConfigData.UAVObject[0]; - systemSettingsData.GUIConfigData[1] = GUIConfigData.UAVObject[1]; - systemSettings->setData(systemSettingsData); - systemSettings->updated(); +// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); +// Q_ASSERT(systemSettings); +// SystemSettings::DataFields systemSettingsData = systemSettings->getData(); +// for (i=0; isetData(systemSettingsData); +// systemSettings->updated(); MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); Q_ASSERT(mixerSettings); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 31a5e227d..75652c01b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -29,6 +29,7 @@ #include "ui_ccpm.h" #include "../uavobjectwidgetutils/configtaskwidget.h" +#include "guiconfigdata.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" @@ -49,29 +50,31 @@ typedef struct { int Neutral[CCPM_MAX_SWASH_SERVOS]; int Min[CCPM_MAX_SWASH_SERVOS]; } SwashplateServoSettingsStruct; +//typedef struct { +// uint SwasplateType:3; +// uint FirstServoIndex:2; +// uint CorrectionAngle:9; +// uint ccpmCollectivePassthroughState:1; +// uint ccpmLinkCyclicState:1; +// uint ccpmLinkRollState:1; +// uint SliderValue0:7; +// uint SliderValue1:7; +// uint SliderValue2:7;//41bits +// uint ServoIndexW:4; +// uint ServoIndexX:4; +// uint ServoIndexY:4; +// uint ServoIndexZ:4;//57bits +// uint Throttle:4; +// uint Tail:4; //65bits +// quint32 padding1:31; //96bits +// quint32 padding2; //128bits +//} __attribute__((packed)) heliGUISettingsStruct; -typedef struct { - uint SwasplateType:3; - uint FirstServoIndex:2; - uint CorrectionAngle:9; - uint ccpmCollectivePassthroughState:1; - uint ccpmLinkCyclicState:1; - uint ccpmLinkRollState:1; - uint SliderValue0:7; - uint SliderValue1:7; - uint SliderValue2:7;//41bits - uint ServoIndexW:4; - uint ServoIndexX:4; - uint ServoIndexY:4; - uint ServoIndexZ:4;//57bits - uint padding:7; -} __attribute__((packed)) heliGUISettingsStruct; - -typedef union -{ - uint UAVObject[2];//32bits * 2 - heliGUISettingsStruct heli;//64bits -} GUIConfigDataUnion; +//typedef union +//{ +// uint UAVObject[4];//32bits * 4 +// heliGUISettingsStruct heli;//128bits +//} GUIConfigDataUnion; class ConfigccpmWidget: public ConfigTaskWidget { @@ -109,6 +112,7 @@ private: SwashplateServoSettingsStruct oldSwashLvlConfiguration; SwashplateServoSettingsStruct newSwashLvlConfiguration; + GUIConfigDataManager GUIManager; GUIConfigDataUnion GUIConfigData; int MixerChannelData[6]; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 7c641acfa..32ec686e2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -136,7 +136,7 @@ QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets() //All airframe types must start with "FixedWing" if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) { airframeType = "FixedWing"; - setupFrameFixedWing( airframeType ); + setupFrameFixedWing( airframeType ); } else if (m_aircraft->fixedWingType->currentText() == "Elevon") { airframeType = "FixedWingElevon"; setupFrameElevon( airframeType ); @@ -156,42 +156,22 @@ QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets() Helper function to refresh the UI widget values */ void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType) -{ - - UAVDataObject* obj; - UAVObjectField *field; - - // Then retrieve how channels are setup - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - field = obj->getField(QString("FixedWingThrottle")); - Q_ASSERT(field); - m_aircraft->fwEngineChannelBox->setCurrentIndex(m_aircraft->fwEngineChannelBox->findText(field->getValue().toString())); +{ + GUIConfigData = GUIManager.GetConfigData(); + fixedGUISettingsStruct fixed = GUIConfigData.fixed; + + // Then retrieve how channels are setup + setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle); + setComboCurrentIndex(m_aircraft->fwAileron1ChannelBox, fixed.FixedWingRoll1); + setComboCurrentIndex(m_aircraft->fwAileron2ChannelBox, fixed.FixedWingRoll2); + setComboCurrentIndex(m_aircraft->fwElevator1ChannelBox, fixed.FixedWingPitch1); + setComboCurrentIndex(m_aircraft->fwElevator2ChannelBox, fixed.FixedWingPitch2); + setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1); + setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2); + + UAVDataObject* obj; + UAVObjectField *field; - field = obj->getField(QString("FixedWingRoll1")); - Q_ASSERT(field); - m_aircraft->fwAileron1ChannelBox->setCurrentIndex(m_aircraft->fwAileron1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingRoll2")); - Q_ASSERT(field); - m_aircraft->fwAileron2ChannelBox->setCurrentIndex(m_aircraft->fwAileron2ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingPitch1")); - Q_ASSERT(field); - m_aircraft->fwElevator1ChannelBox->setCurrentIndex(m_aircraft->fwElevator1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingPitch2")); - Q_ASSERT(field); - m_aircraft->fwElevator2ChannelBox->setCurrentIndex(m_aircraft->fwElevator2ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingYaw1")); - Q_ASSERT(field); - m_aircraft->fwRudder1ChannelBox->setCurrentIndex(m_aircraft->fwRudder1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingYaw2")); - Q_ASSERT(field); - m_aircraft->fwRudder2ChannelBox->setCurrentIndex(m_aircraft->fwRudder2ChannelBox->findText(field->getValue().toString())); - if (frameType == "FixedWingElevon") { // If the airframe is elevon, restore the slider setting // Find the channel number for Elevon1 (FixedWingRoll1) @@ -245,40 +225,24 @@ bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType) // m_aircraft->fwStatusLabel->setText("ERROR: check channel assignment"); return false; } - // Now setup the channels: - resetActuators(); - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Elevator - UAVObjectField *field = obj->getField("FixedWingPitch1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwElevator1ChannelBox->currentText()); - field = obj->getField("FixedWingPitch2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwElevator2ChannelBox->currentText()); - // Aileron - field = obj->getField("FixedWingRoll1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron1ChannelBox->currentText()); - field = obj->getField("FixedWingRoll2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron2ChannelBox->currentText()); - - // Rudder - field = obj->getField("FixedWingYaw1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwRudder1ChannelBox->currentText()); - - // Throttle - field = obj->getField("FixedWingThrottle"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwEngineChannelBox->currentText()); + // Now setup the channels: - obj->updated(); + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); + + GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + + GUIManager.SetConfigData(GUIConfigData); + UAVDataObject* obj; + UAVObjectField* field; + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); // ... and compute the matrix: @@ -382,32 +346,20 @@ bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType) return false; } - resetActuators(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Elevons - UAVObjectField *field = obj->getField("FixedWingRoll1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron1ChannelBox->currentText()); - field = obj->getField("FixedWingRoll2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron2ChannelBox->currentText()); - // Rudder 1 (can be None) - field = obj->getField("FixedWingYaw1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwRudder1ChannelBox->currentText()); - // Rudder 2 (can be None) - field = obj->getField("FixedWingYaw2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwRudder2ChannelBox->currentText()); - // Throttle - field = obj->getField("FixedWingThrottle"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwEngineChannelBox->currentText()); - - obj->updated(); - + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); + + GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + + GUIManager.SetConfigData(GUIConfigData); + + UAVDataObject* obj; + UAVObjectField* field; + // Save the curve: obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); @@ -506,31 +458,20 @@ bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType) return false; } - resetActuators(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Elevons - UAVObjectField *field = obj->getField("FixedWingPitch1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwElevator1ChannelBox->currentText()); - field = obj->getField("FixedWingPitch2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwElevator2ChannelBox->currentText()); - field = obj->getField("FixedWingRoll1"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron1ChannelBox->currentText()); - field = obj->getField("FixedWingRoll2"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwAileron2ChannelBox->currentText()); - - // Throttle - field = obj->getField("FixedWingThrottle"); - Q_ASSERT(field); - field->setValue(m_aircraft->fwEngineChannelBox->currentText()); - - obj->updated(); - + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); + + GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + + GUIManager.SetConfigData(GUIConfigData); + + UAVDataObject* obj; + UAVObjectField* field; + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); // ... and compute the matrix: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 67035ae39..b7b31b0f6 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -194,38 +194,15 @@ void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameTyp UAVDataObject* obj; UAVObjectField *field; + GUIConfigData = GUIManager.GetConfigData(); + //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - field = obj->getField(QString("FixedWingThrottle")); - Q_ASSERT(field); - m_aircraft->gvEngineChannelBox->setCurrentIndex(m_aircraft->gvEngineChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingRoll1")); - Q_ASSERT(field); - m_aircraft->gvAileron1ChannelBox->setCurrentIndex(m_aircraft->gvAileron1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("FixedWingRoll2")); - Q_ASSERT(field); - m_aircraft->gvAileron2ChannelBox->setCurrentIndex(m_aircraft->gvAileron2ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("GroundVehicleThrottle1")); - Q_ASSERT(field); - m_aircraft->gvMotor1ChannelBox->setCurrentIndex(m_aircraft->gvMotor1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("GroundVehicleThrottle2")); - Q_ASSERT(field); - m_aircraft->gvMotor2ChannelBox->setCurrentIndex(m_aircraft->gvMotor2ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("GroundVehicleSteering1")); - Q_ASSERT(field); - m_aircraft->gvSteering1ChannelBox->setCurrentIndex(m_aircraft->gvSteering1ChannelBox->findText(field->getValue().toString())); - - field = obj->getField(QString("GroundVehicleSteering2")); - Q_ASSERT(field); - m_aircraft->gvSteering2ChannelBox->setCurrentIndex(m_aircraft->gvSteering2ChannelBox->findText(field->getValue().toString())); - + setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, GUIConfigData.ground.GroundVehicleThrottle1); + setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, GUIConfigData.ground.GroundVehicleThrottle2); + setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, GUIConfigData.ground.GroundVehicleSteering1); + setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, GUIConfigData.ground.GroundVehicleSteering2); + if (frameType == "GroundVehicleDifferential") { //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE // If the vehicle type is "differential", restore the slider setting @@ -280,25 +257,19 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType) return false; } - + // Now setup the channels: - resetActuators(); - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Left motor - UAVObjectField *field = obj->getField("GroundVehicleThrottle1"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor1ChannelBox->currentText()); - - // Right motor - field = obj->getField("GroundVehicleThrottle2"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor2ChannelBox->currentText()); - - obj->updated(); + GUIConfigData = GUIManager.GetConfigData(); + + GUIManager.ResetActuators(&GUIConfigData); + GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + + GUIManager.SetConfigData(GUIConfigData); + UAVObject* obj; + UAVObjectField* field; + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); // ... and compute the matrix: @@ -397,25 +368,19 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeTyp return false; } + + // Now setup the channels: + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); - // Now setup the channels: - resetActuators(); - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Left motor - UAVObjectField *field = obj->getField("GroundVehicleThrottle1"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor1ChannelBox->currentText()); - - // Right motor - field = obj->getField("GroundVehicleThrottle2"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor2ChannelBox->currentText()); - - obj->updated(); + GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + + GUIManager.SetConfigData((GUIConfigData)); + UAVObject* obj; + UAVObjectField* field; + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); // ... and compute the matrix: @@ -524,43 +489,20 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType) // m_aircraft->gvMotor2Label->setText(htmlText->toPlainText()); // } - // Now setup the channels: - resetActuators(); + // Now setup the channels: + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - - // Front motor - UAVObjectField *field = obj->getField("GroundVehicleThrottle1"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor1ChannelBox->currentText()); - - // Rear motor - field = obj->getField("GroundVehicleThrottle2"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvMotor2ChannelBox->currentText()); + GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + GUIConfigData.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); + GUIConfigData.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); -// // Aileron -// field = obj->getField("FixedWingRoll1"); -// Q_ASSERT(field); -// field->setValue(m_aircraft->fwAileron1ChannelBox->currentText()); -// -// field = obj->getField("FixedWingRoll2"); -// Q_ASSERT(field); -// field->setValue(m_aircraft->fwAileron2ChannelBox->currentText()); - - // Front steering - field = obj->getField("GroundVehicleSteering1"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvSteering1ChannelBox->currentText()); - - // Rear steering - field = obj->getField("GroundVehicleSteering2"); - Q_ASSERT(field); - field->setValue(m_aircraft->gvSteering2ChannelBox->currentText()); - - obj->updated(); + GUIManager.SetConfigData(GUIConfigData); + UAVDataObject* obj; + UAVObjectField* field; + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); // ... and compute the matrix: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index c0d4972f0..e6701f002 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -41,6 +41,7 @@ #include "mixersettings.h" #include "systemsettings.h" #include "actuatorcommand.h" +#include "guiconfigdata.h" //#define Pi 3.14159265358979323846 @@ -63,7 +64,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=4; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(true); @@ -80,7 +81,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=5; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(false); @@ -100,7 +101,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=5; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(false); @@ -120,7 +121,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=7; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(false); @@ -140,7 +141,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=7; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(false); @@ -161,7 +162,7 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) //and grey out all unused motor channel boxes for (int i=7; i <=8; i++) { QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + combobox->setEnabled(false); } m_aircraft->triYawChannelBox->setEnabled(false); @@ -467,10 +468,11 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() } motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS"; setupMotors(motorList); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - field = obj->getField("FixedWingYaw1"); - field->setValue(m_aircraft->triYawChannelBox->currentText()); + + GUIConfigData = GUIManager.GetConfigData(); + GUIConfigData.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex(); + GUIManager.SetConfigData(GUIConfigData); + // Motor 1 to 6, Y6 Layout: // pitch roll yaw @@ -514,26 +516,20 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) ////////////////////////////////////////////////////////////////// // Retrieve settings ////////////////////////////////////////////////////////////////// - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - UAVObjectField *field; + + GUIConfigData = GUIManager.GetConfigData(); + multiGUISettingsStruct multi = GUIConfigData.multi; + + UAVDataObject* obj; + UAVObjectField *field; if (frameType == "QuadP") { - // Motors 1/2/3/4 are: N / E / S / W - field = obj->getField(QString("VTOLMotorN")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + // Motors 1/2/3/4 are: N / E / S / W + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. @@ -556,20 +552,12 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue(val); } } else if (frameType == "QuadX") { - // Motors 1/2/3/4 are: NW / NE / SE / SW - field = obj->getField(QString("VTOLMotorNW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + // Motors 1/2/3/4 are: NW / NE / SE / SW + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. @@ -591,23 +579,18 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) } } else if (frameType == "Hexa") { // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW - field = obj->getField(QString("VTOLMotorN")); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSW")); - m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNW")); - m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; // tmpVal will be -1 if value is set to "None" if (tmpVal > -1) { @@ -628,19 +611,15 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) } } } else if (frameType == "HexaX") { - // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW - field = obj->getField(QString("VTOLMotorNE")); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorE")); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSW")); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorW")); - m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNW")); - m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); + // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the @@ -663,20 +642,16 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue(val); } } else if (frameType == "HexaCoax") { - // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE - field = obj->getField(QString("VTOLMotorNW")); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorW")); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorE")); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. @@ -697,32 +672,18 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) } } else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") { - // Motors 1 to 8 are N / NE / E / etc - field = obj->getField(QString("VTOLMotorN")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox7->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox8->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. @@ -774,32 +735,18 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) } } } else if (frameType == "OctoCoaxX") { - // Motors 1 to 8 are N / NE / E / etc - field = obj->getField(QString("VTOLMotorNW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorN")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorSW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox7->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox8->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString())); - + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. @@ -819,20 +766,14 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue(val); } } else if (frameType == "Tri") { - // Motors 1 to 8 are N / NE / E / etc - field = obj->getField(QString("VTOLMotorNW")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorNE")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString())); - field = obj->getField(QString("VTOLMotorS")); - Q_ASSERT(field); - m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - field = obj->getField(QString("FixedWingYaw1")); - Q_ASSERT(field); - m_aircraft->triYawChannelBox->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString())); - + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw); + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; // tmpVal will be -1 if value is set to "None" @@ -883,19 +824,40 @@ void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double r */ void ConfigVehicleTypeWidget::setupMotors(QList motorList) { - resetActuators(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - UAVObjectField *field; QList mmList; mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; + + GUIConfigData = GUIManager.GetConfigData(); + GUIManager.ResetActuators(&GUIConfigData); + + int index; foreach (QString motor, motorList) { - field = obj->getField(motor); - field->setValue(mmList.takeFirst()->currentText()); + + index = mmList.takeFirst()->currentIndex(); + + //qDebug()<updated(); // Save... + GUIManager.SetConfigData(GUIConfigData); + } @@ -1143,4 +1105,4 @@ void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors) if (error){ m_aircraft->mrStatusLabel->setText(QString("ERROR: Assign all %1 motor channels").arg(numMotors)); } -} \ No newline at end of file +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp index 43630d4ae..5e8d1c7ee 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp @@ -85,6 +85,95 @@ void GUIConfigDataManager::SetConfigData(GUIConfigDataUnion configData) { systemSettings->updated(); } +void GUIConfigDataManager::ResetActuators() +{ + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + // reset the actuators by airframe type + ResetActuators(&configData); + + // set the gui config data + SetConfigData(configData); + +} + +void GUIConfigDataManager::ResetActuators(GUIConfigDataUnion* configData) +{ + // get systemsettings for airframe type + SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + switch (systemSettingsData.AirframeType) + { + // fixed wing + case SystemSettings::AIRFRAMETYPE_FIXEDWING: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: + { + configData->fixed.FixedWingPitch1 = 0; + configData->fixed.FixedWingPitch2 = 0; + configData->fixed.FixedWingRoll1 = 0; + configData->fixed.FixedWingRoll2 = 0; + configData->fixed.FixedWingYaw1 = 0; + configData->fixed.FixedWingYaw2 = 0; + configData->fixed.FixedWingThrottle = 0; + } + break; + + // helicp + case SystemSettings::AIRFRAMETYPE_HELICP: + { + configData->heli.Throttle = 0; + configData->heli.Tail = 0; + configData->heli.ServoIndexW = 0; + configData->heli.ServoIndexX = 0; + configData->heli.ServoIndexY = 0; + configData->heli.ServoIndexZ = 0; + } + break; + + //multirotor + case SystemSettings::AIRFRAMETYPE_VTOL: + case SystemSettings::AIRFRAMETYPE_TRI: + case SystemSettings::AIRFRAMETYPE_QUADX: + case SystemSettings::AIRFRAMETYPE_QUADP: + case SystemSettings::AIRFRAMETYPE_OCTOV: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: + case SystemSettings::AIRFRAMETYPE_OCTO: + case SystemSettings::AIRFRAMETYPE_HEXAX: + case SystemSettings::AIRFRAMETYPE_HEXACOAX: + case SystemSettings::AIRFRAMETYPE_HEXA: + { + configData->multi.VTOLMotorN = 0; + configData->multi.VTOLMotorNE = 0; + configData->multi.VTOLMotorE = 0; + configData->multi.VTOLMotorSE = 0; + configData->multi.VTOLMotorS = 0; + configData->multi.VTOLMotorSW = 0; + configData->multi.VTOLMotorW = 0; + configData->multi.VTOLMotorNW = 0; + configData->multi.TRIYaw = 0; + } + break; + + // ground + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + { + configData->ground.GroundVehicleSteering1 = 0; + configData->ground.GroundVehicleSteering2 = 0; + configData->ground.GroundVehicleThrottle1 = 0; + configData->ground.GroundVehicleThrottle2 = 0; + } + break; + + } +} + QStringList GUIConfigDataManager::getChannelDescriptions() { int i; @@ -183,20 +272,46 @@ QStringList GUIConfigDataManager::getChannelDescriptions() case SystemSettings::AIRFRAMETYPE_HEXACOAX: case SystemSettings::AIRFRAMETYPE_HEXA: { - channelDesc[configData.multi.VTOLMotorN] = QString("VTOLMotorN"); - channelDesc[configData.multi.VTOLMotorNE] = QString("VTOLMotorNE"); - channelDesc[configData.multi.VTOLMotorNW] = QString("VTOLMotorNW"); - channelDesc[configData.multi.VTOLMotorS] = QString("VTOLMotorS"); - channelDesc[configData.multi.VTOLMotorSE] = QString("VTOLMotorSE"); - channelDesc[configData.multi.VTOLMotorSW] = QString("VTOLMotorSW"); - channelDesc[configData.multi.VTOLMotorW] = QString("VTOLMotorW"); - channelDesc[configData.multi.VTOLMotorE] = QString("VTOLMotorE"); + multiGUISettingsStruct multi = configData.multi; + + if (multi.VTOLMotorN > 0 && multi.VTOLMotorN < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN"); + if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE"); + if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW"); + if (multi.VTOLMotorS > 0 && multi.VTOLMotorS < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS"); + if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE"); + if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW"); + if (multi.VTOLMotorW > 0 && multi.VTOLMotorW < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW"); + if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < GUIConfigDataManager::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE"); + return channelDesc; } break; // ground + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + { + if (configData.ground.GroundVehicleSteering1 > 0) + channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1"); + if (configData.ground.GroundVehicleSteering2 > 0) + channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2"); + if (configData.ground.GroundVehicleThrottle1 > 0) + channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1"); + if (configData.ground.GroundVehicleThrottle2 > 0) + channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2"); + return channelDesc; + } + break; } return channelDesc; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h index 287bfcb67..9c92faa0e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h @@ -48,7 +48,7 @@ typedef struct { } __attribute__((packed)) multiGUISettingsStruct; typedef struct { - uint SwasplateType:3; + uint SwashplateType:3; uint FirstServoIndex:2; uint CorrectionAngle:9; uint ccpmCollectivePassthroughState:1; @@ -109,20 +109,23 @@ class GUIConfigDataManager: public QObject GUIConfigDataManager(); ~GUIConfigDataManager(); + GUIConfigDataUnion GetConfigData(); + void SetConfigData(GUIConfigDataUnion configData); + QStringList getChannelDescriptions(); + void ResetActuators(); + void ResetActuators(GUIConfigDataUnion* configData); + static const quint32 CHANNEL_NUMELEM = 10; friend class ConfigTaskWidget; private: - - - private slots: UAVObjectManager* getObjectManager(); + private slots: + public slots: - GUIConfigDataUnion GetConfigData(); - void SetConfigData(GUIConfigDataUnion configData); - QStringList getChannelDescriptions(); + protected: diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 943aaf6d4..1fec3f05c 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -250,7 +250,7 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() rather than a signal in the UI, because we want to force a fitInView of the quad shapes. This is because this method (fitinview) only works when the widget is shown. */ -void ConfigVehicleTypeWidget::switchAirframeType(int index){ +void ConfigVehicleTypeWidget::switchAirframeType(int index){ m_aircraft->airframesWidget->setCurrentIndex(index); m_aircraft->quadShape->setSceneRect(quad->boundingRect()); m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); @@ -844,6 +844,16 @@ void ConfigVehicleTypeWidget::openHelp() QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Airframe+configuration", QUrl::StrictMode) ); } +/** + Helper function: + Sets the current index on supplied combobox to index + if it is within bounds 0 <= index < combobox.count() + */ +void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index) +{ + if (index >= 0 && index < box->count()) + box->setCurrentIndex(index); +} /** WHAT DOES THIS DO??? diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index 9c6daf16e..59a97277c 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -33,6 +33,7 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" +#include "cfg_vehicletypes/guiconfigdata.h" #include #include #include @@ -67,7 +68,7 @@ private: void resetActuators(); //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector); void setupQuadMotor(int channel, double roll, double pitch, double yaw); - + void setComboCurrentIndex(QComboBox* box, int index); QStringList mixerTypes; QStringList mixerVectors; QGraphicsSvgItem *quad; @@ -75,6 +76,9 @@ private: bool ffTuningPhase; UAVObject::Metadata accInitialData; + GUIConfigDataManager GUIManager; + GUIConfigDataUnion GUIConfigData; + private slots: virtual void refreshWidgetsValues(); void refreshFixedWingWidgetsValues(QString frameType); diff --git a/shared/uavobjectdefinition/systemsettings.xml b/shared/uavobjectdefinition/systemsettings.xml index ec092df8e..d1255c858 100644 --- a/shared/uavobjectdefinition/systemsettings.xml +++ b/shared/uavobjectdefinition/systemsettings.xml @@ -2,7 +2,7 @@ Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand - + From 64688be0a10f31f4b0de602b8b9cb37848911022 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Mon, 21 May 2012 11:28:29 -0700 Subject: [PATCH 05/15] Refactor configwidgets for multirotor,fixedwing,heli,ground; VehicleConfig subclasses ConfigTaskWidget and adds guiconfigdata bit storage; Align channelbox items so 'None' is first; --- .../cfg_vehicletypes/configccpmwidget.cpp | 566 +++++++++--------- .../cfg_vehicletypes/configccpmwidget.h | 56 +- .../configfixedwingwidget.cpp | 164 +++-- .../cfg_vehicletypes/configfixedwingwidget.h | 74 +++ .../configgroundvehiclewidget.cpp | 139 +++-- .../configgroundvehiclewidget.h | 74 +++ .../configmultirotorwidget.cpp | 333 ++++++----- .../cfg_vehicletypes/configmultirotorwidget.h | 81 +++ .../config/cfg_vehicletypes/guiconfigdata.cpp | 328 ---------- .../config/cfg_vehicletypes/vehicleconfig.cpp | 143 +++++ .../{guiconfigdata.h => vehicleconfig.h} | 42 +- .../src/plugins/config/config.pro | 7 +- .../src/plugins/config/configoutputwidget.cpp | 5 +- .../src/plugins/config/configoutputwidget.h | 4 +- .../config/configvehicletypewidget.cpp | 400 ++++++++----- .../plugins/config/configvehicletypewidget.h | 56 +- 16 files changed, 1344 insertions(+), 1128 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h delete mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp rename ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/{guiconfigdata.h => vehicleconfig.h} (78%) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 00da51f44..f8fbbb67f 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -44,21 +44,17 @@ #define Pi 3.14159265358979323846 -ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) +ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent) { int i; - - m_ccpm = new Ui_ccpmWidget(); - m_ccpm->setupUi(this); SwashLvlConfigurationInProgress=0; SwashLvlState=0; SwashLvlServoInterlock=0; updatingFromHardware=FALSE; updatingToHardware=FALSE; - // Now connect the widget to the ManualControlCommand / Channel UAVObject - //ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - //UAVObjectManager *objManager = pm->getObject(); + m_ccpm = new Ui_ccpmWidget(); + m_ccpm->setupUi(this); // Initialization of the swashplaye widget m_ccpm->SwashplateImage->setScene(new QGraphicsScene(this)); @@ -148,20 +144,20 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) Q_ASSERT(curve2source); QStringList channels; - channels << "Channel1" << "Channel2" << "Channel3" << "Channel4" << - "Channel5" << "Channel6" << "Channel7" << "Channel8" << "None"; + channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" << + "Channel5" << "Channel6" << "Channel7" << "Channel8"; m_ccpm->ccpmEngineChannel->addItems(channels); - m_ccpm->ccpmEngineChannel->setCurrentIndex(8); + m_ccpm->ccpmEngineChannel->setCurrentIndex(0); m_ccpm->ccpmTailChannel->addItems(channels); - m_ccpm->ccpmTailChannel->setCurrentIndex(8); + m_ccpm->ccpmTailChannel->setCurrentIndex(0); m_ccpm->ccpmServoWChannel->addItems(channels); - m_ccpm->ccpmServoWChannel->setCurrentIndex(8); + m_ccpm->ccpmServoWChannel->setCurrentIndex(0); m_ccpm->ccpmServoXChannel->addItems(channels); - m_ccpm->ccpmServoXChannel->setCurrentIndex(8); + m_ccpm->ccpmServoXChannel->setCurrentIndex(0); m_ccpm->ccpmServoYChannel->addItems(channels); - m_ccpm->ccpmServoYChannel->setCurrentIndex(8); + m_ccpm->ccpmServoYChannel->setCurrentIndex(0); m_ccpm->ccpmServoZChannel->addItems(channels); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); QStringList Types; Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") << @@ -170,12 +166,14 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : ConfigTaskWidget(parent) QString::fromUtf8("Custom - User Angles") << QString::fromUtf8("Custom - Advanced Settings"); m_ccpm->ccpmType->addItems(Types); m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - 1); - requestccpmUpdate(); + UpdateCurveSettings(); //disable changing number of points in curves until UAVObjects have more than 5 m_ccpm->NumCurvePoints->setEnabled(0); + refreshWidgetsValues(QString("HeliCP")); + UpdateType(); //connect(m_ccpm->saveccpmToSD, SIGNAL(clicked()), this, SLOT(saveccpmUpdate())); @@ -229,13 +227,91 @@ ConfigccpmWidget::~ConfigccpmWidget() // Do nothing } +void ConfigccpmWidget::setupUI(QString frameType) +{ +} + +void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData) +{ + configData->heli.Throttle = 0; + configData->heli.Tail = 0; + configData->heli.ServoIndexW = 0; + configData->heli.ServoIndexX = 0; + configData->heli.ServoIndexY = 0; + configData->heli.ServoIndexZ = 0; +} + +QStringList ConfigccpmWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigccpmWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + heliGUISettingsStruct heli = configData.heli; + + if (heli.Throttle > 0) + channelDesc[heli.Throttle - 1] = QString("Throttle"); + if (heli.Tail > 0) + channelDesc[heli.Tail - 1] = QString("Tail"); + + switch(heli.FirstServoIndex) + { + case 0: //front + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 1: //right + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + case 2: //rear + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 3: //left + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + } + if (heli.ServoIndexZ > 0) + channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); + + return channelDesc; +} + void ConfigccpmWidget::UpdateType() { int TypeInt,SingleServoIndex,NumServosDefined; QString TypeText; double AdjustmentAngle=0; - UpdateCCPMOptionsFromUI(); SetUIComponentVisibilities(); TypeInt = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; @@ -283,8 +359,8 @@ void ConfigccpmWidget::UpdateType() m_ccpm->ccpmAngleZ->setValue(0); m_ccpm->ccpmAngleY->setEnabled(0); m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoYChannel->setCurrentIndex(8); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoYChannel->setCurrentIndex(0); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoYChannel->setEnabled(0); m_ccpm->ccpmServoZChannel->setEnabled(0); //m_ccpm->ccpmCorrectionAngle->setValue(0); @@ -298,7 +374,7 @@ void ConfigccpmWidget::UpdateType() m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); m_ccpm->ccpmAngleZ->setValue(0); m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoZChannel->setEnabled(0); //m_ccpm->ccpmCorrectionAngle->setValue(0); NumServosDefined=3; @@ -323,7 +399,7 @@ void ConfigccpmWidget::UpdateType() m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360)); m_ccpm->ccpmAngleZ->setValue(0); m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoZChannel->setEnabled(0); //m_ccpm->ccpmCorrectionAngle->setValue(0); NumServosDefined=3; @@ -336,7 +412,7 @@ void ConfigccpmWidget::UpdateType() m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360)); m_ccpm->ccpmAngleZ->setValue(0); m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoZChannel->setEnabled(0); //m_ccpm->ccpmCorrectionAngle->setValue(0); NumServosDefined=3; @@ -350,8 +426,8 @@ void ConfigccpmWidget::UpdateType() m_ccpm->ccpmAngleZ->setValue(0); m_ccpm->ccpmAngleY->setEnabled(0); m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoYChannel->setCurrentIndex(8); - m_ccpm->ccpmServoZChannel->setCurrentIndex(8); + m_ccpm->ccpmServoYChannel->setCurrentIndex(0); + m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoYChannel->setEnabled(0); m_ccpm->ccpmServoZChannel->setEnabled(0); //m_ccpm->ccpmCorrectionAngle->setValue(0); @@ -735,10 +811,10 @@ void ConfigccpmWidget::ccpmSwashplateRedraw() defined[1]=(m_ccpm->ccpmServoXChannel->isEnabled()); defined[2]=(m_ccpm->ccpmServoYChannel->isEnabled()); defined[3]=(m_ccpm->ccpmServoZChannel->isEnabled()); - used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()<8)&&(m_ccpm->ccpmServoWChannel->isEnabled())); - used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()<8)&&(m_ccpm->ccpmServoXChannel->isEnabled())); - used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()<8)&&(m_ccpm->ccpmServoYChannel->isEnabled())); - used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()<8)&&(m_ccpm->ccpmServoZChannel->isEnabled())); + used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled())); + used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled())); + used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled())); + used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled())); angle[0]=(CorrectionAngle+180+m_ccpm->ccpmAngleW->value())*Pi/180.00; angle[1]=(CorrectionAngle+180+m_ccpm->ccpmAngleX->value())*Pi/180.00; angle[2]=(CorrectionAngle+180+m_ccpm->ccpmAngleY->value())*Pi/180.00; @@ -803,61 +879,6 @@ void ConfigccpmWidget::ccpmSwashplateUpdate() UpdateMixer(); } -void ConfigccpmWidget::ccpmChannelCheck() -{ - if((m_ccpm->ccpmServoWChannel->currentIndex()==8)&&(m_ccpm->ccpmServoWChannel->isEnabled())) - { - m_ccpm->ccpmServoWLabel->setText("Servo W"); - } - else - { - m_ccpm->ccpmServoWLabel->setText("Servo W"); - } - if((m_ccpm->ccpmServoXChannel->currentIndex()==8)&&(m_ccpm->ccpmServoXChannel->isEnabled())) - { - m_ccpm->ccpmServoXLabel->setText("Servo X"); - } - else - { - m_ccpm->ccpmServoXLabel->setText("Servo X"); - } - if((m_ccpm->ccpmServoYChannel->currentIndex()==8)&&(m_ccpm->ccpmServoYChannel->isEnabled())) - { - m_ccpm->ccpmServoYLabel->setText("Servo Y"); - } - else - { - m_ccpm->ccpmServoYLabel->setText("Servo Y"); - } - if((m_ccpm->ccpmServoZChannel->currentIndex()==8)&&(m_ccpm->ccpmServoZChannel->isEnabled())) - { - m_ccpm->ccpmServoZLabel->setText("Servo Z"); - } - else - { - m_ccpm->ccpmServoZLabel->setText("Servo Z"); - } - - if((m_ccpm->ccpmEngineChannel->currentIndex()==8)&&(m_ccpm->ccpmEngineChannel->isEnabled())) - { - m_ccpm->ccpmEngineLabel->setText("Engine"); - } - else - { - m_ccpm->ccpmEngineLabel->setText("Engine"); - } - - if((m_ccpm->ccpmTailChannel->currentIndex()==8)&&(m_ccpm->ccpmTailChannel->isEnabled())) - { - m_ccpm->ccpmTailLabel->setText("Tail Rotor"); - } - else - { - m_ccpm->ccpmTailLabel->setText("Tail Rotor"); - } - -} - void ConfigccpmWidget::UpdateMixer() { bool useCCPM; @@ -866,13 +887,16 @@ void ConfigccpmWidget::UpdateMixer() float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6]; QString Channel; - ccpmChannelCheck(); - UpdateCCPMOptionsFromUI(); - - useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState); - useCyclic = GUIConfigData.heli.ccpmLinkRollState; + throwConfigError(QString("HeliCP")); - CollectiveConstant = (float)GUIConfigData.heli.SliderValue0 / 100.00; + updateConfigObjectsFromWidgets(); + + GUIConfigDataUnion config = GetConfigData(); + + useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); + useCyclic = config.heli.ccpmLinkRollState; + + CollectiveConstant = (float)config.heli.SliderValue0 / 100.00; if (useCCPM) {//cyclic = 1 - collective @@ -881,18 +905,18 @@ void ConfigccpmWidget::UpdateMixer() } else { - PitchConstant = (float)GUIConfigData.heli.SliderValue1 / 100.00;; + PitchConstant = (float)config.heli.SliderValue1 / 100.00;; if (useCyclic) { RollConstant = PitchConstant; } else { - RollConstant = (float)GUIConfigData.heli.SliderValue2 / 100.00;; + RollConstant = (float)config.heli.SliderValue2 / 100.00;; } } - if (GUIConfigData.heli.SwashplateType>0) + if (config.heli.SwashplateType>0) {//not advanced settings //get the channel data from the ui MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex(); @@ -914,18 +938,18 @@ void ConfigccpmWidget::UpdateMixer() ThisEnable[4] = m_ccpm->ccpmServoYChannel->isEnabled(); ThisEnable[5] = m_ccpm->ccpmServoZChannel->isEnabled(); - ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2]+1 )); - ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3]+1 )); - ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4]+1 )); - ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5]+1 )); + ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] )); + ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] )); + ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4] )); + ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5] )); //go through the user data and update the mixer matrix for (i=0;i<6;i++) { - if ((MixerChannelData[i]<8)&&((ThisEnable[i])||(i<2))) + if ((MixerChannelData[i]>0)&&((ThisEnable[i])||(i<2))) { - m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i]+1 )); + m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] )); //config the vector if (i==0) {//motor-engine @@ -947,8 +971,8 @@ void ConfigccpmWidget::UpdateMixer() {//Swashplate m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 - m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll - m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((GUIConfigData.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch + m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll + m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw } @@ -970,131 +994,132 @@ void ConfigccpmWidget::UpdateMixer() } } - - } - -/************************** - * ccpm settings - **************************/ -/* - Get the state of the UI check boxes and change the visibility of sliders - typedef struct { - uint SwasplateType:3; - uint FirstServoIndex:2; - uint CorrectionAngle:9; - uint ccpmCollectivePassthroughState:1; - uint ccpmLinkCyclicState:1; - uint ccpmLinkRollState:1; - uint CollectiveChannel:3; - uint padding:12; - } __attribute__((packed)) heliGUISettingsStruct; - - */ -void ConfigccpmWidget::UpdateCCPMOptionsFromUI() +QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() { + QString airframeType = "HeliCP"; + bool useCCPM; bool useCyclic; - if (updatingFromHardware) return; + if (updatingFromHardware) return airframeType; + + updatingFromHardware = TRUE; + //get the user options + GUIConfigDataUnion config = GetConfigData(); + //swashplate config - GUIConfigData.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; - GUIConfigData.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); + config.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; + config.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); //ccpm mixing options - GUIConfigData.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); - GUIConfigData.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); - GUIConfigData.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); - useCCPM = !(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState); - useCyclic = GUIConfigData.heli.ccpmLinkRollState; + config.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); + config.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); + config.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); + useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); + useCyclic = config.heli.ccpmLinkRollState; //correction angle - GUIConfigData.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value(); + config.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value(); //update sliders if (useCCPM) { - GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value(); + config.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value(); } else { - GUIConfigData.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value(); + config.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value(); } if (useCyclic) { - GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value(); + config.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value(); } else { - GUIConfigData.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value(); + config.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value(); } - GUIConfigData.heli.SliderValue2 = m_ccpm->ccpmRollScale->value(); + config.heli.SliderValue2 = m_ccpm->ccpmRollScale->value(); //servo assignments - GUIConfigData.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex(); - GUIConfigData.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex(); - GUIConfigData.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex(); - GUIConfigData.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex(); + config.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex(); + config.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex(); + config.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex(); + config.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex(); //throttle - GUIConfigData.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex(); + config.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex(); //tail - GUIConfigData.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex(); + config.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex(); + SetConfigData(config); + + //setMixer(); + + updatingFromHardware = FALSE; + return airframeType; } -void ConfigccpmWidget::UpdateCCPMUIFromOptions() + +void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() { + Q_UNUSED(frameType); + + GUIConfigDataUnion config = GetConfigData(); + //swashplate config - m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - (GUIConfigData.heli.SwashplateType +1)); - m_ccpm->ccpmSingleServo->setCurrentIndex(GUIConfigData.heli.FirstServoIndex); + setComboCurrentIndex( m_ccpm->ccpmType, m_ccpm->ccpmType->count() - (config.heli.SwashplateType +1)); + setComboCurrentIndex(m_ccpm->ccpmSingleServo, config.heli.FirstServoIndex); //ccpm mixing options - m_ccpm->ccpmCollectivePassthrough->setChecked(GUIConfigData.heli.ccpmCollectivePassthroughState); - m_ccpm->ccpmLinkCyclic->setChecked(GUIConfigData.heli.ccpmLinkCyclicState); - m_ccpm->ccpmLinkRoll->setChecked(GUIConfigData.heli.ccpmLinkRollState); + m_ccpm->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); + m_ccpm->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); + m_ccpm->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); //correction angle - m_ccpm->ccpmCorrectionAngle->setValue(GUIConfigData.heli.CorrectionAngle); + m_ccpm->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); //update sliders - m_ccpm->ccpmCollectiveScale->setValue(GUIConfigData.heli.SliderValue0); - m_ccpm->ccpmCollectiveScaleBox->setValue(GUIConfigData.heli.SliderValue0); - m_ccpm->ccpmCyclicScale->setValue(GUIConfigData.heli.SliderValue1); - m_ccpm->ccpmCyclicScaleBox->setValue(GUIConfigData.heli.SliderValue1); - m_ccpm->ccpmPitchScale->setValue(GUIConfigData.heli.SliderValue1); - m_ccpm->ccpmPitchScaleBox->setValue(GUIConfigData.heli.SliderValue1); - m_ccpm->ccpmRollScale->setValue(GUIConfigData.heli.SliderValue2); - m_ccpm->ccpmRollScaleBox->setValue(GUIConfigData.heli.SliderValue2); - m_ccpm->ccpmCollectiveSlider->setValue(GUIConfigData.heli.SliderValue0); - m_ccpm->ccpmCollectivespinBox->setValue(GUIConfigData.heli.SliderValue0); + m_ccpm->ccpmCollectiveScale->setValue(config.heli.SliderValue0); + m_ccpm->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); + m_ccpm->ccpmCyclicScale->setValue(config.heli.SliderValue1); + m_ccpm->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1); + m_ccpm->ccpmPitchScale->setValue(config.heli.SliderValue1); + m_ccpm->ccpmPitchScaleBox->setValue(config.heli.SliderValue1); + m_ccpm->ccpmRollScale->setValue(config.heli.SliderValue2); + m_ccpm->ccpmRollScaleBox->setValue(config.heli.SliderValue2); + m_ccpm->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); + m_ccpm->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); //servo assignments - m_ccpm->ccpmServoWChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexW); - m_ccpm->ccpmServoXChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexX); - m_ccpm->ccpmServoYChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexY); - m_ccpm->ccpmServoZChannel->setCurrentIndex(GUIConfigData.heli.ServoIndexZ); + setComboCurrentIndex(m_ccpm->ccpmServoWChannel, config.heli.ServoIndexW); + setComboCurrentIndex( m_ccpm->ccpmServoXChannel,config.heli.ServoIndexX); + setComboCurrentIndex( m_ccpm->ccpmServoYChannel,config.heli.ServoIndexY); + setComboCurrentIndex( m_ccpm->ccpmServoZChannel,config.heli.ServoIndexZ); //throttle - m_ccpm->ccpmEngineChannel->setCurrentIndex(GUIConfigData.heli.Throttle); + setComboCurrentIndex( m_ccpm->ccpmEngineChannel, config.heli.Throttle); //tail - m_ccpm->ccpmTailChannel->setCurrentIndex((GUIConfigData.heli.Tail)); + setComboCurrentIndex( m_ccpm->ccpmTailChannel, config.heli.Tail); + + //getMixer(); } void ConfigccpmWidget::SetUIComponentVisibilities() { - UpdateCCPMOptionsFromUI(); + GUIConfigDataUnion config = GetConfigData(); + //set which sliders are user... m_ccpm->ccpmRevoMixingBox->setVisible(0); - m_ccpm->ccpmPitchMixingBox->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState); - m_ccpm->ccpmCollectiveScalingBox->setVisible(GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState); + m_ccpm->ccpmPitchMixingBox->setVisible(!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState); + m_ccpm->ccpmCollectiveScalingBox->setVisible(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); - m_ccpm->ccpmLinkCyclic->setVisible(!GUIConfigData.heli.ccpmCollectivePassthroughState); + m_ccpm->ccpmLinkCyclic->setVisible(!config.heli.ccpmCollectivePassthroughState); - m_ccpm->ccpmCyclicScalingBox->setVisible((GUIConfigData.heli.ccpmCollectivePassthroughState || !GUIConfigData.heli.ccpmLinkCyclicState) && GUIConfigData.heli.ccpmLinkRollState); - if (!GUIConfigData.heli.ccpmCollectivePassthroughState && GUIConfigData.heli.ccpmLinkCyclicState) + m_ccpm->ccpmCyclicScalingBox->setVisible((config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState) && config.heli.ccpmLinkRollState); + if (!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState) { m_ccpm->ccpmPitchScalingBox->setVisible(0); m_ccpm->ccpmRollScalingBox->setVisible(0); @@ -1103,8 +1128,8 @@ void ConfigccpmWidget::SetUIComponentVisibilities() } else { - m_ccpm->ccpmPitchScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState); - m_ccpm->ccpmRollScalingBox->setVisible(!GUIConfigData.heli.ccpmLinkRollState); + m_ccpm->ccpmPitchScalingBox->setVisible(!config.heli.ccpmLinkRollState); + m_ccpm->ccpmRollScalingBox->setVisible(!config.heli.ccpmLinkRollState); m_ccpm->ccpmLinkRoll->setVisible(1); } @@ -1112,115 +1137,17 @@ void ConfigccpmWidget::SetUIComponentVisibilities() /** Request the current value of the SystemSettings which holds the ccpm type */ -void ConfigccpmWidget::requestccpmUpdate() +void ConfigccpmWidget::getMixer() { -#define MaxAngleError 2 - int MixerDataFromHeli[8][5]; - quint8 MixerOutputType[8]; - int EngineChannel,TailRotorChannel,ServoChannels[4],ServoAngles[4],SortAngles[4],ServoCurve2[4]; - int NumServos=0; - if (SwashLvlConfigurationInProgress)return; if (updatingToHardware)return; updatingFromHardware=TRUE; - unsigned int i,j; - -// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); -// Q_ASSERT(systemSettings); -// SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - -// Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == -// (sizeof(GUIConfigData.UAVObject) / sizeof(GUIConfigData.UAVObject[0]))); - -// for(i = 0; i < SystemSettings::GUICONFIGDATA_NUMELEM; i++) -// GUIConfigData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; - - GUIConfigData = GUIManager.GetConfigData(); - - UpdateCCPMUIFromOptions(); + int i; // Get existing mixer settings MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); - - //go through the user data and update the mixer matrix - for (j=0;j<5;j++) - { - MixerDataFromHeli[0][j] = mixerSettingsData.Mixer1Vector[j]; - MixerDataFromHeli[1][j] = mixerSettingsData.Mixer2Vector[j]; - MixerDataFromHeli[2][j] = mixerSettingsData.Mixer3Vector[j]; - MixerDataFromHeli[3][j] = mixerSettingsData.Mixer4Vector[j]; - MixerDataFromHeli[4][j] = mixerSettingsData.Mixer5Vector[j]; - MixerDataFromHeli[5][j] = mixerSettingsData.Mixer6Vector[j]; - MixerDataFromHeli[6][j] = mixerSettingsData.Mixer7Vector[j]; - MixerDataFromHeli[7][j] = mixerSettingsData.Mixer8Vector[j]; - } - - MixerOutputType[0] = mixerSettingsData.Mixer1Type; - MixerOutputType[1] = mixerSettingsData.Mixer2Type; - MixerOutputType[2] = mixerSettingsData.Mixer3Type; - MixerOutputType[3] = mixerSettingsData.Mixer4Type; - MixerOutputType[4] = mixerSettingsData.Mixer5Type; - MixerOutputType[5] = mixerSettingsData.Mixer6Type; - MixerOutputType[6] = mixerSettingsData.Mixer7Type; - MixerOutputType[7] = mixerSettingsData.Mixer8Type; - - EngineChannel =-1; - TailRotorChannel =-1; - for (j=0;j<5;j++) - { - ServoChannels[j]=8; - ServoCurve2[j]=0; - ServoAngles[j]=0; - SortAngles[j]=j; - } - - NumServos=0; - //process the data from Heli and try to figure out the settings... - for (i=0;i<8;i++) - { - //check if this is the engine... Throttle only - if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_MOTOR)&& - (MixerDataFromHeli[i][0]>0)&&//ThrottleCurve1 - (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 - (MixerDataFromHeli[i][2]==0)&&//Roll - (MixerDataFromHeli[i][3]==0)&&//Pitch - (MixerDataFromHeli[i][4]==0))//Yaw - { - EngineChannel = i; - //m_ccpm->ccpmEngineChannel->setCurrentIndex(i); - - } - //check if this is the tail rotor... REVO and YAW - if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& - //(MixerDataFromHeli[i][0]!=0)&&//ThrottleCurve1 - (MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 - (MixerDataFromHeli[i][2]==0)&&//Roll - (MixerDataFromHeli[i][3]==0)&&//Pitch - (MixerDataFromHeli[i][4]!=0))//Yaw - { - TailRotorChannel = i; - //m_ccpm->ccpmTailChannel->setCurrentIndex(i); - m_ccpm->ccpmRevoSlider->setValue((MixerDataFromHeli[i][0]*100)/127); - m_ccpm->ccpmREVOspinBox->setValue((MixerDataFromHeli[i][0]*100)/127); - } - //check if this is a swashplate servo... Throttle is zero - if ((MixerOutputType[i] == MixerSettings::MIXER1TYPE_SERVO)&& - (MixerDataFromHeli[i][0]==0)&&//ThrottleCurve1 - //(MixerDataFromHeli[i][1]==0)&&//ThrottleCurve2 - //(MixerDataFromHeli[i][2]==0)&&//Roll - //(MixerDataFromHeli[i][3]==0)&&//Pitch - (MixerDataFromHeli[i][4]==0))//Yaw - { - ServoChannels[NumServos] = i;//record the channel for this servo - ServoCurve2[NumServos]=MixerDataFromHeli[i][1];//record the ThrottleCurve2 contribution to this servo - ServoAngles[NumServos]=NumServos*45;//make this 0 for the final version - - NumServos++; - } - - } //get the settings for the curve from the mixer settings for (i=0;i<5;i++) @@ -1232,7 +1159,7 @@ void ConfigccpmWidget::requestccpmUpdate() } updatingFromHardware=FALSE; - UpdateCCPMUIFromOptions(); + ccpmSwashplateUpdate(); } @@ -1240,28 +1167,13 @@ void ConfigccpmWidget::requestccpmUpdate() /** Sends the config to the board (ccpm type) */ -void ConfigccpmWidget::sendccpmUpdate() +void ConfigccpmWidget::setMixer() { int i,j; if (SwashLvlConfigurationInProgress)return; updatingToHardware=TRUE; - //ShowDisclaimer(1); - - UpdateCCPMOptionsFromUI(); - GUIManager.SetConfigData(GUIConfigData); - - // Store the data required to reconstruct -// SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); -// Q_ASSERT(systemSettings); -// SystemSettings::DataFields systemSettingsData = systemSettings->getData(); -// for (i=0; isetData(systemSettingsData); -// systemSettings->updated(); - MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); Q_ASSERT(mixerSettings); MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); @@ -1316,7 +1228,7 @@ void ConfigccpmWidget::sendccpmUpdate() //mapping of collective input to curve 2... //MixerSettings.Curve2Source = Throttle,Roll,Pitch,Yaw,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5 //check if we are using throttle or directly from a channel... - if (GUIConfigData.heli.ccpmCollectivePassthroughState) + if (GetConfigData().heli.ccpmCollectivePassthroughState) mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_COLLECTIVE; else mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_THROTTLE; @@ -1335,7 +1247,8 @@ void ConfigccpmWidget::saveccpmUpdate() if (SwashLvlConfigurationInProgress)return; ShowDisclaimer(0); // Send update so that the latest value is saved - sendccpmUpdate(); + //sendccpmUpdate(); + setMixer(); UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); saveObjectToSD(obj); @@ -1402,7 +1315,8 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed() //download the current settings to the OP hw - sendccpmUpdate(); + //sendccpmUpdate(); + setMixer(); //change control mode to gcs control / disarmed //set throttle to 0 @@ -1427,10 +1341,10 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed() oldSwashLvlConfiguration.ServoChannels[2]=m_ccpm->ccpmServoYChannel->currentIndex(); oldSwashLvlConfiguration.ServoChannels[3]=m_ccpm->ccpmServoZChannel->currentIndex(); //if servos are used - oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()<8)&&(m_ccpm->ccpmServoWChannel->isEnabled())); - oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()<8)&&(m_ccpm->ccpmServoXChannel->isEnabled())); - oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()<8)&&(m_ccpm->ccpmServoYChannel->isEnabled())); - oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()<8)&&(m_ccpm->ccpmServoZChannel->isEnabled())); + oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled())); + oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled())); + oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled())); + oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled())); //min,neutral,max values for the servos for (i=0;iccpmServoWChannel->currentIndex()==0)&&(m_ccpm->ccpmServoWChannel->isEnabled())) + { + m_ccpm->ccpmServoWLabel->setText("Servo W"); + } + else + { + m_ccpm->ccpmServoWLabel->setText("Servo W"); + } + if((m_ccpm->ccpmServoXChannel->currentIndex()==0)&&(m_ccpm->ccpmServoXChannel->isEnabled())) + { + m_ccpm->ccpmServoXLabel->setText("Servo X"); + } + else + { + m_ccpm->ccpmServoXLabel->setText("Servo X"); + } + if((m_ccpm->ccpmServoYChannel->currentIndex()==0)&&(m_ccpm->ccpmServoYChannel->isEnabled())) + { + m_ccpm->ccpmServoYLabel->setText("Servo Y"); + } + else + { + m_ccpm->ccpmServoYLabel->setText("Servo Y"); + } + if((m_ccpm->ccpmServoZChannel->currentIndex()==0)&&(m_ccpm->ccpmServoZChannel->isEnabled())) + { + m_ccpm->ccpmServoZLabel->setText("Servo Z"); + } + else + { + m_ccpm->ccpmServoZLabel->setText("Servo Z"); + } + + if((m_ccpm->ccpmEngineChannel->currentIndex()==0)&&(m_ccpm->ccpmEngineChannel->isEnabled())) + { + m_ccpm->ccpmEngineLabel->setText("Engine"); + } + else + { + m_ccpm->ccpmEngineLabel->setText("Engine"); + } + + if((m_ccpm->ccpmTailChannel->currentIndex()==0)&&(m_ccpm->ccpmTailChannel->isEnabled())) + { + m_ccpm->ccpmTailLabel->setText("Tail Rotor"); + } + else + { + m_ccpm->ccpmTailLabel->setText("Tail Rotor"); + } + +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 75652c01b..cf7803393 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -29,7 +29,7 @@ #include "ui_ccpm.h" #include "../uavobjectwidgetutils/configtaskwidget.h" -#include "guiconfigdata.h" +#include "cfg_vehicletypes/vehicleconfig.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" @@ -50,33 +50,9 @@ typedef struct { int Neutral[CCPM_MAX_SWASH_SERVOS]; int Min[CCPM_MAX_SWASH_SERVOS]; } SwashplateServoSettingsStruct; -//typedef struct { -// uint SwasplateType:3; -// uint FirstServoIndex:2; -// uint CorrectionAngle:9; -// uint ccpmCollectivePassthroughState:1; -// uint ccpmLinkCyclicState:1; -// uint ccpmLinkRollState:1; -// uint SliderValue0:7; -// uint SliderValue1:7; -// uint SliderValue2:7;//41bits -// uint ServoIndexW:4; -// uint ServoIndexX:4; -// uint ServoIndexY:4; -// uint ServoIndexZ:4;//57bits -// uint Throttle:4; -// uint Tail:4; //65bits -// quint32 padding1:31; //96bits -// quint32 padding2; //128bits -//} __attribute__((packed)) heliGUISettingsStruct; -//typedef union -//{ -// uint UAVObject[4];//32bits * 4 -// heliGUISettingsStruct heli;//128bits -//} GUIConfigDataUnion; -class ConfigccpmWidget: public ConfigTaskWidget +class ConfigccpmWidget: public VehicleConfig { Q_OBJECT @@ -90,14 +66,6 @@ private: Ui_ccpmWidget *m_ccpm; QGraphicsSvgItem *SwashplateImg; QGraphicsSvgItem *CurveImg; - //QGraphicsSvgItem *ServoW; - //QGraphicsSvgItem *ServoX; - //QGraphicsSvgItem *ServoY; - //QGraphicsSvgItem *ServoZ; - //QGraphicsTextItem *ServoWText; - //QGraphicsTextItem *ServoXText; - //QGraphicsTextItem *ServoYText; - //QGraphicsTextItem *ServoZText; QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS]; QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS]; QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS]; @@ -112,9 +80,6 @@ private: SwashplateServoSettingsStruct oldSwashLvlConfiguration; SwashplateServoSettingsStruct newSwashLvlConfiguration; - GUIConfigDataManager GUIManager; - GUIConfigDataUnion GUIConfigData; - int MixerChannelData[6]; int ShowDisclaimer(int messageID); virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget @@ -122,7 +87,15 @@ private: bool updatingFromHardware; bool updatingToHardware; + virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual QStringList getChannelDescriptions(); + private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + virtual void throwConfigError(QString airframeType); + void ccpmSwashplateUpdate(); void ccpmSwashplateRedraw(); void UpdateCurveSettings(); @@ -139,11 +112,10 @@ private: void SwashLvlCancelButtonPressed(); void SwashLvlFinishButtonPressed(); - void UpdateCCPMOptionsFromUI(); - void UpdateCCPMUIFromOptions(); + //void UpdateCCPMOptionsFromUI(); + //void UpdateCCPMUIFromOptions(); void SetUIComponentVisibilities(); - void ccpmChannelCheck(); void enableSwashplateLevellingControl(bool state); void setSwashplateLevel(int percent); @@ -151,8 +123,8 @@ private: virtual void refreshValues() {}; // Not used public slots: - void requestccpmUpdate(); - void sendccpmUpdate(); + void getMixer(); + void setMixer(); void saveccpmUpdate(); protected: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 32ec686e2..0b6a026da 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -24,7 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//#include "configfixedwingwidget.h" +#include "configfixedwingwidget.h" #include "configvehicletypewidget.h" #include "mixersettings.h" @@ -40,18 +40,38 @@ #include "mixersettings.h" #include "systemsettings.h" +#include "actuatorsettings.h" #include "actuatorcommand.h" /** - Helper function to setup the UI + Constructor */ -void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType) +ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { + m_aircraft = aircraft; +} + +/** + Destructor + */ +ConfigFixedWingWidget::~ConfigFixedWingWidget() +{ + // Do nothing +} + + +/** + Virtual function to setup the UI + */ +void ConfigFixedWingWidget::setupUI(QString frameType) +{ + Q_ASSERT(m_aircraft); + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") { // Setup the UI - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing")); - m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fwRudder1ChannelBox->setEnabled(true); m_aircraft->fwRudder1Label->setEnabled(true); m_aircraft->fwRudder2ChannelBox->setEnabled(true); @@ -72,8 +92,8 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType) m_aircraft->elevonMixBox->setHidden(true); } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing")); - m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevon")); + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); m_aircraft->fwAileron1Label->setText("Elevon 1"); m_aircraft->fwAileron2Label->setText("Elevon 2"); m_aircraft->fwElevator1ChannelBox->setEnabled(false); @@ -91,8 +111,8 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType) m_aircraft->elevonLabel2->setText("Pitch"); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing")); - m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Vtail")); + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail")); m_aircraft->fwRudder1ChannelBox->setEnabled(false); m_aircraft->fwRudder1Label->setEnabled(false); m_aircraft->fwRudder2ChannelBox->setEnabled(false); @@ -111,12 +131,53 @@ void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType) } } +void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData) +{ + configData->fixedwing.FixedWingPitch1 = 0; + configData->fixedwing.FixedWingPitch2 = 0; + configData->fixedwing.FixedWingRoll1 = 0; + configData->fixedwing.FixedWingRoll2 = 0; + configData->fixedwing.FixedWingYaw1 = 0; + configData->fixedwing.FixedWingYaw2 = 0; + configData->fixedwing.FixedWingThrottle = 0; +} +QStringList ConfigFixedWingWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigFixedWingWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + if (configData.fixedwing.FixedWingPitch1 > 0) + channelDesc[configData.fixedwing.FixedWingPitch1-1] = QString("FixedWingPitch1"); + if (configData.fixedwing.FixedWingPitch2 > 0) + channelDesc[configData.fixedwing.FixedWingPitch2-1] = QString("FixedWingPitch2"); + if (configData.fixedwing.FixedWingRoll1 > 0) + channelDesc[configData.fixedwing.FixedWingRoll1-1] = QString("FixedWingRoll1"); + if (configData.fixedwing.FixedWingRoll2 > 0) + channelDesc[configData.fixedwing.FixedWingRoll2-1] = QString("FixedWingRoll2"); + if (configData.fixedwing.FixedWingYaw1 > 0) + channelDesc[configData.fixedwing.FixedWingYaw1-1] = QString("FixedWingYaw1"); + if (configData.fixedwing.FixedWingYaw2 > 0) + channelDesc[configData.fixedwing.FixedWingYaw2-1] = QString("FixedWingYaw2"); + if (configData.fixedwing.FixedWingThrottle > 0) + channelDesc[configData.fixedwing.FixedWingThrottle-1] = QString("FixedWingThrottle"); + + return channelDesc; +} /** - Helper function to update the UI widget objects + Virtual function to update the UI widget objects */ -QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets() +QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() { QString airframeType = "FixedWing"; @@ -144,21 +205,20 @@ QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets() airframeType = "FixedWingVtail"; setupFrameVtail( airframeType ); } - - // Now reflect those settings in the "Custom" panel as well - updateCustomAirframeUI(); - + return airframeType; } /** - Helper function to refresh the UI widget values + Virtual function to refresh the UI widget values */ -void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType) -{ - GUIConfigData = GUIManager.GetConfigData(); - fixedGUISettingsStruct fixed = GUIConfigData.fixed; +void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) +{ + Q_ASSERT(m_aircraft); + + GUIConfigDataUnion config = GetConfigData(); + fixedGUISettingsStruct fixed = config.fixedwing; // Then retrieve how channels are setup setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle); @@ -210,11 +270,11 @@ void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType) Returns False if impossible to create the mixer. */ -bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType) +bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) { // Check coherence: //Show any config errors in GUI - throwFixedWingChannelConfigError(airframeType); + throwConfigError(airframeType); // - At least Pitch and either Roll or Yaw if (m_aircraft->fwEngineChannelBox->currentText() == "None" || @@ -228,17 +288,17 @@ bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType) // Now setup the channels: - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); + config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); + config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + SetConfigData(config); UAVDataObject* obj; UAVObjectField* field; @@ -331,11 +391,11 @@ bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType) /** Setup Elevon */ -bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType) +bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) { // Check coherence: //Show any config errors in GUI - throwFixedWingChannelConfigError(airframeType); + throwConfigError(airframeType); // - At least Aileron1 and Aileron 2, and engine if (m_aircraft->fwEngineChannelBox->currentText() == "None" || @@ -346,16 +406,16 @@ bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType) return false; } - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); + config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); + config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + SetConfigData(config); UAVDataObject* obj; UAVObjectField* field; @@ -443,11 +503,11 @@ bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType) /** Setup VTail */ -bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType) +bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) { // Check coherence: //Show any config errors in GUI - throwFixedWingChannelConfigError(airframeType); + throwConfigError(airframeType); // - At least Pitch1 and Pitch2, and engine if (m_aircraft->fwEngineChannelBox->currentText() == "None" || @@ -458,16 +518,16 @@ bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType) return false; } - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIConfigData.fixed.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); - GUIConfigData.fixed.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); + config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); + config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); + config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); + config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + SetConfigData(config); UAVDataObject* obj; UAVObjectField* field; @@ -545,7 +605,7 @@ bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType) /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ -void ConfigVehicleTypeWidget::throwFixedWingChannelConfigError(QString airframeType) +void ConfigFixedWingWidget::throwConfigError(QString airframeType) { //Initialize configuration error flag bool error=false; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h new file mode 100644 index 000000000..8a39715f0 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -0,0 +1,74 @@ +/** + ****************************************************************************** + * + * @file configairframetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Airframe configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGFIXEDWINGWIDGET_H +#define CONFIGFIXEDWINGWIDGET_H + +#include "ui_airframe.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "uavtalk/telemetrymanager.h" +#include +#include +#include + +class Ui_Widget; + +class ConfigFixedWingWidget: public VehicleConfig +{ + Q_OBJECT + +public: + ConfigFixedWingWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ~ConfigFixedWingWidget(); + + friend class ConfigVehicleTypeWidget; + +private: + Ui_AircraftWidget *m_aircraft; + + bool setupFrameFixedWing(QString airframeType); + bool setupFrameElevon(QString airframeType); + bool setupFrameVtail(QString airframeType); + + virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual QStringList getChannelDescriptions(); + +private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + virtual void throwConfigError(QString airframeType); + + +protected: + +}; + + +#endif // CONFIGFIXEDWINGWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index b7b31b0f6..cee0a4d88 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -24,7 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//#include "configgroundvehiclewidget.h" +#include "configgroundvehiclewidget.h" #include "configvehicletypewidget.h" #include "mixersettings.h" @@ -40,18 +40,35 @@ #include "mixersettings.h" #include "systemsettings.h" +#include "actuatorsettings.h" #include "actuatorcommand.h" /** - Helper function to setup the UI + Constructor */ -void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType) +ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) +{ + m_aircraft = aircraft; +} + +/** + Destructor + */ +ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget() +{ + // Do nothing +} + +/** + Virtual function to setup the UI + */ +void ConfigGroundVehicleWidget::setupUI(QString frameType) { m_aircraft->differentialSteeringMixBox->setHidden(true); //STILL NEEDS WORK // Setup the UI - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Ground")); + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); m_aircraft->gvEngineChannelBox->setEnabled(false); m_aircraft->gvEngineLabel->setEnabled(false); @@ -64,7 +81,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType) m_aircraft->gvAileron2Label->setEnabled(false); if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank - m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Differential (tank)")); + setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)")); m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1Label->setEnabled(true); @@ -89,7 +106,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType) } else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle - m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Motorcycle")); + setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle")); m_aircraft->gvMotor1ChannelBox->setEnabled(false); m_aircraft->gvMotor1Label->setEnabled(false); @@ -113,7 +130,7 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType) m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); } else {//Car - m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)")); + setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)")); m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1Label->setEnabled(true); @@ -137,12 +154,46 @@ void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType) } } +void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData) +{ + configData->ground.GroundVehicleSteering1 = 0; + configData->ground.GroundVehicleSteering2 = 0; + configData->ground.GroundVehicleThrottle1 = 0; + configData->ground.GroundVehicleThrottle2 = 0; +} + +QStringList ConfigGroundVehicleWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + if (configData.ground.GroundVehicleSteering1 > 0) + channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1"); + if (configData.ground.GroundVehicleSteering2 > 0) + channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2"); + if (configData.ground.GroundVehicleThrottle1 > 0) + channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1"); + if (configData.ground.GroundVehicleThrottle2 > 0) + channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2"); + + return channelDesc; +} + /** - Helper function to update the UI widget objects + Virtual function to update the UI widget objects */ -QString ConfigVehicleTypeWidget::updateGroundVehicleObjectsFromWidgets() +QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() { QString airframeType = "GroundVehicleCar"; @@ -176,32 +227,28 @@ QString ConfigVehicleTypeWidget::updateGroundVehicleObjectsFromWidgets() airframeType = "GroundVehicleMotorcycle"; setupGroundVehicleMotorcycle(airframeType); } - - // Now reflect those settings in the "Custom" panel as well - updateCustomAirframeUI(); - + return airframeType; } /** - Helper function to refresh the UI widget values + Virtual function to refresh the UI widget values */ -void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameType) +void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { - UAVDataObject* obj; UAVObjectField *field; - GUIConfigData = GUIManager.GetConfigData(); + GUIConfigDataUnion config = GetConfigData(); //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values - setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, GUIConfigData.ground.GroundVehicleThrottle1); - setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, GUIConfigData.ground.GroundVehicleThrottle2); - setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, GUIConfigData.ground.GroundVehicleSteering1); - setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, GUIConfigData.ground.GroundVehicleSteering2); + setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1); + setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2); + setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1); + setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2); if (frameType == "GroundVehicleDifferential") { //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE @@ -237,17 +284,15 @@ void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameTyp } - - /** Setup balancing ground vehicle. Returns False if impossible to create the mixer. */ -bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType){ +bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType){ // Check coherence: //Show any config errors in GUI - throwGroundVehicleChannelConfigError(airframeType); + throwConfigError(airframeType); // - Motor, steering, and balance if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" || @@ -259,13 +304,13 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType) // Now setup the channels: - GUIConfigData = GUIManager.GetConfigData(); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIManager.ResetActuators(&GUIConfigData); - GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); - GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + SetConfigData(config); UAVObject* obj; UAVObjectField* field; @@ -356,10 +401,10 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType) Returns False if impossible to create the mixer. */ -bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeType){ +bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType){ // Check coherence: //Show any config errors in GUI - throwGroundVehicleChannelConfigError(airframeType); + throwConfigError(airframeType); // - Left and right steering if ( m_aircraft->gvMotor2ChannelBox->currentText() == "None" || @@ -370,13 +415,13 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeTyp // Now setup the channels: - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); - GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); - GUIManager.SetConfigData((GUIConfigData)); + SetConfigData((config)); UAVObject* obj; UAVObjectField* field; @@ -457,11 +502,11 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeTyp Returns False if impossible to create the mixer. */ -bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType) +bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) { // Check coherence: //Show any config errors in GUI - throwGroundVehicleChannelConfigError(airframeType); + throwConfigError(airframeType); // - At least one motor and one steering servo if ((m_aircraft->gvMotor1ChannelBox->currentText() == "None" && @@ -490,15 +535,15 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType) // } // Now setup the channels: - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + ResetActuators(&config); - GUIConfigData.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); - GUIConfigData.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); - GUIConfigData.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); - GUIConfigData.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); + config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); + config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); + config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + SetConfigData(config); UAVDataObject* obj; UAVObjectField* field; @@ -599,7 +644,7 @@ bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType) /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ -void ConfigVehicleTypeWidget::throwGroundVehicleChannelConfigError(QString airframeType) +void ConfigGroundVehicleWidget::throwConfigError(QString airframeType) { //Initialize configuration error flag bool error=false; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h new file mode 100644 index 000000000..1e7b378e4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -0,0 +1,74 @@ +/** + ****************************************************************************** + * + * @file configairframetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Airframe configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGGROUNDVEHICLEWIDGET_H +#define CONFIGGROUNDVEHICLEWIDGET_H + +#include "ui_airframe.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "uavtalk/telemetrymanager.h" +#include +#include +#include + +class Ui_Widget; + +class ConfigGroundVehicleWidget: public VehicleConfig +{ + Q_OBJECT + +public: + ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ~ConfigGroundVehicleWidget(); + + friend class ConfigVehicleTypeWidget; + +private: + Ui_AircraftWidget *m_aircraft; + + bool setupGroundVehicleCar(QString airframeType); + bool setupGroundVehicleDifferential(QString airframeType); + bool setupGroundVehicleMotorcycle(QString airframeType); + + virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual QStringList getChannelDescriptions(); + +private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + virtual void throwConfigError(QString airframeType); + + +protected: + +}; + + +#endif // CONFIGGROUNDVEHICLEWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index e6701f002..81e537696 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -24,8 +24,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -//#include "configmultirotorwidget.h" -#include "configvehicletypewidget.h" +#include "configmultirotorwidget.h" #include "mixersettings.h" #include @@ -34,201 +33,206 @@ #include #include #include +#include #include #include #include #include "mixersettings.h" #include "systemsettings.h" +#include "actuatorsettings.h" #include "actuatorcommand.h" -#include "guiconfigdata.h" //#define Pi 3.14159265358979323846 /** - Helper function to setup the UI + Constructor */ -void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) +ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { - if (frameType == "Tri" || frameType == "Tricopter Y") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Tricopter Y")); + m_aircraft = aircraft; +} + +/** + Destructor + */ +ConfigMultiRotorWidget::~ConfigMultiRotorWidget() +{ + // Do nothing +} + + +void ConfigMultiRotorWidget::setupUI(QString frameType) +{ + Q_ASSERT(m_aircraft); + Q_ASSERT(quad); + + // set aircraftType to Multirotor, disable triyaw channel + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); + m_aircraft->triYawChannelBox->setEnabled(false); + + // disable all motor channel boxes + for (int i=1; i <=8; i++) { + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(false); + } + + if (frameType == "Tri" || frameType == "Tricopter Y") { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y")); quad->setElementId("tri"); //Enable all necessary motor channel boxes... for (int i=1; i <=3; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); - } - //and grey out all unused motor channel boxes - for (int i=4; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - m_aircraft->triYawChannelBox->setEnabled(true); - } else if (frameType == "QuadX" || frameType == "Quad X") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X")); + m_aircraft->triYawChannelBox->setEnabled(true); + } + else if (frameType == "QuadX" || frameType == "Quad X") { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X")); quad->setElementId("quad-X"); //Enable all necessary motor channel boxes... for (int i=1; i <=4; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - //and grey out all unused motor channel boxes - for (int i=5; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); - } - - m_aircraft->triYawChannelBox->setEnabled(false); + m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(50); m_aircraft->mrYawMixLevel->setValue(50); - } else if (frameType == "QuadP" || frameType == "Quad +") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad +")); + } + else if (frameType == "QuadP" || frameType == "Quad +") { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +")); quad->setElementId("quad-plus"); //Enable all necessary motor channel boxes... for (int i=1; i <=4; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); - } - //and grey out all unused motor channel boxes - for (int i=5; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - m_aircraft->triYawChannelBox->setEnabled(false); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); m_aircraft->mrYawMixLevel->setValue(50); - } else if (frameType == "Hexa" || frameType == "Hexacopter") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter")); + } + else if (frameType == "Hexa" || frameType == "Hexacopter") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); quad->setElementId("quad-hexa"); //Enable all necessary motor channel boxes... for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - //and grey out all unused motor channel boxes - for (int i=7; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); - } - - m_aircraft->triYawChannelBox->setEnabled(false); + m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(33); m_aircraft->mrYawMixLevel->setValue(33); - } else if (frameType == "HexaX" || frameType == "Hexacopter X" ) { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter X")); + } + else if (frameType == "HexaX" || frameType == "Hexacopter X" ) { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X")); quad->setElementId("quad-hexa-H"); //Enable all necessary motor channel boxes... for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - //and grey out all unused motor channel boxes - for (int i=7; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); - } - - m_aircraft->triYawChannelBox->setEnabled(false); + m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(50); m_aircraft->mrYawMixLevel->setValue(33); - } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); + } + else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); quad->setElementId("hexa-coax"); //Enable all necessary motor channel boxes... for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - //and grey out all unused motor channel boxes - for (int i=7; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(false); - } - - m_aircraft->triYawChannelBox->setEnabled(false); + m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(50); m_aircraft->mrYawMixLevel->setValue(66); - } else if (frameType == "Octo" || frameType == "Octocopter") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter")); + } + else if (frameType == "Octo" || frameType == "Octocopter") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); quad->setElementId("quad-octo"); //Enable all necessary motor channel boxes for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - - m_aircraft->triYawChannelBox->setEnabled(false); + m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(33); m_aircraft->mrYawMixLevel->setValue(25); - } else if (frameType == "OctoV" || frameType == "Octocopter V") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter V")); + } + else if (frameType == "OctoV" || frameType == "Octocopter V") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V")); quad->setElementId("quad-octo-v"); //Enable all necessary motor channel boxes for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - m_aircraft->triYawChannelBox->setEnabled(false); m_aircraft->mrRollMixLevel->setValue(25); m_aircraft->mrPitchMixLevel->setValue(25); m_aircraft->mrYawMixLevel->setValue(25); - } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax +")); + } + else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); quad->setElementId("octo-coax-P"); //Enable all necessary motor channel boxes for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - m_aircraft->triYawChannelBox->setEnabled(false); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); m_aircraft->mrYawMixLevel->setValue(50); - } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor")); - m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax X")); + } + else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") + { + setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); quad->setElementId("octo-coax-X"); //Enable all necessary motor channel boxes for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); - combobox->setEnabled(true); + QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); + if (combobox) + combobox->setEnabled(true); } - m_aircraft->triYawChannelBox->setEnabled(false); m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(50); m_aircraft->mrYawMixLevel->setValue(50); @@ -236,12 +240,61 @@ void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType) } } +void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData) +{ + configData->multi.VTOLMotorN = 0; + configData->multi.VTOLMotorNE = 0; + configData->multi.VTOLMotorE = 0; + configData->multi.VTOLMotorSE = 0; + configData->multi.VTOLMotorS = 0; + configData->multi.VTOLMotorSW = 0; + configData->multi.VTOLMotorW = 0; + configData->multi.VTOLMotorNW = 0; + configData->multi.TRIYaw = 0; +} + +QStringList ConfigMultiRotorWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + multiGUISettingsStruct multi = configData.multi; + + if (multi.VTOLMotorN > 0 && multi.VTOLMotorN < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN"); + if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE"); + if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW"); + if (multi.VTOLMotorS > 0 && multi.VTOLMotorS < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS"); + if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE"); + if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW"); + if (multi.VTOLMotorW > 0 && multi.VTOLMotorW < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW"); + if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < ConfigMultiRotorWidget::CHANNEL_NUMELEM) + channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE"); + + return channelDesc; +} + + /** Helper function to update the UI widget objects */ -QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() +QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() { QString airframeType; QList motorList; @@ -280,7 +333,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "HexaCoax"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(6); + throwConfigError(6); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || @@ -314,7 +367,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "Octo"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(8); + throwConfigError(8); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || @@ -349,7 +402,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "OctoV"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(8); + throwConfigError(8); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || @@ -385,7 +438,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "OctoCoaxP"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(8); + throwConfigError(8); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || @@ -420,7 +473,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "OctoCoaxX"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(8); + throwConfigError(8); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || @@ -455,7 +508,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() airframeType = "Tri"; //Show any config errors in GUI - throwMultiRotorChannelConfigError(3); + throwConfigError(3); if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || m_aircraft->multiMotorChannelBox2->currentText() == "None" || m_aircraft->multiMotorChannelBox3->currentText() == "None" ) { @@ -469,9 +522,9 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS"; setupMotors(motorList); - GUIConfigData = GUIManager.GetConfigData(); - GUIConfigData.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex(); - GUIManager.SetConfigData(GUIConfigData); + GUIConfigDataUnion config = GetConfigData(); + config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex(); + SetConfigData(config); // Motor 1 to 6, Y6 Layout: @@ -499,9 +552,7 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK"); - } - // Now reflect those settings in the "Custom" panel as well - updateCustomAirframeUI(); + } return airframeType; } @@ -511,14 +562,10 @@ QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets() /** Helper function to refresh the UI widget values */ -void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) +void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) { - ////////////////////////////////////////////////////////////////// - // Retrieve settings - ////////////////////////////////////////////////////////////////// - - GUIConfigData = GUIManager.GetConfigData(); - multiGUISettingsStruct multi = GUIConfigData.multi; + GUIConfigDataUnion config = GetConfigData(); + multiGUISettingsStruct multi = config.multi; UAVDataObject* obj; UAVObjectField *field; @@ -794,9 +841,10 @@ void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType) /** Helper function: setupQuadMotor */ -void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw) +void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw) { qDebug()<(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); UAVObjectField *field = obj->getField(mixerTypes.at(channel)); @@ -822,15 +870,15 @@ void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double r /** Helper function: setup motors. Takes a list of channel names in input. */ -void ConfigVehicleTypeWidget::setupMotors(QList motorList) +void ConfigMultiRotorWidget::setupMotors(QList motorList) { QList mmList; mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; - GUIConfigData = GUIManager.GetConfigData(); - GUIManager.ResetActuators(&GUIConfigData); + GUIConfigDataUnion configData = GetConfigData(); + ResetActuators(&configData); int index; foreach (QString motor, motorList) { @@ -840,23 +888,23 @@ void ConfigVehicleTypeWidget::setupMotors(QList motorList) //qDebug()< motorList) /** Set up a Quad-X or Quad-P mixer */ -bool ConfigVehicleTypeWidget::setupQuad(bool pLayout) +bool ConfigMultiRotorWidget::setupQuad(bool pLayout) { // Check coherence: //Show any config errors in GUI - throwMultiRotorChannelConfigError(4); + throwConfigError(4); // - Four engines have to be defined if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || @@ -941,11 +989,11 @@ bool ConfigVehicleTypeWidget::setupQuad(bool pLayout) /** Set up a Hexa-X or Hexa-P mixer */ -bool ConfigVehicleTypeWidget::setupHexa(bool pLayout) +bool ConfigMultiRotorWidget::setupHexa(bool pLayout) { // Check coherence: //Show any config errors in GUI - throwMultiRotorChannelConfigError(6); + throwConfigError(6); // - Four engines have to be defined if (m_aircraft->multiMotorChannelBox1->currentText() == "None" || @@ -1022,7 +1070,7 @@ bool ConfigVehicleTypeWidget::setupHexa(bool pLayout) /** This function sets up the multirotor mixer values. */ -bool ConfigVehicleTypeWidget::setupMultiRotorMixer(double mixerFactors[8][3]) +bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) { qDebug()<<"Mixer factors"; qDebug()<(this, "multiMotorChannelBox" + QString::number(i+1)); + QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i+1)); if (combobox){ //if QLabel exists - QLabel *label = qFindChild(this, "MotorOutputLabel" + QString::number(i+1)); +// QLabel *label = qFindChild(this, "MotorOutputLabel" + QString::number(i+1)); + if (combobox->currentText() == "None") { // label->setText("" + label->text() + ""); @@ -1106,3 +1155,5 @@ void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors) m_aircraft->mrStatusLabel->setText(QString("ERROR: Assign all %1 motor channels").arg(numMotors)); } } + + diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h new file mode 100644 index 000000000..e7dc101e2 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * + * @file configairframetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Airframe configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGMULTIROTORWIDGET_H +#define CONFIGMULTIROTORWIDGET_H + +#include "ui_airframe.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" + +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "uavtalk/telemetrymanager.h" +#include +#include +#include + +class Ui_Widget; + +class ConfigMultiRotorWidget: public VehicleConfig +{ + Q_OBJECT + +public: + ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ~ConfigMultiRotorWidget(); + + friend class ConfigVehicleTypeWidget; + +private: + Ui_AircraftWidget *m_aircraft; + + QGraphicsSvgItem *quad; + + bool setupQuad(bool pLayout); + bool setupHexa(bool pLayout); + bool setupOcto(); + bool setupMultiRotorMixer(double mixerFactors[8][3]); + void setupMotors(QList motorList); + void setupQuadMotor(int channel, double roll, double pitch, double yaw); + + virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual QStringList getChannelDescriptions(); + +private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + void throwConfigError(int numMotors); + + +protected: + + +}; + + +#endif // CONFIGMULTIROTORWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp deleted file mode 100644 index 5e8d1c7ee..000000000 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.cpp +++ /dev/null @@ -1,328 +0,0 @@ - -/** - ****************************************************************************** - * - * @file guiconfigdata.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. - * @addtogroup GCSPlugins GCS Plugins - * @{ - * @addtogroup ConfigPlugin Config Plugin - * @{ - * @brief bit storage of config ui settings - *****************************************************************************/ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include "guiconfigdata.h" -#include "extensionsystem/pluginmanager.h" -#include "uavobjectmanager.h" -#include "uavobject.h" - -#include "systemsettings.h" - -#include - -GUIConfigDataManager::GUIConfigDataManager() -{ -} - -GUIConfigDataManager::~GUIConfigDataManager() -{ - // Do nothing -} - -GUIConfigDataUnion GUIConfigDataManager::GetConfigData() { - - int i; - GUIConfigDataUnion configData; - - // get an instance of systemsettings - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - - // copy systemsettings -> local configData - for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) - configData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; - - // sanity check - Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == - (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); - - return configData; -} - -void GUIConfigDataManager::SetConfigData(GUIConfigDataUnion configData) { - - int i; - - // sanity check - Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == - (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); - - // get an instance of systemsettings - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - - // copy parameter configData -> systemsettings - for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) - systemSettingsData.GUIConfigData[i] = configData.UAVObject[i]; - - systemSettings->setData(systemSettingsData); - systemSettings->updated(); -} - -void GUIConfigDataManager::ResetActuators() -{ - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - - // reset the actuators by airframe type - ResetActuators(&configData); - - // set the gui config data - SetConfigData(configData); - -} - -void GUIConfigDataManager::ResetActuators(GUIConfigDataUnion* configData) -{ - // get systemsettings for airframe type - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - - switch (systemSettingsData.AirframeType) - { - // fixed wing - case SystemSettings::AIRFRAMETYPE_FIXEDWING: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: - { - configData->fixed.FixedWingPitch1 = 0; - configData->fixed.FixedWingPitch2 = 0; - configData->fixed.FixedWingRoll1 = 0; - configData->fixed.FixedWingRoll2 = 0; - configData->fixed.FixedWingYaw1 = 0; - configData->fixed.FixedWingYaw2 = 0; - configData->fixed.FixedWingThrottle = 0; - } - break; - - // helicp - case SystemSettings::AIRFRAMETYPE_HELICP: - { - configData->heli.Throttle = 0; - configData->heli.Tail = 0; - configData->heli.ServoIndexW = 0; - configData->heli.ServoIndexX = 0; - configData->heli.ServoIndexY = 0; - configData->heli.ServoIndexZ = 0; - } - break; - - //multirotor - case SystemSettings::AIRFRAMETYPE_VTOL: - case SystemSettings::AIRFRAMETYPE_TRI: - case SystemSettings::AIRFRAMETYPE_QUADX: - case SystemSettings::AIRFRAMETYPE_QUADP: - case SystemSettings::AIRFRAMETYPE_OCTOV: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: - case SystemSettings::AIRFRAMETYPE_OCTO: - case SystemSettings::AIRFRAMETYPE_HEXAX: - case SystemSettings::AIRFRAMETYPE_HEXACOAX: - case SystemSettings::AIRFRAMETYPE_HEXA: - { - configData->multi.VTOLMotorN = 0; - configData->multi.VTOLMotorNE = 0; - configData->multi.VTOLMotorE = 0; - configData->multi.VTOLMotorSE = 0; - configData->multi.VTOLMotorS = 0; - configData->multi.VTOLMotorSW = 0; - configData->multi.VTOLMotorW = 0; - configData->multi.VTOLMotorNW = 0; - configData->multi.TRIYaw = 0; - } - break; - - // ground - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: - { - configData->ground.GroundVehicleSteering1 = 0; - configData->ground.GroundVehicleSteering2 = 0; - configData->ground.GroundVehicleThrottle1 = 0; - configData->ground.GroundVehicleThrottle2 = 0; - } - break; - - } -} - -QStringList GUIConfigDataManager::getChannelDescriptions() -{ - int i; - QStringList channelDesc; - - // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(GUIConfigDataManager::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); - } - - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - - // get systemsettings for airframe type - SystemSettings * systemSettings = SystemSettings::GetInstance(getObjectManager()); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - - switch (systemSettingsData.AirframeType) - { - // fixed wing - case SystemSettings::AIRFRAMETYPE_FIXEDWING: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: - { - if (configData.fixed.FixedWingPitch1 > 0) - channelDesc[configData.fixed.FixedWingPitch1-1] = QString("FixedWingPitch1"); - if (configData.fixed.FixedWingPitch2 > 0) - channelDesc[configData.fixed.FixedWingPitch2-1] = QString("FixedWingPitch2"); - if (configData.fixed.FixedWingRoll1 > 0) - channelDesc[configData.fixed.FixedWingRoll1-1] = QString("FixedWingRoll1"); - if (configData.fixed.FixedWingRoll2 > 0) - channelDesc[configData.fixed.FixedWingRoll2-1] = QString("FixedWingRoll2"); - if (configData.fixed.FixedWingYaw1 > 0) - channelDesc[configData.fixed.FixedWingYaw1-1] = QString("FixedWingYaw1"); - if (configData.fixed.FixedWingYaw2 > 0) - channelDesc[configData.fixed.FixedWingYaw2-1] = QString("FixedWingYaw2"); - if (configData.fixed.FixedWingThrottle > 0) - channelDesc[configData.fixed.FixedWingThrottle-1] = QString("FixedWingThrottle"); - - return channelDesc; - } - break; - - // helicp - case SystemSettings::AIRFRAMETYPE_HELICP: - { - channelDesc[configData.heli.Throttle] = QString("Throttle"); - channelDesc[configData.heli.Tail] = QString("Tail"); - - switch(configData.heli.FirstServoIndex) - { - case 0: //front - channelDesc[configData.heli.ServoIndexW] = QString("Elevator"); - channelDesc[configData.heli.ServoIndexX] = QString("Roll1"); - channelDesc[configData.heli.ServoIndexY] = QString("Roll2"); - break; - - case 1: //right - channelDesc[configData.heli.ServoIndexW] = QString("ServoW"); - channelDesc[configData.heli.ServoIndexX] = QString("ServoX"); - channelDesc[configData.heli.ServoIndexY] = QString("ServoY"); - break; - - case 2: //rear - channelDesc[configData.heli.ServoIndexW] = QString("Elevator"); - channelDesc[configData.heli.ServoIndexX] = QString("Roll1"); - channelDesc[configData.heli.ServoIndexY] = QString("Roll2"); - break; - - case 3: //left - channelDesc[configData.heli.ServoIndexW] = QString("ServoW"); - channelDesc[configData.heli.ServoIndexX] = QString("ServoX"); - channelDesc[configData.heli.ServoIndexY] = QString("ServoY"); - break; - - } - if (configData.heli.ServoIndexZ < 8) - channelDesc[configData.heli.ServoIndexZ] = QString("ServoZ"); - - return channelDesc; - } - break; - - //multirotor - case SystemSettings::AIRFRAMETYPE_VTOL: - case SystemSettings::AIRFRAMETYPE_TRI: - case SystemSettings::AIRFRAMETYPE_QUADX: - case SystemSettings::AIRFRAMETYPE_QUADP: - case SystemSettings::AIRFRAMETYPE_OCTOV: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: - case SystemSettings::AIRFRAMETYPE_OCTO: - case SystemSettings::AIRFRAMETYPE_HEXAX: - case SystemSettings::AIRFRAMETYPE_HEXACOAX: - case SystemSettings::AIRFRAMETYPE_HEXA: - { - multiGUISettingsStruct multi = configData.multi; - - if (multi.VTOLMotorN > 0 && multi.VTOLMotorN < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN"); - if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE"); - if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW"); - if (multi.VTOLMotorS > 0 && multi.VTOLMotorS < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS"); - if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE"); - if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW"); - if (multi.VTOLMotorW > 0 && multi.VTOLMotorW < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW"); - if (multi.VTOLMotorE > 0 && multi.VTOLMotorE < GUIConfigDataManager::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE"); - - return channelDesc; - } - break; - - // ground - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: - { - if (configData.ground.GroundVehicleSteering1 > 0) - channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1"); - if (configData.ground.GroundVehicleSteering2 > 0) - channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2"); - if (configData.ground.GroundVehicleThrottle1 > 0) - channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1"); - if (configData.ground.GroundVehicleThrottle2 > 0) - channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2"); - - return channelDesc; - } - break; - } - - return channelDesc; -} -/** - * Util function to get a pointer to the object manager - * @return pointer to the UAVObjectManager - */ -UAVObjectManager* GUIConfigDataManager::getObjectManager() { - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager * objMngr = pm->getObject(); - Q_ASSERT(objMngr); - return objMngr; -} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp new file mode 100644 index 000000000..e00ad6605 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -0,0 +1,143 @@ + +/** + ****************************************************************************** + * + * @file vehicleconfig.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief bit storage of config ui settings + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "cfg_vehicletypes/vehicleconfig.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" + +#include "systemsettings.h" + +#include + +VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) +{ + for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { + mixerTypes << QString("Mixer%1Type").arg(i+1); + mixerVectors << QString("Mixer%1Vector").arg(i+1); + } +} + +VehicleConfig::~VehicleConfig() +{ + // Do nothing +} + +GUIConfigDataUnion VehicleConfig::GetConfigData() { + + int i; + GUIConfigDataUnion configData; + + // get an instance of systemsettings + SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + // copy systemsettings -> local configData + for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) + configData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; + + // sanity check + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == + (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + + return configData; +} + +void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { + + int i; + + // sanity check + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == + (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + + // get an instance of systemsettings + SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + // copy parameter configData -> systemsettings + for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) + systemSettingsData.GUIConfigData[i] = configData.UAVObject[i]; + + systemSettings->setData(systemSettingsData); + systemSettings->updated(); + + //emit ConfigurationChanged(); +} + +void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData) +{ +} +QStringList VehicleConfig::getChannelDescriptions() +{ + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (int i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + return channelDesc; +} + +/** + Helper function: + Sets the current index on supplied combobox to index + if it is within bounds 0 <= index < combobox.count() + */ +void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index) +{ + Q_ASSERT(box); + + if (index >= 0 && index < box->count()) + box->setCurrentIndex(index); +} + + +/** + Reset the contents of a field + */ +void VehicleConfig::resetField(UAVObjectField * field) +{ + for (unsigned int i=0;igetNumElements();i++) { + field->setValue(0,i); + } +} + + +/** + * Util function to get a pointer to the object manager + * @return pointer to the UAVObjectManager + */ +UAVObjectManager* VehicleConfig::getUAVObjectManager() { + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager * objMngr = pm->getObject(); + Q_ASSERT(objMngr); + return objMngr; +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h similarity index 78% rename from ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h rename to ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 9c92faa0e..45e1739c1 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/guiconfigdata.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -1,7 +1,7 @@ /** ****************************************************************************** * - * @file guiconfigdata.h + * @file vehicleconfig.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup GCSPlugins GCS Plugins * @{ @@ -24,14 +24,15 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef GUICONFIGDATA_H -#define GUICONFIGDATA_H - +#ifndef GUIVEHICLECONFIG_H +#define GUIVEHICLECONFIG_H +#include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" + typedef struct { uint VTOLMotorN:4; uint VTOLMotorS:4; @@ -96,39 +97,46 @@ typedef union { uint UAVObject[4]; //32bits * 4 heliGUISettingsStruct heli; //128bits - fixedGUISettingsStruct fixed; + fixedGUISettingsStruct fixedwing; multiGUISettingsStruct multi; groundGUISettingsStruct ground; } GUIConfigDataUnion; -class GUIConfigDataManager: public QObject + +class VehicleConfig: public ConfigTaskWidget { Q_OBJECT public: - GUIConfigDataManager(); - ~GUIConfigDataManager(); + VehicleConfig(QWidget *parent = 0); + ~VehicleConfig(); - GUIConfigDataUnion GetConfigData(); - void SetConfigData(GUIConfigDataUnion configData); - QStringList getChannelDescriptions(); - void ResetActuators(); - void ResetActuators(GUIConfigDataUnion* configData); + static GUIConfigDataUnion GetConfigData(); + static void SetConfigData(GUIConfigDataUnion configData); + static void resetField(UAVObjectField * field); + static void setComboCurrentIndex(QComboBox* box, int index); + + virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual QStringList getChannelDescriptions(); + + QStringList mixerTypes; + QStringList mixerVectors; static const quint32 CHANNEL_NUMELEM = 10; - friend class ConfigTaskWidget; - private: - UAVObjectManager* getObjectManager(); + + static UAVObjectManager* getUAVObjectManager(); private slots: public slots: + signals: + //void ConfigurationChanged(); protected: }; -#endif // GUICONFIGDATA_H +#endif // GUIVEHICLECONFIG_H diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index c90640517..0d703bee4 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -32,7 +32,10 @@ HEADERS += configplugin.h \ configtxpidwidget.h \ outputchannelform.h \ config_global.h \ - cfg_vehicletypes/guiconfigdata.h + cfg_vehicletypes/configmultirotorwidget.h \ + cfg_vehicletypes/configgroundvehiclewidget.h \ + cfg_vehicletypes/configfixedwingwidget.h \ + cfg_vehicletypes/vehicleconfig.h SOURCES += configplugin.cpp \ configgadgetconfiguration.cpp \ configgadgetwidget.cpp \ @@ -62,7 +65,7 @@ SOURCES += configplugin.cpp \ cfg_vehicletypes/configfixedwingwidget.cpp \ cfg_vehicletypes/configccpmwidget.cpp \ outputchannelform.cpp \ - cfg_vehicletypes/guiconfigdata.cpp + cfg_vehicletypes/vehicleconfig.cpp FORMS += airframe.ui \ cc_hw_settings.ui \ pro_hw_settings.ui \ diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index 48e7f487c..9cb37e3b3 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -27,6 +27,7 @@ #include "configoutputwidget.h" #include "outputchannelform.h" +#include "configvehicletypewidget.h" #include "uavtalk/telemetrymanager.h" @@ -250,8 +251,8 @@ void ConfigOutputWidget::refreshWidgetsValues() Q_ASSERT(actuatorSettings); ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData(); - // get helicp channel descriptions based on mixer settings - QStringList ChannelDesc = GUIManager.getChannelDescriptions(); + // get channel descriptions + QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions(); // Initialize output forms QList outputChannelForms = findChildren(); diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index 3881b8f36..9a3a32fdf 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -33,7 +33,7 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "uavobjectutilmanager.h" -#include "cfg_vehicletypes/guiconfigdata.h" +#include "cfg_vehicletypes/vehicleconfig.h" #include #include @@ -63,8 +63,6 @@ private: UAVObject::Metadata accInitialData; - GUIConfigDataManager GUIManager; - bool firstUpdate; bool wasItMe; diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 1fec3f05c..66eb50fe4 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -103,7 +103,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi addUAVObject("MixerSettings"); addUAVObject("ActuatorSettings"); - ffTuningInProgress = false; ffTuningPhase = false; @@ -119,7 +118,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi QStringList airframeTypes; airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom"; m_aircraft->aircraftType->addItems(airframeTypes); - m_aircraft->aircraftType->setCurrentIndex(1); + m_aircraft->aircraftType->setCurrentIndex(0); QStringList fixedWingTypes; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; @@ -138,27 +137,13 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi m_aircraft->multirotorFrameType->addItems(multiRotorTypes); m_aircraft->multirotorFrameType->setCurrentIndex(1); //Set default model to "Quad +" - // Now load all the channel assignements - //OLD STYLE: DO IT MANUALLY -// m_aircraft->triYawChannelBox->addItems(channels); -// m_aircraft->gvMotor1ChannelBox->addItems(channels); -// m_aircraft->gvMotor2ChannelBox->addItems(channels); -// m_aircraft->gvSteering1ChannelBox->addItems(channels); -// m_aircraft->gvSteering2ChannelBox->addItems(channels); -// m_aircraft->fwElevator1ChannelBox->addItems(channels); -// m_aircraft->fwElevator2ChannelBox->addItems(channels); -// m_aircraft->fwEngineChannelBox->addItems(channels); -// m_aircraft->fwRudder1ChannelBox->addItems(channels); -// m_aircraft->fwRudder2ChannelBox->addItems(channels); -// m_aircraft->fwAileron1ChannelBox->addItems(channels); -// m_aircraft->fwAileron2ChannelBox->addItems(channels); //NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name foreach(QComboBox *combobox, this->findChildren(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate { - combobox->addItems(channels); - } + combobox->addItems(channels); + } // Setup the Multirotor picture in the Quad settings interface m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -188,6 +173,19 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } + m_multirotor = new ConfigMultiRotorWidget(m_aircraft, this); + m_multirotor->quad = quad; + m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText()); + + m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft, this); + m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() ); + + m_fixedwing = new ConfigFixedWingWidget(m_aircraft, this); + m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() ); + + m_heli = m_aircraft->widget_3;// new ConfigccpmWidget(this); + m_heli->setupUI(QString("HeliCP")); + //Connect aircraft type selection dropbox to callback function connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -195,6 +193,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); + //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); //Connect throttle curve reset pushbuttons to reset functions connect(m_aircraft->fwThrottleReset, SIGNAL(clicked()), this, SLOT(resetFwMixer())); @@ -220,19 +219,13 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); - //WHAT DOES THIS DO? - enableControls(false); - refreshWidgetsValues(); - // Connect the help pushbutton connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); + + enableControls(false); + refreshWidgetsValues(); addToDirtyMonitor(); - - //Initialize GUI tabs //MOVING THIS FROM THE END OF THIS FUNCTION CAN CAUSE RUNTIME ERRORS DUE TO setupMultiRotorUI. WHY? - setupMultiRotorUI( m_aircraft->multirotorFrameType->currentText() ); - setupGroundVehicleUI( m_aircraft->groundVehicleType->currentText() ); - setupFixedWingUI( m_aircraft->fixedWingType->currentText() ); - + disbleMouseWheelEvents(); } @@ -245,12 +238,90 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() // Do nothing } +QStringList ConfigVehicleTypeWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager * objMngr = pm->getObject(); + Q_ASSERT(objMngr); + + // get an instance of systemsettings + SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + switch (systemSettingsData.AirframeType) + { + // fixed wing + case SystemSettings::AIRFRAMETYPE_FIXEDWING: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: + { + ConfigFixedWingWidget* fixedwing = new ConfigFixedWingWidget(); + channelDesc = fixedwing->getChannelDescriptions(); + } + break; + + // helicp + case SystemSettings::AIRFRAMETYPE_HELICP: + { + ConfigccpmWidget* heli = new ConfigccpmWidget(); + channelDesc = heli->getChannelDescriptions(); + } + break; + + //multirotor + case SystemSettings::AIRFRAMETYPE_VTOL: + case SystemSettings::AIRFRAMETYPE_TRI: + case SystemSettings::AIRFRAMETYPE_QUADX: + case SystemSettings::AIRFRAMETYPE_QUADP: + case SystemSettings::AIRFRAMETYPE_OCTOV: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: + case SystemSettings::AIRFRAMETYPE_OCTO: + case SystemSettings::AIRFRAMETYPE_HEXAX: + case SystemSettings::AIRFRAMETYPE_HEXACOAX: + case SystemSettings::AIRFRAMETYPE_HEXA: + { + ConfigMultiRotorWidget* multi = new ConfigMultiRotorWidget(); + channelDesc = multi->getChannelDescriptions(); + } + break; + + // ground + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + { + ConfigGroundVehicleWidget* ground = new ConfigGroundVehicleWidget(); + channelDesc = ground->getChannelDescriptions(); + } + break; + + default: + { + for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) + channelDesc.append(QString("-")); + } + break; + } + +// for (i=0; i < channelDesc.count(); i++) +// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]); + + return channelDesc; +} + + /** Slot for switching the airframe type. We do it explicitely rather than a signal in the UI, because we want to force a fitInView of the quad shapes. This is because this method (fitinview) only works when the widget is shown. */ -void ConfigVehicleTypeWidget::switchAirframeType(int index){ +void ConfigVehicleTypeWidget::switchAirframeType(int index) +{ m_aircraft->airframesWidget->setCurrentIndex(index); m_aircraft->quadShape->setSceneRect(quad->boundingRect()); m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); @@ -609,7 +680,7 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues() if (frameType.startsWith("FixedWing")) { // Retrieve fixed wing settings - refreshFixedWingWidgetsValues(frameType); + m_fixedwing->refreshWidgetsValues(frameType); } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || @@ -617,17 +688,18 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues() frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) { // Retrieve multirotor settings - refreshMultiRotorWidgetsValues(frameType); + m_multirotor->refreshWidgetsValues(frameType); } else if (frameType == "HeliCP") { - m_aircraft->widget_3->requestccpmUpdate(); - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Helicopter"));//"Helicopter" + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); + m_heli->refreshWidgetsValues(frameType); + } else if (frameType.startsWith("GroundVehicle")) { - // Retrieve ground vehicle settings - refreshGroundVehicleWidgetsValues(frameType); + // Retrieve ground vehicle settings + m_groundvehicle->refreshWidgetsValues(frameType); } else if (frameType == "Custom") { - m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Custom")); + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); } @@ -641,13 +713,13 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues() */ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) { - bool dirty=isDirty(); if(frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" || frameType == "Elevon" || - frameType == "FixedWingVtail" || frameType == "Vtail"){ - setupFixedWingUI(frameType); - } else if (frameType == "Tri" || frameType == "Tricopter Y" || + frameType == "FixedWingVtail" || frameType == "Vtail"){ + m_fixedwing->setupUI(frameType); + } + else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" || @@ -657,13 +729,16 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) frameType == "OctoV" || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" ) { - //Call multi-rotor setup UI - setupMultiRotorUI(frameType); + //Call multi-rotor setup UI + m_multirotor->setupUI(frameType); } + else if (frameType == "HeliCP") { + m_heli->setupUI(frameType); + } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" || - frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { - setupGroundVehicleUI(frameType); + frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { + m_groundvehicle->setupUI(frameType); } //SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST??? @@ -684,26 +759,6 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) } } - -/** - Reset actuator values - */ -void ConfigVehicleTypeWidget::resetActuators() -{ - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - Q_ASSERT(obj); - QList fieldList = obj->getFields(); - // Reset all assignements first: - foreach (UAVObjectField* field, fieldList) { - // NOTE: we assume that all options in ActuatorSettings are a channel assignement - // except for the options called "ChannelBoxXXX" - if (field->getUnits().contains("channel")) { - field->setValue(field->getOptions().last()); - } - } -} - - /** Updates the custom airframe settings based on the current airframe. @@ -711,58 +766,77 @@ void ConfigVehicleTypeWidget::resetActuators() */ void ConfigVehicleTypeWidget::updateCustomAirframeUI() { - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - UAVObjectField* field = obj->getField(QString("ThrottleCurve1")); QList curveValues; - // If the 1st element of the curve is <= -10, then the curve - // is a straight line (that's how the mixer works on the mainboard): - if (field->getValue(0).toInt() <= -10) { - m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1); - } else { - double temp=0; - double value; - for (unsigned int i=0; i < field->getNumElements(); i++) { - value=field->getValue(i).toDouble(); - temp+=value; - curveValues.append(value); - } - if(temp==0) + + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(obj); + + UAVObjectField* field = obj->getField(QString("ThrottleCurve1")); + if (field) + { + // If the 1st element of the curve is <= -10, then the curve + // is a straight line (that's how the mixer works on the mainboard): + if (field->getValue(0).toInt() <= -10) { m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1); - else - m_aircraft->customThrottle1Curve->initCurve(curveValues); - } - - field = obj->getField(QString("ThrottleCurve2")); - curveValues.clear(); - // If the 1st element of the curve is <= -10, then the curve - // is a straight line (that's how the mixer works on the mainboard): - if (field->getValue(0).toInt() <= -10) { - m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1); - } else { - for (unsigned int i=0; i < field->getNumElements(); i++) { - curveValues.append(field->getValue(i).toDouble()); + } else { + double temp=0; + double value; + for (unsigned int i=0; i < field->getNumElements(); i++) { + value=field->getValue(i).toDouble(); + temp+=value; + curveValues.append(value); + } + if(temp==0) + m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1); + else + m_aircraft->customThrottle1Curve->initCurve(curveValues); + } + } + + curveValues.clear(); + + field = obj->getField(QString("ThrottleCurve2")); + if (field) + { + // If the 1st element of the curve is <= -10, then the curve + // is a straight line (that's how the mixer works on the mainboard): + if (field->getValue(0).toInt() <= -10) { + m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1); + } else { + for (unsigned int i=0; i < field->getNumElements(); i++) { + curveValues.append(field->getValue(i).toDouble()); + } + m_aircraft->customThrottle2Curve->initCurve(curveValues); } - m_aircraft->customThrottle2Curve->initCurve(curveValues); } // Update the table: for (int i=0; i<8; i++) { field = obj->getField(mixerTypes.at(i)); - QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i); - QString s = field->getValue().toString(); - q->setCurrentIndex(q->findText(s)); - //bool en = (s != "Disabled"); - field = obj->getField(mixerVectors.at(i)); - int ti = field->getElementNames().indexOf("ThrottleCurve1"); - m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString()); - ti = field->getElementNames().indexOf("ThrottleCurve2"); - m_aircraft->customMixerTable->item(2,i)->setText(field->getValue(ti).toString()); - ti = field->getElementNames().indexOf("Roll"); - m_aircraft->customMixerTable->item(3,i)->setText(field->getValue(ti).toString()); - ti = field->getElementNames().indexOf("Pitch"); - m_aircraft->customMixerTable->item(4,i)->setText(field->getValue(ti).toString()); - ti = field->getElementNames().indexOf("Yaw"); - m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString()); + if (field) + { + QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i); + if (q) + { + QString s = field->getValue().toString(); + setComboCurrentIndex(q, q->findText(s)); + } + + field = obj->getField(mixerVectors.at(i)); + if (field) + { + int ti = field->getElementNames().indexOf("ThrottleCurve1"); + m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString()); + ti = field->getElementNames().indexOf("ThrottleCurve2"); + m_aircraft->customMixerTable->item(2,i)->setText(field->getValue(ti).toString()); + ti = field->getElementNames().indexOf("Roll"); + m_aircraft->customMixerTable->item(3,i)->setText(field->getValue(ti).toString()); + ti = field->getElementNames().indexOf("Pitch"); + m_aircraft->customMixerTable->item(4,i)->setText(field->getValue(ti).toString()); + ti = field->getElementNames().indexOf("Yaw"); + m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString()); + } + } } } @@ -776,20 +850,19 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() */ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() { - qDebug()<<"updateObjectsFromWidgets"; QString airframeType = "Custom"; //Sets airframe type default to "Custom" if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { - airframeType = updateFixedWingObjectsFromWidgets(); - } else if (m_aircraft->aircraftType->currentText() == "Multirotor") { - //update the mixer - airframeType = updateMultiRotorObjectsFromWidgets(); - } else if (m_aircraft->aircraftType->currentText() == "Helicopter") { - airframeType = "HeliCP"; - m_aircraft->widget_3->sendccpmUpdate(); - } else if (m_aircraft->aircraftType->currentText() == "Ground") { - airframeType = updateGroundVehicleObjectsFromWidgets(); - } else { - airframeType = "Custom"; + airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Multirotor") { + airframeType = m_multirotor->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Helicopter") { + airframeType = m_heli->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Ground") { + airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); + } UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); UAVObjectField* field = obj->getField(QString("FeedForward")); @@ -826,13 +899,12 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti); } - } - - //WHAT DOES THIS DO? - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - UAVObjectField* field = obj->getField(QString("AirframeType")); + // set the airframe type + obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + field = obj->getField(QString("AirframeType")); field->setValue(airframeType); + updateCustomAirframeUI(); } /** @@ -893,44 +965,44 @@ void ConfigVehicleTypeWidget::addToDirtyMonitor() addWidget(m_aircraft->fwRudder2ChannelBox); addWidget(m_aircraft->elevonSlider1); addWidget(m_aircraft->elevonSlider2); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmType); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmTailChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmEngineChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoWChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoXChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoYChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmSingleServo); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoZChannel); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleW); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleX); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCorrectionAngle); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleZ); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleY); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivePassthrough); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkRoll); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkCyclic); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmRevoSlider); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmREVOspinBox); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveSlider); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivespinBox); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScale); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScaleBox); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmCyclicScale); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScale); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScaleBox); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScale); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScaleBox); - addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSlider); - addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSpinBox); - addWidget(m_aircraft->widget_3->m_ccpm->CurveType); - addWidget(m_aircraft->widget_3->m_ccpm->NumCurvePoints); - addWidget(m_aircraft->widget_3->m_ccpm->CurveValue1); - addWidget(m_aircraft->widget_3->m_ccpm->CurveValue2); - addWidget(m_aircraft->widget_3->m_ccpm->CurveValue3); - addWidget(m_aircraft->widget_3->m_ccpm->CurveToGenerate); - addWidget(m_aircraft->widget_3->m_ccpm->CurveSettings); - addWidget(m_aircraft->widget_3->m_ccpm->ThrottleCurve); - addWidget(m_aircraft->widget_3->m_ccpm->PitchCurve); - addWidget(m_aircraft->widget_3->m_ccpm->ccpmAdvancedSettingsTable); + addWidget(m_heli->m_ccpm->ccpmType); + addWidget(m_heli->m_ccpm->ccpmTailChannel); + addWidget(m_heli->m_ccpm->ccpmEngineChannel); + addWidget(m_heli->m_ccpm->ccpmServoWChannel); + addWidget(m_heli->m_ccpm->ccpmServoXChannel); + addWidget(m_heli->m_ccpm->ccpmServoYChannel); + addWidget(m_heli->m_ccpm->ccpmSingleServo); + addWidget(m_heli->m_ccpm->ccpmServoZChannel); + addWidget(m_heli->m_ccpm->ccpmAngleW); + addWidget(m_heli->m_ccpm->ccpmAngleX); + addWidget(m_heli->m_ccpm->ccpmCorrectionAngle); + addWidget(m_heli->m_ccpm->ccpmAngleZ); + addWidget(m_heli->m_ccpm->ccpmAngleY); + addWidget(m_heli->m_ccpm->ccpmCollectivePassthrough); + addWidget(m_heli->m_ccpm->ccpmLinkRoll); + addWidget(m_heli->m_ccpm->ccpmLinkCyclic); + addWidget(m_heli->m_ccpm->ccpmRevoSlider); + addWidget(m_heli->m_ccpm->ccpmREVOspinBox); + addWidget(m_heli->m_ccpm->ccpmCollectiveSlider); + addWidget(m_heli->m_ccpm->ccpmCollectivespinBox); + addWidget(m_heli->m_ccpm->ccpmCollectiveScale); + addWidget(m_heli->m_ccpm->ccpmCollectiveScaleBox); + addWidget(m_heli->m_ccpm->ccpmCyclicScale); + addWidget(m_heli->m_ccpm->ccpmPitchScale); + addWidget(m_heli->m_ccpm->ccpmPitchScaleBox); + addWidget(m_heli->m_ccpm->ccpmRollScale); + addWidget(m_heli->m_ccpm->ccpmRollScaleBox); + addWidget(m_heli->m_ccpm->SwashLvlPositionSlider); + addWidget(m_heli->m_ccpm->SwashLvlPositionSpinBox); + addWidget(m_heli->m_ccpm->CurveType); + addWidget(m_heli->m_ccpm->NumCurvePoints); + addWidget(m_heli->m_ccpm->CurveValue1); + addWidget(m_heli->m_ccpm->CurveValue2); + addWidget(m_heli->m_ccpm->CurveValue3); + addWidget(m_heli->m_ccpm->CurveToGenerate); + addWidget(m_heli->m_ccpm->CurveSettings); + addWidget(m_heli->m_ccpm->ThrottleCurve); + addWidget(m_heli->m_ccpm->PitchCurve); + addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable); } diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index 59a97277c..d9af3c968 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -33,7 +33,12 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" -#include "cfg_vehicletypes/guiconfigdata.h" + +#include "cfg_vehicletypes/configccpmwidget.h" +#include "cfg_vehicletypes/configfixedwingwidget.h" +#include "cfg_vehicletypes/configmultirotorwidget.h" +#include "cfg_vehicletypes/configgroundvehiclewidget.h" + #include #include #include @@ -48,27 +53,24 @@ public: ConfigVehicleTypeWidget(QWidget *parent = 0); ~ConfigVehicleTypeWidget(); + static QStringList getChannelDescriptions(); + private: Ui_AircraftWidget *m_aircraft; - bool setupFrameFixedWing(QString airframeType); - bool setupFrameElevon(QString airframeType); - bool setupFrameVtail(QString airframeType); - bool setupQuad(bool pLayout); - bool setupHexa(bool pLayout); - bool setupOcto(); - bool setupGroundVehicleCar(QString airframeType); - bool setupGroundVehicleDifferential(QString airframeType); - bool setupGroundVehicleMotorcycle(QString airframeType); + + ConfigccpmWidget *m_heli; + ConfigFixedWingWidget *m_fixedwing; + ConfigMultiRotorWidget *m_multirotor; + ConfigGroundVehicleWidget *m_groundvehicle; + void updateCustomAirframeUI(); - bool setupMultiRotorMixer(double mixerFactors[8][3]); - void setupMotors(QList motorList); void addToDirtyMonitor(); void resetField(UAVObjectField * field); void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue); - void resetActuators(); + //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector); - void setupQuadMotor(int channel, double roll, double pitch, double yaw); - void setComboCurrentIndex(QComboBox* box, int index); + + QStringList mixerTypes; QStringList mixerVectors; QGraphicsSvgItem *quad; @@ -76,29 +78,15 @@ private: bool ffTuningPhase; UAVObject::Metadata accInitialData; - GUIConfigDataManager GUIManager; - GUIConfigDataUnion GUIConfigData; - private slots: + virtual void refreshWidgetsValues(); - void refreshFixedWingWidgetsValues(QString frameType); - void refreshMultiRotorWidgetsValues(QString frameType); - void refreshGroundVehicleWidgetsValues(QString frameType); - - void updateObjectsFromWidgets(); - QString updateFixedWingObjectsFromWidgets(); - QString updateMultiRotorObjectsFromWidgets(); - QString updateGroundVehicleObjectsFromWidgets(); - // void saveAircraftUpdate(); + virtual void updateObjectsFromWidgets(); + + void setComboCurrentIndex(QComboBox* box, int index); + void setupAirframeUI(QString type); - void setupFixedWingUI(QString frameType); - void setupMultiRotorUI(QString frameType); - void setupGroundVehicleUI(QString frameType); - - void throwMultiRotorChannelConfigError(int numMotors); - void throwFixedWingChannelConfigError(QString airframeType); - void throwGroundVehicleChannelConfigError(QString airframeType); void toggleAileron2(int index); void toggleElevator2(int index); From 2db4f6b2b6c96457547af1dbee5eb279b181891a Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Tue, 22 May 2012 09:55:50 -0700 Subject: [PATCH 06/15] Resolves mixer/advanced tab switching issue; semi-centralized channelNames; renames ConfigCcpmWidget --- .../src/plugins/config/airframe.ui | 26 +---- .../cfg_vehicletypes/configccpmwidget.cpp | 86 ++++++++-------- .../cfg_vehicletypes/configccpmwidget.h | 6 +- .../configmultirotorwidget.cpp | 97 ++++++++----------- .../cfg_vehicletypes/configmultirotorwidget.h | 3 + .../config/cfg_vehicletypes/vehicleconfig.cpp | 14 +++ .../config/cfg_vehicletypes/vehicleconfig.h | 2 + .../config/configvehicletypewidget.cpp | 33 ++++--- .../plugins/config/configvehicletypewidget.h | 6 +- 9 files changed, 134 insertions(+), 139 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 0dcc5ec57..bf44988d8 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -1376,7 +1376,7 @@ margin:1px; 0 - + @@ -2801,12 +2801,12 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> @@ -2910,7 +2910,7 @@ p, li { white-space: pre-wrap; } 1 - ConfigccpmWidget + ConfigCcpmWidget QWidget
cfg_vehicletypes/configccpmwidget.h
1 @@ -3016,22 +3016,6 @@ p, li { white-space: pre-wrap; } - - mrPitchMixLevel - valueChanged(int) - mrPitchMixValue - setNum(int) - - - 83 - 228 - - - 82 - 168 - - - mrRollMixLevel valueChanged(int) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index f8fbbb67f..fee50819a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -44,7 +44,7 @@ #define Pi 3.14159265358979323846 -ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent) +ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) { int i; SwashLvlConfigurationInProgress=0; @@ -143,20 +143,20 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent) UAVObjectField * curve2source = mixerSettings->getField("Curve2Source"); Q_ASSERT(curve2source); - QStringList channels; - channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" << - "Channel5" << "Channel6" << "Channel7" << "Channel8"; - m_ccpm->ccpmEngineChannel->addItems(channels); +// QStringList channels; +// channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" << +// "Channel5" << "Channel6" << "Channel7" << "Channel8"; + m_ccpm->ccpmEngineChannel->addItems(channelNames); m_ccpm->ccpmEngineChannel->setCurrentIndex(0); - m_ccpm->ccpmTailChannel->addItems(channels); + m_ccpm->ccpmTailChannel->addItems(channelNames); m_ccpm->ccpmTailChannel->setCurrentIndex(0); - m_ccpm->ccpmServoWChannel->addItems(channels); + m_ccpm->ccpmServoWChannel->addItems(channelNames); m_ccpm->ccpmServoWChannel->setCurrentIndex(0); - m_ccpm->ccpmServoXChannel->addItems(channels); + m_ccpm->ccpmServoXChannel->addItems(channelNames); m_ccpm->ccpmServoXChannel->setCurrentIndex(0); - m_ccpm->ccpmServoYChannel->addItems(channels); + m_ccpm->ccpmServoYChannel->addItems(channelNames); m_ccpm->ccpmServoYChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->addItems(channels); + m_ccpm->ccpmServoZChannel->addItems(channelNames); m_ccpm->ccpmServoZChannel->setCurrentIndex(0); QStringList Types; @@ -222,16 +222,16 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent) ccpmSwashplateRedraw(); } -ConfigccpmWidget::~ConfigccpmWidget() +ConfigCcpmWidget::~ConfigCcpmWidget() { // Do nothing } -void ConfigccpmWidget::setupUI(QString frameType) +void ConfigCcpmWidget::setupUI(QString frameType) { } -void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData) { configData->heli.Throttle = 0; configData->heli.Tail = 0; @@ -241,13 +241,13 @@ void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData) configData->heli.ServoIndexZ = 0; } -QStringList ConfigccpmWidget::getChannelDescriptions() +QStringList ConfigCcpmWidget::getChannelDescriptions() { int i; QStringList channelDesc; // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigccpmWidget::CHANNEL_NUMELEM); i++) + for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) { channelDesc.append(QString("-")); } @@ -306,7 +306,7 @@ QStringList ConfigccpmWidget::getChannelDescriptions() return channelDesc; } -void ConfigccpmWidget::UpdateType() +void ConfigCcpmWidget::UpdateType() { int TypeInt,SingleServoIndex,NumServosDefined; QString TypeText; @@ -483,12 +483,12 @@ void ConfigccpmWidget::UpdateType() /** Resets a mixer curve */ -void ConfigccpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements) +void ConfigCcpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements) { mixer->initLinearCurve(numElements,(double)1); } -void ConfigccpmWidget::UpdateCurveWidgets() +void ConfigCcpmWidget::UpdateCurveWidgets() { int NumCurvePoints,i,Changed; QList curveValues; @@ -522,7 +522,7 @@ void ConfigccpmWidget::UpdateCurveWidgets() if (Changed==1)m_ccpm->PitchCurve->setCurve(curveValues); } -void ConfigccpmWidget::updatePitchCurveValue(QList curveValues0,double Value0) +void ConfigCcpmWidget::updatePitchCurveValue(QList curveValues0,double Value0) { Q_UNUSED(curveValues0); Q_UNUSED(Value0); @@ -546,7 +546,7 @@ void ConfigccpmWidget::updatePitchCurveValue(QList curveValues0,double V } -void ConfigccpmWidget::updateThrottleCurveValue(QList curveValues0,double Value0) +void ConfigCcpmWidget::updateThrottleCurveValue(QList curveValues0,double Value0) { Q_UNUSED(curveValues0); Q_UNUSED(Value0); @@ -571,7 +571,7 @@ void ConfigccpmWidget::updateThrottleCurveValue(QList curveValues0,doubl } -void ConfigccpmWidget::UpdateCurveSettings() +void ConfigCcpmWidget::UpdateCurveSettings() { int NumCurvePoints,i; double scale; @@ -701,7 +701,7 @@ void ConfigccpmWidget::UpdateCurveSettings() UpdateCurveWidgets(); } -void ConfigccpmWidget::GenerateCurve() +void ConfigCcpmWidget::GenerateCurve() { int NumCurvePoints,CurveToGenerate,i; double value1, value2, value3, scale; @@ -771,7 +771,7 @@ void ConfigccpmWidget::GenerateCurve() } -void ConfigccpmWidget::ccpmSwashplateRedraw() +void ConfigCcpmWidget::ccpmSwashplateRedraw() { double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY; int used[CCPM_MAX_SWASH_SERVOS],defined[CCPM_MAX_SWASH_SERVOS],i; @@ -872,14 +872,14 @@ void ConfigccpmWidget::ccpmSwashplateRedraw() //m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio); } -void ConfigccpmWidget::ccpmSwashplateUpdate() +void ConfigCcpmWidget::ccpmSwashplateUpdate() { ccpmSwashplateRedraw(); SetUIComponentVisibilities(); UpdateMixer(); } -void ConfigccpmWidget::UpdateMixer() +void ConfigCcpmWidget::UpdateMixer() { bool useCCPM; bool useCyclic; @@ -995,7 +995,7 @@ void ConfigccpmWidget::UpdateMixer() } } -QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() +QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() { QString airframeType = "HeliCP"; @@ -1061,7 +1061,7 @@ QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr return airframeType; } -void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() +void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() { Q_UNUSED(frameType); @@ -1106,8 +1106,10 @@ void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro } -void ConfigccpmWidget::SetUIComponentVisibilities() +void ConfigCcpmWidget::SetUIComponentVisibilities() { + //mdl updateObjectsFromWidgets(); + GUIConfigDataUnion config = GetConfigData(); //set which sliders are user... @@ -1137,7 +1139,7 @@ void ConfigccpmWidget::SetUIComponentVisibilities() /** Request the current value of the SystemSettings which holds the ccpm type */ -void ConfigccpmWidget::getMixer() +void ConfigCcpmWidget::getMixer() { if (SwashLvlConfigurationInProgress)return; if (updatingToHardware)return; @@ -1167,7 +1169,7 @@ void ConfigccpmWidget::getMixer() /** Sends the config to the board (ccpm type) */ -void ConfigccpmWidget::setMixer() +void ConfigCcpmWidget::setMixer() { int i,j; @@ -1242,7 +1244,7 @@ void ConfigccpmWidget::setMixer() /** Send ccpm type to the board and request saving to SD card */ -void ConfigccpmWidget::saveccpmUpdate() +void ConfigCcpmWidget::saveccpmUpdate() { if (SwashLvlConfigurationInProgress)return; ShowDisclaimer(0); @@ -1254,7 +1256,7 @@ void ConfigccpmWidget::saveccpmUpdate() saveObjectToSD(obj); } -void ConfigccpmWidget::resizeEvent(QResizeEvent* event) +void ConfigCcpmWidget::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); // Make the custom table columns autostretch: @@ -1266,7 +1268,7 @@ void ConfigccpmWidget::resizeEvent(QResizeEvent* event) ccpmSwashplateRedraw(); } -void ConfigccpmWidget::showEvent(QShowEvent *event) +void ConfigCcpmWidget::showEvent(QShowEvent *event) { Q_UNUSED(event) m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents(); @@ -1278,7 +1280,7 @@ void ConfigccpmWidget::showEvent(QShowEvent *event) } -void ConfigccpmWidget::SwashLvlStartButtonPressed() +void ConfigCcpmWidget::SwashLvlStartButtonPressed() { QMessageBox msgBox; int i; @@ -1377,7 +1379,7 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed() } -void ConfigccpmWidget::SwashLvlNextButtonPressed() +void ConfigCcpmWidget::SwashLvlNextButtonPressed() { //ShowDisclaimer(2); SwashLvlState++; @@ -1480,7 +1482,7 @@ void ConfigccpmWidget::SwashLvlNextButtonPressed() break; } } -void ConfigccpmWidget::SwashLvlCancelButtonPressed() +void ConfigCcpmWidget::SwashLvlCancelButtonPressed() { int i; SwashLvlState=0; @@ -1528,7 +1530,7 @@ void ConfigccpmWidget::SwashLvlCancelButtonPressed() } -void ConfigccpmWidget::SwashLvlFinishButtonPressed() +void ConfigCcpmWidget::SwashLvlFinishButtonPressed() { int i; @@ -1572,7 +1574,7 @@ void ConfigccpmWidget::SwashLvlFinishButtonPressed() } -int ConfigccpmWidget::ShowDisclaimer(int messageID) +int ConfigCcpmWidget::ShowDisclaimer(int messageID) { QMessageBox msgBox; msgBox.setText("

Warning!!!

"); @@ -1621,7 +1623,7 @@ int ConfigccpmWidget::ShowDisclaimer(int messageID) Toggles the channel testing mode by making the GCS take over the ActuatorCommand objects */ -void ConfigccpmWidget::enableSwashplateLevellingControl(bool state) +void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state) { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); @@ -1661,7 +1663,7 @@ void ConfigccpmWidget::enableSwashplateLevellingControl(bool state) Sets the swashplate level to a given value based on current settings for Max, Neutral and Min values. level ranges -1 to +1 */ -void ConfigccpmWidget::setSwashplateLevel(int percent) +void ConfigCcpmWidget::setSwashplateLevel(int percent) { if (percent<0)return;// -1; if (percent>100)return;// -1; @@ -1696,7 +1698,7 @@ return; } -void ConfigccpmWidget::SwashLvlSpinBoxChanged(int value) +void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value) { Q_UNUSED(value); int i; @@ -1740,7 +1742,7 @@ void ConfigccpmWidget::SwashLvlSpinBoxChanged(int value) /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ -void ConfigccpmWidget::throwConfigError(QString airframeType) +void ConfigCcpmWidget::throwConfigError(QString airframeType) { Q_UNUSED(airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index cf7803393..ac609773d 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -52,13 +52,13 @@ typedef struct { } SwashplateServoSettingsStruct; -class ConfigccpmWidget: public VehicleConfig +class ConfigCcpmWidget: public VehicleConfig { Q_OBJECT public: - ConfigccpmWidget(QWidget *parent = 0); - ~ConfigccpmWidget(); + ConfigCcpmWidget(QWidget *parent = 0); + ~ConfigCcpmWidget(); friend class ConfigVehicleTypeWidget; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 81e537696..8c5cf664e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -52,6 +52,9 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { m_aircraft = aircraft; + + //connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); + } /** @@ -66,17 +69,23 @@ ConfigMultiRotorWidget::~ConfigMultiRotorWidget() void ConfigMultiRotorWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); + Q_ASSERT(uiowner); Q_ASSERT(quad); + int i; + // set aircraftType to Multirotor, disable triyaw channel setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); m_aircraft->triYawChannelBox->setEnabled(false); // disable all motor channel boxes - for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) + for (i=1; i <=8; i++) { + // do it manually so we can turn off any error decorations + QComboBox *combobox = qFindChild(uiowner, "multiMotorChannelBox" + QString::number(i)); + if (combobox) { combobox->setEnabled(false); + combobox->setItemData(0, 0, Qt::DecorationRole); + } } if (frameType == "Tri" || frameType == "Tricopter Y") { @@ -84,10 +93,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("tri"); //Enable all necessary motor channel boxes... - for (int i=1; i <=3; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=3; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->triYawChannelBox->setEnabled(true); @@ -97,10 +104,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-X"); //Enable all necessary motor channel boxes... - for (int i=1; i <=4; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=4; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(50); @@ -112,10 +117,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-plus"); //Enable all necessary motor channel boxes... - for (int i=1; i <=4; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=4; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(100); @@ -128,10 +131,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-hexa"); //Enable all necessary motor channel boxes... - for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=6; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(50); @@ -143,10 +144,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-hexa-H"); //Enable all necessary motor channel boxes... - for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=6; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(33); @@ -160,10 +159,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("hexa-coax"); //Enable all necessary motor channel boxes... - for (int i=1; i <=6; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=6; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(100); @@ -177,10 +174,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-octo"); //Enable all necessary motor channel boxes - for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=8; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(33); @@ -193,10 +188,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("quad-octo-v"); //Enable all necessary motor channel boxes - for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (i=1; i <=8; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(25); @@ -210,10 +203,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("octo-coax-P"); //Enable all necessary motor channel boxes - for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (int i=1; i <=8; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(100); @@ -227,10 +218,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) quad->setElementId("octo-coax-X"); //Enable all necessary motor channel boxes - for (int i=1; i <=8; i++) { - QComboBox *combobox = qFindChild(this->parent(), "multiMotorChannelBox" + QString::number(i)); - if (combobox) - combobox->setEnabled(true); + for (int i=1; i <=8; i++) { + enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true); } m_aircraft->mrRollMixLevel->setValue(50); @@ -1118,34 +1107,24 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ void ConfigMultiRotorWidget::throwConfigError(int numMotors) -{ +{ //Initialize configuration error flag bool error=false; //Iterate through all instances of multiMotorChannelBox for (int i=0; i(this, "multiMotorChannelBox" + QString::number(i+1)); - if (combobox){ //if QLabel exists -// QLabel *label = qFindChild(this, "MotorOutputLabel" + QString::number(i+1)); - - if (combobox->currentText() == "None") { - -// label->setText("" + label->text() + ""); - + QComboBox *combobox = qFindChild(uiowner, "multiMotorChannelBox" + QString::number(i+1)); + if (combobox){ + if (combobox->currentText() == "None") { int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize); QPixmap pixmap(size,size); pixmap.fill(QColor("red")); - combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes -// combobox->setStyleSheet("QComboBox { color: red}"); + combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes error=true; - } else { - combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes -// combobox->setStyleSheet("color: black;"); -// QTextEdit* htmlText=new QTextEdit(label->text()); // htmlText is any QString with html tags. -// label->setText(htmlText->toPlainText()); + combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes } } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index e7dc101e2..7a275e401 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -53,6 +53,7 @@ public: private: Ui_AircraftWidget *m_aircraft; + QWidget *uiowner; QGraphicsSvgItem *quad; bool setupQuad(bool pLayout); @@ -74,6 +75,8 @@ private slots: protected: +signals: + void configurationChanged(); }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index e00ad6605..0edeb3ceb 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -36,9 +36,12 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) { + //Generate lists of mixerTypeNames, mixerVectorNames, channelNames + channelNames << "None"; for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { mixerTypes << QString("Mixer%1Type").arg(i+1); mixerVectors << QString("Mixer%1Vector").arg(i+1); + channelNames << QString("Channel%1").arg(i+1); } } @@ -119,6 +122,17 @@ void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index) box->setCurrentIndex(index); } +/** + Helper function: + enables/disables the named combobox within supplied uiowner + */ +void VehicleConfig::enableComboBox(QWidget* owner, QString boxName, bool enable) +{ + QComboBox* box = qFindChild(owner, boxName); + if (box) + box->setEnabled(enable); +} + /** Reset the contents of a field diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 45e1739c1..0ac76b1de 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -115,10 +115,12 @@ class VehicleConfig: public ConfigTaskWidget static void SetConfigData(GUIConfigDataUnion configData); static void resetField(UAVObjectField * field); static void setComboCurrentIndex(QComboBox* box, int index); + static void enableComboBox(QWidget* owner, QString boxName, bool enable); virtual void ResetActuators(GUIConfigDataUnion* configData); virtual QStringList getChannelDescriptions(); + QStringList channelNames; QStringList mixerTypes; QStringList mixerVectors; diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 66eb50fe4..bdd65c466 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -106,13 +106,12 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi ffTuningInProgress = false; ffTuningPhase = false; - //Generate list of channels - QStringList channels; - channels << "None"; + //Generate lists of mixerTypeNames, mixerVectorNames, channelNames + channelNames << "None"; for (int i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) { mixerTypes << QString("Mixer%1Type").arg(i+1); mixerVectors << QString("Mixer%1Vector").arg(i+1); - channels << QString("Channel%1").arg(i+1); + channelNames << QString("Channel%1").arg(i+1); } QStringList airframeTypes; @@ -142,7 +141,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name foreach(QComboBox *combobox, this->findChildren(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate { - combobox->addItems(channels); + combobox->addItems(channelNames); } // Setup the Multirotor picture in the Quad settings interface @@ -173,19 +172,27 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } - m_multirotor = new ConfigMultiRotorWidget(m_aircraft, this); + // create and setup a MultiRotor config widget + m_multirotor = new ConfigMultiRotorWidget(m_aircraft); m_multirotor->quad = quad; + m_multirotor->uiowner = this; m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText()); - m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft, this); + // create and setup a GroundVehicle config widget + m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft); m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() ); - m_fixedwing = new ConfigFixedWingWidget(m_aircraft, this); + // create and setup a FixedWing config widget + m_fixedwing = new ConfigFixedWingWidget(m_aircraft); m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() ); - m_heli = m_aircraft->widget_3;// new ConfigccpmWidget(this); + // create and setup a Helicopter config widget + m_heli = m_aircraft->widget_3; m_heli->setupUI(QString("HeliCP")); + // initialize the ui to show the mixersettings tab + //mdl m_aircraft->tabWidget->setCurrentIndex(0); + //Connect aircraft type selection dropbox to callback function connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -238,6 +245,11 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() // Do nothing } +/** + Static function to get currently assigned channelDescriptions + for all known vehicle types; instantiates the appropriate object + then asks it to supply channel descs + */ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() { int i; @@ -267,7 +279,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() // helicp case SystemSettings::AIRFRAMETYPE_HELICP: { - ConfigccpmWidget* heli = new ConfigccpmWidget(); + ConfigCcpmWidget* heli = new ConfigCcpmWidget(); channelDesc = heli->getChannelDescriptions(); } break; @@ -402,7 +414,6 @@ void ConfigVehicleTypeWidget::toggleRudder2(int index) } } - ///////////////////////////////////////////////////////// /// Feed Forward Testing ///////////////////////////////////////////////////////// diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index d9af3c968..c85cb5f30 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -58,7 +58,7 @@ public: private: Ui_AircraftWidget *m_aircraft; - ConfigccpmWidget *m_heli; + ConfigCcpmWidget *m_heli; ConfigFixedWingWidget *m_fixedwing; ConfigMultiRotorWidget *m_multirotor; ConfigGroundVehicleWidget *m_groundvehicle; @@ -70,9 +70,10 @@ private: //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector); - + QStringList channelNames; QStringList mixerTypes; QStringList mixerVectors; + QGraphicsSvgItem *quad; bool ffTuningInProgress; bool ffTuningPhase; @@ -85,7 +86,6 @@ private slots: void setComboCurrentIndex(QComboBox* box, int index); - void setupAirframeUI(QString type); void toggleAileron2(int index); From 7fb96f1acdcc1c648641eedfe369e7dee7d4f580 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Thu, 24 May 2012 09:38:34 -0700 Subject: [PATCH 07/15] Bugfixes in configwidgets; Refactor mixer type and vector set/get, named vector elements; --- .../cfg_vehicletypes/configccpmwidget.cpp | 16 +- .../configfixedwingwidget.cpp | 504 ++++++++++------ .../configgroundvehiclewidget.cpp | 411 ++++++------- .../configmultirotorwidget.cpp | 546 ++++++++++++------ .../config/cfg_vehicletypes/vehicleconfig.cpp | 92 +++ .../config/cfg_vehicletypes/vehicleconfig.h | 12 + .../config/configvehicletypewidget.cpp | 11 +- .../uavobjectdefinition/actuatorsettings.xml | 19 - 8 files changed, 1000 insertions(+), 611 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index fee50819a..0548ed1a2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -889,7 +889,7 @@ void ConfigCcpmWidget::UpdateMixer() throwConfigError(QString("HeliCP")); - updateConfigObjectsFromWidgets(); + //updateConfigObjectsFromWidgets(); GUIConfigDataUnion config = GetConfigData(); @@ -1055,7 +1055,7 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr SetConfigData(config); - //setMixer(); + setMixer(); updatingFromHardware = FALSE; return airframeType; @@ -1102,7 +1102,7 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro //tail setComboCurrentIndex( m_ccpm->ccpmTailChannel, config.heli.Tail); - //getMixer(); + getMixer(); } @@ -1204,19 +1204,23 @@ void ConfigCcpmWidget::setMixer() &mixerSettingsData.Mixer8Type }; + //reset all to Disabled + for (i=0; i<8; i++) + *mixerTypes[i] = 0; + //go through the user data and update the mixer matrix for (i=0;i<6;i++) { - if (MixerChannelData[i]<8) + if (MixerChannelData[i]>0) { //set the mixer type - *(mixerTypes[MixerChannelData[i]]) = i==0 ? + *(mixerTypes[MixerChannelData[i] - 1]) = i==0 ? MixerSettings::MIXER1TYPE_MOTOR : MixerSettings::MIXER1TYPE_SERVO; //config the vector for (j=0;j<5;j++) - mixers[MixerChannelData[i]][j] = m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(); + mixers[MixerChannelData[i] - 1][j] = m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(); } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 0b6a026da..f8cc56ebd 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -300,87 +300,123 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) SetConfigData(config); - UAVDataObject* obj; - UAVObjectField* field; + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + int channel; + //disable all + for (channel=0; channelfwEngineChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); + setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + + //rudder + channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + //ailerons + channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; + if (channel > -1) { + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); + + channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); + } + + //elevators + channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; + if (channel > -1) { + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); + + channel = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); + } - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel // Disable all - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); - field->setValue("Disabled"); - } - // and set only the relevant channels: - // Engine - int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Motor"); - field = obj->getField(mixerVectors.at(tmpVal)); - // First of all reset the vector - resetField(field); - int ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(127, ti); +// foreach(QString mixer, mixerTypes) { +// field = obj->getField(mixer); +// Q_ASSERT(field); +// field->setValue("Disabled"); +// } +// // and set only the relevant channels: +// // Engine +// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Motor"); + +// field = obj->getField(mixerVectors.at(tmpVal)); +// // First of all reset the vector +// resetField(field); +// int ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(127, ti); - // Rudder - tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; - // tmpVal will be -1 if rudder is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(127, ti); - } // Else: we have no rudder, only ailerons, we're fine with it. +// // Rudder +// tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; +// // tmpVal will be -1 if rudder is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(127, ti); +// } // Else: we have no rudder, only ailerons, we're fine with it. - // Ailerons - tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(127, ti); - // Only set Aileron 2 if Aileron 1 is defined - tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(127, ti); - } - } // Else we have no ailerons. Our consistency check guarantees we have - // rudder in this case, so we're fine with it too. +// // Ailerons +// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(127, ti); +// // Only set Aileron 2 if Aileron 1 is defined +// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(127, ti); +// } +// } // Else we have no ailerons. Our consistency check guarantees we have +// // rudder in this case, so we're fine with it too. - // Elevator - tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue(127, ti); - // Only set Elevator 2 if it is defined - tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue(127, ti); - } +// // Elevator +// tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue(127, ti); +// // Only set Elevator 2 if it is defined +// tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue(127, ti); +// } - obj->updated(); +// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; @@ -417,83 +453,121 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) SetConfigData(config); - UAVDataObject* obj; - UAVObjectField* field; + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + int channel; + double value; + //disable all + for (channel=0; channelfwEngineChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); + setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + + //rudders + channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + channel = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); + + //ailerons + channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; + if (channel > -1) { + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + value = (double)(m_aircraft->elevonSlider2->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); + value = (double)(m_aircraft->elevonSlider1->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, value); + + channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + value = (double)(m_aircraft->elevonSlider2->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); + value = (double)(m_aircraft->elevonSlider1->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value); + } + // Save the curve: - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(obj); // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel // Disable all - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); - field->setValue("Disabled"); - } - // and set only the relevant channels: - // Engine - int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Motor"); - field = obj->getField(mixerVectors.at(tmpVal)); - // First of all reset the vector - resetField(field); - int ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(127, ti); +// foreach(QString mixer, mixerTypes) { +// field = obj->getField(mixer); +// Q_ASSERT(field); +// field->setValue("Disabled"); +// } +// // and set only the relevant channels: +// // Engine +// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Motor"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// // First of all reset the vector +// resetField(field); +// int ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(127, ti); - // Rudder 1 - tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; - // tmpVal will be -1 if rudder 1 is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(127, ti); - } // Else: we have no rudder, only elevons, we're fine with it. +// // Rudder 1 +// tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; +// // tmpVal will be -1 if rudder 1 is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(127, ti); +// } // Else: we have no rudder, only elevons, we're fine with it. - // Rudder 2 - tmpVal = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; - // tmpVal will be -1 if rudder 2 is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(-127, ti); - } // Else: we have no rudder, only elevons, we're fine with it. +// // Rudder 2 +// tmpVal = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; +// // tmpVal will be -1 if rudder 2 is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(-127, ti); +// } // Else: we have no rudder, only elevons, we're fine with it. - tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); - } +// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); +// } - tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); - } +// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); +// } - obj->updated(); +// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; } @@ -529,75 +603,121 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) SetConfigData(config); - UAVDataObject* obj; - UAVObjectField* field; + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + int channel; + double value; + //disable all + for (channel=0; channelfwEngineChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); + setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + + //rudders + channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + channel = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); + + //ailerons + channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; + if (channel > -1) { + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); + + channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127); + } + + //vtail + channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; + if (channel > -1) { + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + value = (double)(m_aircraft->elevonSlider2->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); + value = (double)(m_aircraft->elevonSlider1->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, value); + + channel = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + value = (double)(m_aircraft->elevonSlider2->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); + value = (double)(m_aircraft->elevonSlider1->value()*1.27); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -value); + } - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel // Disable all - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); - field->setValue("Disabled"); - } - // and set only the relevant channels: - // Engine - int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Motor"); - field = obj->getField(mixerVectors.at(tmpVal)); - // First of all reset the vector - resetField(field); - int ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(127, ti); +// foreach(QString mixer, mixerTypes) { +// field = obj->getField(mixer); +// Q_ASSERT(field); +// field->setValue("Disabled"); +// } +// // and set only the relevant channels: +// // Engine +// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Motor"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// // First of all reset the vector +// resetField(field); +// int ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(127, ti); + +// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(127,ti); +// } - tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(127,ti); - } +// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(-127,ti); +// } - tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(-127,ti); - } +// // Now compute the VTail +// tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); - // Now compute the VTail - tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); +// tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); - tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); - - obj->updated(); +// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index cee0a4d88..d1f7794ff 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -257,14 +257,16 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) // Find the channel number for Motor1 obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); - int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - if (chMixerNumber >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check. - field = obj->getField(mixerVectors.at(chMixerNumber)); - int ti = field->getElementNames().indexOf("Roll"); - m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); - - ti = field->getElementNames().indexOf("Pitch"); - m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100); + int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; + if (channel >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check. +// field = obj->getField(mixerVectors.at(chMixerNumber)); +// int ti = field->getElementNames().indexOf("Roll"); +// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); + + m_aircraft->differentialSteeringSlider1->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_ROLL)*100); + +// ti = field->getElementNames().indexOf("Pitch"); + m_aircraft->differentialSteeringSlider2->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_PITCH)*100); } } if (frameType == "GroundVehicleMotorcycle") { @@ -312,81 +314,109 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp SetConfigData(config); - UAVObject* obj; - UAVObjectField* field; + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 + int channel; + //disable all + for (channel=0; channelgvMotor2ChannelBox->currentIndex()-1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + //steering + channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127); + + //balance + channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); + +// UAVObject* obj; +// UAVObjectField* field; + +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(obj); +// // ... and compute the matrix: +// // In order to make code a bit nicer, we assume: +// // - Channel dropdowns start with 'None', then 0 to 7 - // 1. Assign the servo/motor/none for each channel +// // 1. Assign the servo/motor/none for each channel - int tmpVal, ti; +// int tmpVal, ti; - // Disable all output channels - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); +// // Disable all output channels +// foreach(QString mixer, mixerTypes) { +// field = obj->getField(mixer); +// Q_ASSERT(field); - //Disable output channel - field->setValue("Disabled"); +// //Disable output channel +// field->setValue("Disabled"); - } +// } - // Set all mixer values to zero - foreach(QString mixer, mixerVectors) { - field = obj->getField(mixer); - resetField(field); +// // Set all mixer values to zero +// foreach(QString mixer, mixerVectors) { +// field = obj->getField(mixer); +// resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("ThrottleCurve2"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(0, ti); - } +// ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(0, ti); +// ti = field->getElementNames().indexOf("ThrottleCurve2"); +// field->setValue(0, ti); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(0, ti); +// ti = field->getElementNames().indexOf("Pitch"); +// field->setValue(0, ti); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(0, ti); +// } // Motor // Setup motor - tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); //Set motor mixer type to Servo - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward - field->setValue(127, ti); +// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); //Set motor mixer type to Servo +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward +// field->setValue(127, ti); - //Steering - // Setup steering - tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); //Set motor mixer type to Servo - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); //Set steering response to roll - field->setValue(-127, ti); - ti = field->getElementNames().indexOf("Roll"); //Set steering response to roll - field->setValue(-127, ti); +// //Steering +// // Setup steering +// tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); //Set motor mixer type to Servo +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); //Set steering response to roll +// field->setValue(-127, ti); +// ti = field->getElementNames().indexOf("Roll"); //Set steering response to roll +// field->setValue(-127, ti); - //Balancing - // Setup balancing servo - tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); //Set motor mixer type to Servo - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); //Set balance response to yaw - field->setValue(127, ti); - ti = field->getElementNames().indexOf("Roll"); //Set balance response to roll - field->setValue(127, ti); +// //Balancing +// // Setup balancing servo +// tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); //Set motor mixer type to Servo +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); //Set balance response to yaw +// field->setValue(127, ti); +// ti = field->getElementNames().indexOf("Roll"); //Set balance response to roll +// field->setValue(127, ti); - obj->updated(); +// obj->updated(); //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); @@ -423,70 +453,61 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT SetConfigData((config)); - UAVObject* obj; - UAVObjectField* field; + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + int channel; + //disable all + for (channel=0; channelgvMotor1ChannelBox->currentIndex()-1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + //right motor + channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel - int tmpVal, ti; - - // Disable all output channels - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); - - //Disable output channel - field->setValue("Disabled"); - - } - - // Set all mixer values to zero - foreach(QString mixer, mixerVectors) { - field = obj->getField(mixer); - resetField(field); - - ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("ThrottleCurve2"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(0, ti); - } - +// int tmpVal, ti; + + // Motor // Setup left motor - tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); //Set motor mixer type to Servo - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward - field->setValue(127, ti); - ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn right with increasing throttle - field->setValue(127, ti); +// tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); //Set motor mixer type to Servo +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward +// field->setValue(127, ti); +// ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn right with increasing throttle +// field->setValue(127, ti); - // Setup right motor - tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); //Set motor mixer type to Servo - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve2"); //Set motor to full forward - field->setValue(127, ti); - ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn left with increasing throttle - field->setValue(-127, ti); +// // Setup right motor +// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); //Set motor mixer type to Servo +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("ThrottleCurve2"); //Set motor to full forward +// field->setValue(127, ti); +// ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn left with increasing throttle +// field->setValue(-127, ti); - obj->updated(); +// obj->updated(); //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); @@ -544,96 +565,88 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); SetConfigData(config); - - UAVDataObject* obj; - UAVObjectField* field; - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + int channel; + //disable all + for (channel=0; channelgvSteering1ChannelBox->currentIndex()-1; + setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + + channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); + + channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; + setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + + channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; + setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); + // ... and compute the matrix: // In order to make code a bit nicer, we assume: // - Channel dropdowns start with 'None', then 0 to 7 // 1. Assign the servo/motor/none for each channel - int tmpVal, ti; - - // Disable all output channels - foreach(QString mixer, mixerTypes) { - field = obj->getField(mixer); - Q_ASSERT(field); - - //Disable output channel - field->setValue("Disabled"); - - } - - // Set all mixer values to zero - foreach(QString mixer, mixerVectors) { - field = obj->getField(mixer); - resetField(field); - - ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("ThrottleCurve2"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Pitch"); - field->setValue(0, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(0, ti); - } - // Steering // Only set front steering if it is defined - tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; - // tmpVal will be -1 if steering is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(127, ti); - } // Else: we have no front steering. We're fine with it as long as we have rear steering +// tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; +// // tmpVal will be -1 if steering is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(127, ti); +// } // Else: we have no front steering. We're fine with it as long as we have rear steering - // Only set rear steering if it is defined - tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; - // tmpVal will be -1 if steering is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("Yaw"); - field->setValue(-127, ti); - } // Else: we have no rear steering. We're fine with it as long as we have front steering +// // Only set rear steering if it is defined +// tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; +// // tmpVal will be -1 if steering is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(-127, ti); +// } // Else: we have no rear steering. We're fine with it as long as we have front steering - // Motor - // Only set front motor if it is defined - tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(127, ti); - } +// // Motor +// // Only set front motor if it is defined +// tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(127, ti); +// } - // Only set rear motor if it is defined - tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; - if (tmpVal > -1) { - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - ti = field->getElementNames().indexOf("ThrottleCurve2"); - field->setValue(127, ti); - } +// // Only set rear motor if it is defined +// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; +// if (tmpVal > -1) { +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// ti = field->getElementNames().indexOf("ThrottleCurve2"); +// field->setValue(127, ti); +// } - obj->updated(); +// obj->updated(); //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 8c5cf664e..71258bf3a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -52,9 +52,6 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { m_aircraft = aircraft; - - //connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); - } /** @@ -529,15 +526,25 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() { 0, 0, 0} }; setupMultiRotorMixer(mixer); - - int tmpVal = m_aircraft->triYawChannelBox->currentIndex()-1; - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - field = obj->getField(mixerTypes.at(tmpVal)); - field->setValue("Servo"); - field = obj->getField(mixerVectors.at(tmpVal)); - resetField(field); - int ti = field->getElementNames().indexOf("Yaw"); - field->setValue(127,ti); + + //tell the mixer about tricopter yaw channel + UAVDataObject* mixerObj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixerObj); + + int channel = m_aircraft->triYawChannelBox->currentIndex()-1; + if (channel > -1){ + setMixerType(mixerObj, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixerObj, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + } + +// int tmpVal = m_aircraft->triYawChannelBox->currentIndex()-1; +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// field = obj->getField(mixerTypes.at(tmpVal)); +// field->setValue("Servo"); +// field = obj->getField(mixerVectors.at(tmpVal)); +// resetField(field); +// int ti = field->getElementNames().indexOf("Yaw"); +// field->setValue(127,ti); m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK"); @@ -553,12 +560,15 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() */ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) { + int channel; + double value; + GUIConfigDataUnion config = GetConfigData(); multiGUISettingsStruct multi = config.multi; - UAVDataObject* obj; - UAVObjectField *field; - + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + if (frameType == "QuadP") { // Motors 1/2/3/4 are: N / E / S / W setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); @@ -569,24 +579,41 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = field->getDouble(i)/1.27; - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = (1-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Roll"); - val = -field->getDouble(i)/1.27; - m_aircraft->mrRollMixLevel->setValue(val); - } + + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( value/1.27 ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( 1-value/1.27 ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -value/1.27); + + } +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = field->getDouble(i)/1.27; +// m_aircraft->mrPitchMixLevel->setValue(val); + +// i = field->getElementNames().indexOf("Yaw"); +// val = (1-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); + +// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; + +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Roll"); +// val = -field->getDouble(i)/1.27; +// m_aircraft->mrRollMixLevel->setValue(val); +// } + } else if (frameType == "QuadX") { // Motors 1/2/3/4 are: NW / NE / SE / SW setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); @@ -594,25 +621,38 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( value/1.27 ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( 1-value/1.27 ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( value/1.27); + + } // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = field->getDouble(i)/1.27; - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = 1-field->getDouble(i)/1.27; - m_aircraft->mrYawMixLevel->setValue(val); - i = field->getElementNames().indexOf("Roll"); - val = field->getDouble(i)/1.27; - m_aircraft->mrRollMixLevel->setValue(val); - } +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(obj); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = field->getDouble(i)/1.27; +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Yaw"); +// val = 1-field->getDouble(i)/1.27; +// m_aircraft->mrYawMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Roll"); +// val = field->getDouble(i)/1.27; +// m_aircraft->mrRollMixLevel->setValue(val); +// } } else if (frameType == "Hexa") { // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW @@ -623,29 +663,44 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(1-value/1.27) ); + + } + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - if(tmpVal>-1) - { - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Roll"); - val = floor(1-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } - } +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); +// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; +// if(tmpVal>-1) +// { +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(1-field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); +// } +// } } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW @@ -657,26 +712,41 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(1-value/1.27) ); + + } + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Roll"); - val = floor(1-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); +// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(1-field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); +// } } else if (frameType == "HexaCoax") { // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE @@ -688,24 +758,39 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( value/1.27 ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( value/1.27 ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( value/1.27); + + } + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(2*field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - i = field->getElementNames().indexOf("Roll"); - val = floor(field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(2*field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); +// } } else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") { // Motors 1 to 8 are N / NE / E / etc @@ -720,56 +805,102 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + if (frameType == "Octo") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + //change channelboxes + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); + } + else if (frameType == "OctoV") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); + } + else if (frameType == "OctoCoaxP") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); + } + + } // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - if (frameType == "Octo") { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Roll"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } else if (frameType == "OctoV") { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Yaw"); - double val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - i = field->getElementNames().indexOf("Roll"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Pitch"); - val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// if (frameType == "Octo") { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); + +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); + +// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); + +// } else if (frameType == "OctoV") { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Yaw"); +// double val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); + +// i = field->getElementNames().indexOf("Roll"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); + +// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Pitch"); +// val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); - } else if (frameType == "OctoCoaxP") { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - tmpVal = m_aircraft->multiMotorChannelBox3->currentIndex()-1; - field = obj->getField(mixerVectors.at(tmpVal)); - i = field->getElementNames().indexOf("Roll"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); +// } else if (frameType == "OctoCoaxP") { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); + +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); + +// tmpVal = m_aircraft->multiMotorChannelBox3->currentIndex()-1; +// field = obj->getField(mixerVectors.at(tmpVal)); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); - } - } +// } +// } } else if (frameType == "OctoCoaxX") { // Motors 1 to 8 are N / NE / E / etc @@ -782,25 +913,38 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(value/1.27) ); + } + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Yaw"); - val = floor(-field->getDouble(i)/1.27); - m_aircraft->mrYawMixLevel->setValue(val); - i = field->getElementNames().indexOf("Roll"); - val = floor(field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Yaw"); +// val = floor(-field->getDouble(i)/1.27); +// m_aircraft->mrYawMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); +// } } else if (frameType == "Tri") { // Motors 1 to 8 are N / NE / E / etc @@ -810,18 +954,29 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; - // tmpVal will be -1 if value is set to "None" - if (tmpVal > -1) { - field = obj->getField(mixerVectors.at(tmpVal)); - int i = field->getElementNames().indexOf("Pitch"); - double val = floor(2*field->getDouble(i)/1.27); - m_aircraft->mrPitchMixLevel->setValue(val); - i = field->getElementNames().indexOf("Roll"); - val = floor(field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); - } + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( floor(2*value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( floor(value/1.27) ); + + } + +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; +// // tmpVal will be -1 if value is set to "None" +// if (tmpVal > -1) { +// field = obj->getField(mixerVectors.at(tmpVal)); +// int i = field->getElementNames().indexOf("Pitch"); +// double val = floor(2*field->getDouble(i)/1.27); +// m_aircraft->mrPitchMixLevel->setValue(val); +// i = field->getElementNames().indexOf("Roll"); +// val = floor(field->getDouble(i)/1.27); +// m_aircraft->mrRollMixLevel->setValue(val); +// } } } @@ -834,24 +989,33 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro { qDebug()<(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - UAVObjectField *field = obj->getField(mixerTypes.at(channel)); - field->setValue("Motor"); - field = obj->getField(mixerVectors.at(channel)); - // First of all reset the vector - resetField(field); - int ti = field->getElementNames().indexOf("ThrottleCurve1"); - field->setValue(127, ti); - ti = field->getElementNames().indexOf("Roll"); - field->setValue(roll*127,ti); - qDebug()<<"Set roll="<getElementNames().indexOf("Pitch"); - field->setValue(pitch*127,ti); - qDebug()<<"Set pitch="<getElementNames().indexOf("Yaw"); - field->setValue(yaw*127,ti); - qDebug()<<"Set yaw="<(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); + + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll*127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch*127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw*127); + +// UAVObjectField *field = obj->getField(mixerTypes.at(channel)); +// field->setValue("Motor"); +// field = obj->getField(mixerVectors.at(channel)); +// // First of all reset the vector +// resetField(field); +// int ti = field->getElementNames().indexOf("ThrottleCurve1"); +// field->setValue(127, ti); +// ti = field->getElementNames().indexOf("Roll"); +// field->setValue(roll*127,ti); +// qDebug()<<"Set roll="<getElementNames().indexOf("Pitch"); +// field->setValue(pitch*127,ti); +// qDebug()<<"Set pitch="<getElementNames().indexOf("Yaw"); +// field->setValue(yaw*127,ti); +// qDebug()<<"Set yaw="<setEnabled(enable); } +QString VehicleConfig::getMixerType(UAVDataObject* mixer, int channel) +{ + Q_ASSERT(mixer); + + QString mixerType = mixerTypeDescriptions[0]; //default to disabled + + if (channel >= 0 && channel < mixerTypes.count()) { + UAVObjectField *field = mixer->getField(mixerTypes.at(channel)); + Q_ASSERT(field); + + if (field) + mixerType = field->getValue().toString(); + } + + return mixerType; +} + +void VehicleConfig::setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType) +{ + Q_ASSERT(mixer); + + qDebug() << QString("setMixerType channel %0, type %1").arg(channel).arg(mixerType); + + if (channel >= 0 && channel < mixerTypes.count()) { + UAVObjectField *field = mixer->getField(mixerTypes.at(channel)); + Q_ASSERT(field); + + if (field) { + if (mixerType >= 0 && mixerType < mixerTypeDescriptions.count()) + { + field->setValue(mixerTypeDescriptions[mixerType]); + mixer->updated(); + } + } + } +} + +void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel) +{ + Q_ASSERT(mixer); + + if (channel >= 0 && channel < mixerVectors.count()) { + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 0); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 0); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 0); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 0); + } +} + +double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName) +{ + Q_ASSERT(mixer); + + double value = 0; + + if (channel >= 0 && channel < mixerVectors.count()) { + UAVObjectField *field = mixer->getField(mixerVectors.at(channel)); + Q_ASSERT(field); + + if (field) { + value = field->getDouble(elementName); + } + } + return value; +} + +void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value) +{ + Q_ASSERT(mixer); + + qDebug() << QString("setMixerVectorValue channel %0, name %1, value %2").arg(channel).arg(elementName).arg(value); + + if (channel >= 0 && channel < mixerVectors.count()) { + UAVObjectField *field = mixer->getField(mixerVectors.at(channel)); + Q_ASSERT(field); + + if (field) { + field->setDouble(value, elementName); + mixer->updated(); + } + } +} /** Reset the contents of a field diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 0ac76b1de..9700a8789 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -111,18 +111,30 @@ class VehicleConfig: public ConfigTaskWidget VehicleConfig(QWidget *parent = 0); ~VehicleConfig(); + /* Enumeration options for field MixerType */ + typedef enum { MIXERTYPE_DISABLED=0, MIXERTYPE_MOTOR=1, MIXERTYPE_SERVO=2, MIXERTYPE_CAMERAROLL=3, MIXERTYPE_CAMERAPITCH=4, MIXERTYPE_CAMERAYAW=5, MIXERTYPE_ACCESSORY0=6, MIXERTYPE_ACCESSORY1=7, MIXERTYPE_ACCESSORY2=8, MIXERTYPE_ACCESSORY3=9, MIXERTYPE_ACCESSORY4=10, MIXERTYPE_ACCESSORY5=11 } MixerTypeElem; + /* Array element names for field MixerVector */ + typedef enum { MIXERVECTOR_THROTTLECURVE1=0, MIXERVECTOR_THROTTLECURVE2=1, MIXERVECTOR_ROLL=2, MIXERVECTOR_PITCH=3, MIXERVECTOR_YAW=4 } MixerVectorElem; + static GUIConfigDataUnion GetConfigData(); static void SetConfigData(GUIConfigDataUnion configData); static void resetField(UAVObjectField * field); static void setComboCurrentIndex(QComboBox* box, int index); static void enableComboBox(QWidget* owner, QString boxName, bool enable); + double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); + void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); + void resetMixerVector(UAVDataObject* mixer, int channel); + QString getMixerType(UAVDataObject* mixer, int channel); + void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); + virtual void ResetActuators(GUIConfigDataUnion* configData); virtual QStringList getChannelDescriptions(); QStringList channelNames; QStringList mixerTypes; QStringList mixerVectors; + QStringList mixerTypeDescriptions; static const quint32 CHANNEL_NUMELEM = 10; diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index bdd65c466..508a0a112 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -861,6 +861,9 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() */ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() { + UAVDataObject* obj; + UAVObjectField* field; + QString airframeType = "Custom"; //Sets airframe type default to "Custom" if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); @@ -874,9 +877,9 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() else if (m_aircraft->aircraftType->currentText() == "Ground") { airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); } - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - UAVObjectField* field = obj->getField(QString("FeedForward")); + else { + obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + field = obj->getField(QString("FeedForward")); // Curve is also common to all quads: field = obj->getField("ThrottleCurve1"); @@ -909,7 +912,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() ti = field->getElementNames().indexOf("Yaw"); field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti); } - + } // set the airframe type obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); field = obj->getField(QString("AirframeType")); diff --git a/shared/uavobjectdefinition/actuatorsettings.xml b/shared/uavobjectdefinition/actuatorsettings.xml index dd64dad15..a3d3c7bd4 100644 --- a/shared/uavobjectdefinition/actuatorsettings.xml +++ b/shared/uavobjectdefinition/actuatorsettings.xml @@ -1,25 +1,6 @@ Settings for the @ref ActuatorModule that controls the channel assignments for the mixer based on AircraftType - - - - - - - - - - - - - - - - - - - From e9e6aece21a2b54c50a03b370aff674b94959b2e Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Fri, 25 May 2012 11:29:38 -0700 Subject: [PATCH 08/15] Bugfix: ccpm_ui - change sliders signal sliderMoved to valueChanged; resolves related spinboxes not always staying in synch --- ground/openpilotgcs/src/plugins/config/ccpm.ui | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/ccpm.ui b/ground/openpilotgcs/src/plugins/config/ccpm.ui index 8bb8a4e27..c31e5fb97 100644 --- a/ground/openpilotgcs/src/plugins/config/ccpm.ui +++ b/ground/openpilotgcs/src/plugins/config/ccpm.ui @@ -3959,7 +3959,7 @@ margin:1px; ccpmCollectiveSlider - sliderMoved(int) + valueChanged(int) ccpmCollectivespinBox setValue(int) @@ -4007,7 +4007,7 @@ margin:1px; ccpmRevoSlider - sliderMoved(int) + valueChanged(int) ccpmREVOspinBox setValue(int) @@ -4023,7 +4023,7 @@ margin:1px; SwashLvlPositionSlider - sliderMoved(int) + valueChanged(int) SwashLvlPositionSpinBox setValue(int) @@ -4071,7 +4071,7 @@ margin:1px; ccpmCollectiveScale - sliderMoved(int) + valueChanged(int) ccpmCollectiveScaleBox setValue(int) @@ -4087,7 +4087,7 @@ margin:1px; ccpmCyclicScale - sliderMoved(int) + valueChanged(int) ccpmCyclicScaleBox setValue(int) @@ -4119,7 +4119,7 @@ margin:1px; ccpmPitchScale - sliderMoved(int) + valueChanged(int) ccpmPitchScaleBox setValue(int) @@ -4167,7 +4167,7 @@ margin:1px; ccpmRollScale - sliderMoved(int) + valueChanged(int) ccpmRollScaleBox setValue(int) From b5ac4306d3440a68f637e8dce2879b0ba4258cee Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Fri, 25 May 2012 11:47:38 -0700 Subject: [PATCH 09/15] Delete commented code using direct vector object referencing --- .../configfixedwingwidget.cpp | 236 ++--------------- .../configgroundvehiclewidget.cpp | 195 +------------- .../configmultirotorwidget.cpp | 250 ++---------------- 3 files changed, 49 insertions(+), 632 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index f8cc56ebd..5904b8871 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -303,6 +303,12 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + // ... and compute the matrix: + // In order to make code a bit nicer, we assume: + // - Channel dropdowns start with 'None', then 0 to 7 + + // 1. Assign the servo/motor/none for each channel + int channel; //disable all for (channel=0; channelgetField(mixer); -// Q_ASSERT(field); -// field->setValue("Disabled"); -// } -// // and set only the relevant channels: -// // Engine -// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Motor"); - -// field = obj->getField(mixerVectors.at(tmpVal)); -// // First of all reset the vector -// resetField(field); -// int ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(127, ti); - -// // Rudder -// tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; -// // tmpVal will be -1 if rudder is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(127, ti); -// } // Else: we have no rudder, only ailerons, we're fine with it. - -// // Ailerons -// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(127, ti); -// // Only set Aileron 2 if Aileron 1 is defined -// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(127, ti); -// } -// } // Else we have no ailerons. Our consistency check guarantees we have -// // rudder in this case, so we're fine with it too. - -// // Elevator -// tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue(127, ti); -// // Only set Elevator 2 if it is defined -// tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue(127, ti); -// } - -// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; @@ -456,6 +385,13 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + // Save the curve: + // ... and compute the matrix: + // In order to make code a bit nicer, we assume: + // - Channel dropdowns start with 'None', then 0 to 7 + + // 1. Assign the servo/motor/none for each channel + int channel; double value; //disable all @@ -493,81 +429,6 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value); } - - // Save the curve: -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(obj); - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 - - // 1. Assign the servo/motor/none for each channel - // Disable all -// foreach(QString mixer, mixerTypes) { -// field = obj->getField(mixer); -// Q_ASSERT(field); -// field->setValue("Disabled"); -// } -// // and set only the relevant channels: -// // Engine -// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Motor"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// // First of all reset the vector -// resetField(field); -// int ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(127, ti); - -// // Rudder 1 -// tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; -// // tmpVal will be -1 if rudder 1 is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(127, ti); -// } // Else: we have no rudder, only elevons, we're fine with it. - -// // Rudder 2 -// tmpVal = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; -// // tmpVal will be -1 if rudder 2 is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(-127, ti); -// } // Else: we have no rudder, only elevons, we're fine with it. - -// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); -// } - -// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); -// } - -// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; } @@ -606,6 +467,13 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); + // Save the curve: + // ... and compute the matrix: + // In order to make code a bit nicer, we assume: + // - Channel dropdowns start with 'None', then 0 to 7 + + // 1. Assign the servo/motor/none for each channel + int channel; double value; //disable all @@ -654,70 +522,6 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -value); } - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 - - // 1. Assign the servo/motor/none for each channel - // Disable all -// foreach(QString mixer, mixerTypes) { -// field = obj->getField(mixer); -// Q_ASSERT(field); -// field->setValue("Disabled"); -// } -// // and set only the relevant channels: -// // Engine -// int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Motor"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// // First of all reset the vector -// resetField(field); -// int ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(127, ti); - -// tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(127,ti); -// } - -// tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(-127,ti); -// } - -// // Now compute the VTail -// tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti); - -// tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti); - -// obj->updated(); m_aircraft->fwStatusLabel->setText("Mixer generated"); return true; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index d1f7794ff..1fc17cea0 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -258,14 +258,9 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(obj); int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - if (channel >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check. -// field = obj->getField(mixerVectors.at(chMixerNumber)); -// int ti = field->getElementNames().indexOf("Roll"); -// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); + if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. m_aircraft->differentialSteeringSlider1->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_ROLL)*100); - -// ti = field->getElementNames().indexOf("Pitch"); m_aircraft->differentialSteeringSlider2->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_PITCH)*100); } } @@ -297,7 +292,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp throwConfigError(airframeType); // - Motor, steering, and balance - if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" || + if (m_aircraft->gvMotor2ChannelBox->currentText() == "None" || (m_aircraft->gvSteering1ChannelBox->currentText() == "None" || m_aircraft->gvSteering2ChannelBox->currentText() == "None") ) { @@ -342,83 +337,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); -// UAVObject* obj; -// UAVObjectField* field; - -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(obj); -// // ... and compute the matrix: -// // In order to make code a bit nicer, we assume: -// // - Channel dropdowns start with 'None', then 0 to 7 - -// // 1. Assign the servo/motor/none for each channel - -// int tmpVal, ti; - -// // Disable all output channels -// foreach(QString mixer, mixerTypes) { -// field = obj->getField(mixer); -// Q_ASSERT(field); - -// //Disable output channel -// field->setValue("Disabled"); - -// } - -// // Set all mixer values to zero -// foreach(QString mixer, mixerVectors) { -// field = obj->getField(mixer); -// resetField(field); - -// ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(0, ti); -// ti = field->getElementNames().indexOf("ThrottleCurve2"); -// field->setValue(0, ti); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(0, ti); -// ti = field->getElementNames().indexOf("Pitch"); -// field->setValue(0, ti); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(0, ti); -// } - - // Motor - // Setup motor -// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); //Set motor mixer type to Servo -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward -// field->setValue(127, ti); - -// //Steering -// // Setup steering -// tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); //Set motor mixer type to Servo -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); //Set steering response to roll -// field->setValue(-127, ti); -// ti = field->getElementNames().indexOf("Roll"); //Set steering response to roll -// field->setValue(-127, ti); - -// //Balancing -// // Setup balancing servo -// tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); //Set motor mixer type to Servo -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); //Set balance response to yaw -// field->setValue(127, ti); -// ti = field->getElementNames().indexOf("Roll"); //Set balance response to roll -// field->setValue(127, ti); - -// obj->updated(); - - //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); return true; @@ -475,40 +393,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 - - // 1. Assign the servo/motor/none for each channel - -// int tmpVal, ti; - - - // Motor - // Setup left motor -// tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); //Set motor mixer type to Servo -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward -// field->setValue(127, ti); -// ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn right with increasing throttle -// field->setValue(127, ti); - -// // Setup right motor -// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); //Set motor mixer type to Servo -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("ThrottleCurve2"); //Set motor to full forward -// field->setValue(127, ti); -// ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn left with increasing throttle -// field->setValue(-127, ti); - -// obj->updated(); - //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); @@ -537,24 +421,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) { return false; } -// else{ -// // m_aircraft->gvStatusLabel->setText("Mixer generated"); -// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText()); -// delete htmlText; -// -// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText()); -// delete htmlText; -// -// htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText()); -// delete htmlText; -// -// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText()); -// } - + // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); ResetActuators(&config); @@ -592,62 +459,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 - - // 1. Assign the servo/motor/none for each channel - - // Steering - // Only set front steering if it is defined -// tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; -// // tmpVal will be -1 if steering is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(127, ti); -// } // Else: we have no front steering. We're fine with it as long as we have rear steering - -// // Only set rear steering if it is defined -// tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; -// // tmpVal will be -1 if steering is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(-127, ti); -// } // Else: we have no rear steering. We're fine with it as long as we have front steering - -// // Motor -// // Only set front motor if it is defined -// tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(127, ti); -// } - -// // Only set rear motor if it is defined -// tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; -// if (tmpVal > -1) { -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// ti = field->getElementNames().indexOf("ThrottleCurve2"); -// field->setValue(127, ti); -// } - -// obj->updated(); - //Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 71258bf3a..35044965d 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -536,15 +536,6 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() setMixerType(mixerObj, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixerObj, channel, VehicleConfig::MIXERVECTOR_YAW, 127); } - -// int tmpVal = m_aircraft->triYawChannelBox->currentIndex()-1; -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// field = obj->getField(mixerTypes.at(tmpVal)); -// field->setValue("Servo"); -// field = obj->getField(mixerVectors.at(tmpVal)); -// resetField(field); -// int ti = field->getElementNames().indexOf("Yaw"); -// field->setValue(127,ti); m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK"); @@ -594,26 +585,6 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue( -value/1.27); } -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = field->getDouble(i)/1.27; -// m_aircraft->mrPitchMixLevel->setValue(val); - -// i = field->getElementNames().indexOf("Yaw"); -// val = (1-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); - -// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; - -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Roll"); -// val = -field->getDouble(i)/1.27; -// m_aircraft->mrRollMixLevel->setValue(val); -// } - } else if (frameType == "QuadX") { // Motors 1/2/3/4 are: NW / NE / SE / SW setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); @@ -621,6 +592,9 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -634,25 +608,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue( value/1.27); } - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(obj); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = field->getDouble(i)/1.27; -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Yaw"); -// val = 1-field->getDouble(i)/1.27; -// m_aircraft->mrYawMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Roll"); -// val = field->getDouble(i)/1.27; -// m_aircraft->mrRollMixLevel->setValue(val); -// } + } else if (frameType == "Hexa") { // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW @@ -663,6 +619,10 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -672,35 +632,14 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(1-value/1.27) ); } - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); -// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; -// if(tmpVal>-1) -// { -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(1-field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); -// } -// } + } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW @@ -711,7 +650,10 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); - + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -724,29 +666,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(1-value/1.27) ); - } - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); -// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(1-field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); -// } } else if (frameType == "HexaCoax") { // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE @@ -757,7 +677,9 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); - + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -770,27 +692,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( value/1.27); - } - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(2*field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); -// } } else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") { // Motors 1 to 8 are N / NE / E / etc @@ -804,7 +706,9 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); - + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -815,7 +719,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); - //change channelboxes + //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); @@ -827,6 +731,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); @@ -838,69 +743,13 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); m_aircraft->mrYawMixLevel->setValue( floor(-value/1.27) ); + //change channels channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(-value/1.27) ); } } - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// if (frameType == "Octo") { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); - -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); - -// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); - -// } else if (frameType == "OctoV") { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Yaw"); -// double val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); - -// i = field->getElementNames().indexOf("Roll"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); - -// tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1; -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Pitch"); -// val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); - -// } else if (frameType == "OctoCoaxP") { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); - -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); - -// tmpVal = m_aircraft->multiMotorChannelBox3->currentIndex()-1; -// field = obj->getField(mixerVectors.at(tmpVal)); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); - -// } -// } } else if (frameType == "OctoCoaxX") { // Motors 1 to 8 are N / NE / E / etc @@ -913,6 +762,9 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; if (channel > -1) { @@ -925,26 +777,6 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); m_aircraft->mrRollMixLevel->setValue( floor(value/1.27) ); } - - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Yaw"); -// val = floor(-field->getDouble(i)/1.27); -// m_aircraft->mrYawMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); -// } } else if (frameType == "Tri") { // Motors 1 to 8 are N / NE / E / etc @@ -964,19 +796,6 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) m_aircraft->mrRollMixLevel->setValue( floor(value/1.27) ); } - -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1; -// // tmpVal will be -1 if value is set to "None" -// if (tmpVal > -1) { -// field = obj->getField(mixerVectors.at(tmpVal)); -// int i = field->getElementNames().indexOf("Pitch"); -// double val = floor(2*field->getDouble(i)/1.27); -// m_aircraft->mrPitchMixLevel->setValue(val); -// i = field->getElementNames().indexOf("Roll"); -// val = floor(field->getDouble(i)/1.27); -// m_aircraft->mrRollMixLevel->setValue(val); -// } } } @@ -999,23 +818,6 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll*127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch*127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw*127); - -// UAVObjectField *field = obj->getField(mixerTypes.at(channel)); -// field->setValue("Motor"); -// field = obj->getField(mixerVectors.at(channel)); -// // First of all reset the vector -// resetField(field); -// int ti = field->getElementNames().indexOf("ThrottleCurve1"); -// field->setValue(127, ti); -// ti = field->getElementNames().indexOf("Roll"); -// field->setValue(roll*127,ti); -// qDebug()<<"Set roll="<getElementNames().indexOf("Pitch"); -// field->setValue(pitch*127,ti); -// qDebug()<<"Set pitch="<getElementNames().indexOf("Yaw"); -// field->setValue(yaw*127,ti); -// qDebug()<<"Set yaw="< Date: Fri, 25 May 2012 19:36:39 -0700 Subject: [PATCH 10/15] Bugfix: update ccpm swash mix slider visibility via ui instead of stored config; sliders now appear/disappear as user selects link checkboxes --- .../cfg_vehicletypes/configccpmwidget.cpp | 72 +++++++++---------- .../cfg_vehicletypes/configccpmwidget.h | 1 + 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 0548ed1a2..1cbb529a4 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -143,9 +143,6 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) UAVObjectField * curve2source = mixerSettings->getField("Curve2Source"); Q_ASSERT(curve2source); -// QStringList channels; -// channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" << -// "Channel5" << "Channel6" << "Channel7" << "Channel8"; m_ccpm->ccpmEngineChannel->addItems(channelNames); m_ccpm->ccpmEngineChannel->setCurrentIndex(0); m_ccpm->ccpmTailChannel->addItems(channelNames); @@ -203,9 +200,6 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) connect(m_ccpm->CurveSettings, SIGNAL(cellChanged (int, int)), this, SLOT(UpdateCurveWidgets())); connect(m_ccpm->TabObject, SIGNAL(currentChanged ( QWidget * )), this, SLOT(UpdateType())); -// connect(m_ccpm->SwashLvlSwashplateImage, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateRedraw())); - - connect(m_ccpm->PitchCurve, SIGNAL(curveUpdated(QList,double)), this, SLOT(updatePitchCurveValue(QList,double))); connect(m_ccpm->ThrottleCurve, SIGNAL(curveUpdated(QList,double)), this, SLOT(updateThrottleCurveValue(QList,double))); @@ -214,6 +208,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) connect(m_ccpm->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed())); connect(m_ccpm->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed())); + connect(m_ccpm->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities())); connect(m_ccpm->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); connect(m_ccpm->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); @@ -889,8 +884,6 @@ void ConfigCcpmWidget::UpdateMixer() throwConfigError(QString("HeliCP")); - //updateConfigObjectsFromWidgets(); - GUIConfigDataUnion config = GetConfigData(); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); @@ -995,14 +988,14 @@ void ConfigCcpmWidget::UpdateMixer() } } -QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() +QString ConfigCcpmWidget::updateConfigObjects() { QString airframeType = "HeliCP"; bool useCCPM; bool useCyclic; - - if (updatingFromHardware) return airframeType; + + if (updatingFromHardware == TRUE) return airframeType; updatingFromHardware = TRUE; @@ -1012,19 +1005,19 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr //swashplate config config.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; config.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); - + //ccpm mixing options config.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); config.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); config.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCyclic = config.heli.ccpmLinkRollState; - + //correction angle config.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value(); - + //update sliders - if (useCCPM) + if (useCCPM) { config.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value(); } @@ -1032,16 +1025,16 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr { config.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value(); } - if (useCyclic) + if (useCyclic) { config.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value(); } else { config.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value(); - } + } config.heli.SliderValue2 = m_ccpm->ccpmRollScale->value(); - + //servo assignments config.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex(); config.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex(); @@ -1052,12 +1045,19 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr config.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex(); //tail config.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex(); - + SetConfigData(config); + updatingFromHardware = FALSE; + return airframeType; +} + +QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() +{ + QString airframeType = updateConfigObjects(); + setMixer(); - updatingFromHardware = FALSE; return airframeType; } @@ -1108,33 +1108,31 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro void ConfigCcpmWidget::SetUIComponentVisibilities() { - //mdl updateObjectsFromWidgets(); - - GUIConfigDataUnion config = GetConfigData(); - - //set which sliders are user... m_ccpm->ccpmRevoMixingBox->setVisible(0); - m_ccpm->ccpmPitchMixingBox->setVisible(!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState); - m_ccpm->ccpmCollectiveScalingBox->setVisible(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); + m_ccpm->ccpmPitchMixingBox->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked() && + m_ccpm->ccpmLinkCyclic->isChecked()); - m_ccpm->ccpmLinkCyclic->setVisible(!config.heli.ccpmCollectivePassthroughState); - - m_ccpm->ccpmCyclicScalingBox->setVisible((config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState) && config.heli.ccpmLinkRollState); - if (!config.heli.ccpmCollectivePassthroughState && config.heli.ccpmLinkCyclicState) + m_ccpm->ccpmCollectiveScalingBox->setVisible(m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked()); + + m_ccpm->ccpmLinkCyclic->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked()); + + m_ccpm->ccpmCyclicScalingBox->setVisible((m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked()) && + m_ccpm->ccpmLinkRoll->isChecked()); + + if (!m_ccpm->ccpmCollectivePassthrough->checkState() && m_ccpm->ccpmLinkCyclic->isChecked()) { m_ccpm->ccpmPitchScalingBox->setVisible(0); m_ccpm->ccpmRollScalingBox->setVisible(0); m_ccpm->ccpmLinkRoll->setVisible(0); - + } else { - m_ccpm->ccpmPitchScalingBox->setVisible(!config.heli.ccpmLinkRollState); - m_ccpm->ccpmRollScalingBox->setVisible(!config.heli.ccpmLinkRollState); + m_ccpm->ccpmPitchScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked()); + m_ccpm->ccpmRollScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked()); m_ccpm->ccpmLinkRoll->setVisible(1); } - } /** Request the current value of the SystemSettings which holds the ccpm type @@ -1174,6 +1172,8 @@ void ConfigCcpmWidget::setMixer() int i,j; if (SwashLvlConfigurationInProgress)return; + if (updatingToHardware == TRUE) return; + updatingToHardware=TRUE; MixerSettings * mixerSettings = MixerSettings::GetInstance(getObjectManager()); @@ -1234,7 +1234,7 @@ void ConfigCcpmWidget::setMixer() //mapping of collective input to curve 2... //MixerSettings.Curve2Source = Throttle,Roll,Pitch,Yaw,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5 //check if we are using throttle or directly from a channel... - if (GetConfigData().heli.ccpmCollectivePassthroughState) + if (m_ccpm->ccpmCollectivePassthrough->isChecked()) mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_COLLECTIVE; else mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_THROTTLE; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index ac609773d..3dceadcda 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -90,6 +90,7 @@ private: virtual void ResetActuators(GUIConfigDataUnion* configData); virtual QStringList getChannelDescriptions(); + QString updateConfigObjects(); private slots: virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); From 1b2ffde116d4e7c4aaccf0cf0d2789ab0b857457 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Sat, 26 May 2012 16:49:02 -0700 Subject: [PATCH 11/15] Keep up: spelling disableWheelEvents; add pushbutton setAttribute for osx. --- .../config/cfg_vehicletypes/configfixedwingwidget.cpp | 2 +- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp | 7 +++++++ .../src/plugins/config/configcamerastabilizationwidget.cpp | 2 +- .../src/plugins/config/configstabilizationwidget.cpp | 2 +- .../openpilotgcs/src/plugins/config/configtxpidwidget.cpp | 2 +- .../src/plugins/config/configvehicletypewidget.cpp | 2 +- .../openpilotgcs/src/plugins/config/inputchannelform.cpp | 2 +- .../openpilotgcs/src/plugins/config/outputchannelform.cpp | 2 +- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 2 +- .../src/plugins/uavobjectwidgetutils/configtaskwidget.h | 2 +- 10 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 5904b8871..b1354a447 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -49,7 +49,7 @@ */ ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { - m_aircraft = aircraft; + m_aircraft = aircraft; } /** diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 1ce01ddd7..a5b1ac8b4 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -52,6 +52,13 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch" << "CameraYaw" << "Accessory0" << "Accessory1" << "Accessory2" << "Accessory3" << "Accessory4" << "Accessory5"; + + // This is needed because new style tries to compact things as much as possible in grid + // and on OSX the widget sizes of PushButtons is reported incorrectly: + // https://bugreports.qt-project.org/browse/QTBUG-14591 + foreach( QPushButton * btn, findChildren() ) { + btn->setAttribute(Qt::WA_LayoutUsesWidgetRect); + } } VehicleConfig::~VehicleConfig() diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 86ac30080..3e757de63 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -90,7 +90,7 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent connect(m_camerastabilization->camerastabilizationSaveSD, SIGNAL(clicked()), this, SLOT(saveSettings())); connect(m_camerastabilization->camerastabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp())); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget() diff --git a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp index 7306475a4..3f2b4d216 100644 --- a/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configstabilizationwidget.cpp @@ -53,7 +53,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa connect(this,SIGNAL(widgetContentsChanged(QWidget*)),this,SLOT(processLinkedWidgets(QWidget*))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } diff --git a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp index 1d65eaf1c..30c87bd78 100644 --- a/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtxpidwidget.cpp @@ -68,7 +68,7 @@ ConfigTxPIDWidget::ConfigTxPIDWidget(QWidget *parent) : ConfigTaskWidget(parent) populateWidgets(); refreshWidgetsValues(); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } ConfigTxPIDWidget::~ConfigTxPIDWidget() diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 508a0a112..db2b551a0 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -233,7 +233,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi refreshWidgetsValues(); addToDirtyMonitor(); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } diff --git a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp index dbab48cac..212621d44 100644 --- a/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/inputchannelform.cpp @@ -37,7 +37,7 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) : connect(ui->channelNumberDropdown,SIGNAL(currentIndexChanged(int)),this,SLOT(channelDropdownUpdated(int))); connect(ui->channelNumber,SIGNAL(valueChanged(int)),this,SLOT(channelNumberUpdated(int))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } diff --git a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp index 530244777..f2d039edb 100644 --- a/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp +++ b/ground/openpilotgcs/src/plugins/config/outputchannelform.cpp @@ -71,7 +71,7 @@ OutputChannelForm::OutputChannelForm(const int index, QWidget *parent, const boo connect(ui.actuatorLink, SIGNAL(toggled(bool)), this, SLOT(linkToggled(bool))); - disbleMouseWheelEvents(); + disableMouseWheelEvents(); } OutputChannelForm::~OutputChannelForm() diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 51bafbb2d..f2ad263b9 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -1145,7 +1145,7 @@ void ConfigTaskWidget::loadWidgetLimits(QWidget * widget,UAVObjectField * field, } } -void ConfigTaskWidget::disbleMouseWheelEvents() +void ConfigTaskWidget::disableMouseWheelEvents() { //Disable mouse wheel events foreach( QSpinBox * sp, findChildren() ) { diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index a0e1feb7b..0e7af1699 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -86,7 +86,7 @@ public: ConfigTaskWidget(QWidget *parent = 0); ~ConfigTaskWidget(); - void disbleMouseWheelEvents(); + void disableMouseWheelEvents(); bool eventFilter( QObject * obj, QEvent * evt ); void saveObjectToSD(UAVObject *obj); From e2d1f67d9e4610de503f937e46a4be6653bd4a74 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Sun, 27 May 2012 10:20:31 -0700 Subject: [PATCH 12/15] Add virtual updateObjectsFromWidgets to configccattitude; reset calibration progress bar to 0% upon successful apply/save. --- .../src/plugins/config/configccattitudewidget.cpp | 9 ++++++++- .../src/plugins/config/configccattitudewidget.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp index 4ffabef66..f020b852e 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp @@ -61,6 +61,14 @@ ConfigCCAttitudeWidget::~ConfigCCAttitudeWidget() delete ui; } +void ConfigCCAttitudeWidget::updateObjectsFromWidgets() +{ + ConfigTaskWidget::updateObjectsFromWidgets(); + + ui->zeroBiasProgress->setValue(0); + +} + void ConfigCCAttitudeWidget::attitudeRawUpdated(UAVObject * obj) { QMutexLocker locker(&startStop); @@ -101,7 +109,6 @@ void ConfigCCAttitudeWidget::attitudeRawUpdated(UAVObject * obj) { attitudeSettingsData.GyroBias[2] = -z_gyro_bias; attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_TRUE; AttitudeSettings::GetInstance(getObjectManager())->setData(attitudeSettingsData); - } else { // Possible to get here if weird threading stuff happens. Just ignore updates. qDebug("Unexpected accel update received."); diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h index 0d0581ba3..e550ca8ac 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.h @@ -46,6 +46,8 @@ public: explicit ConfigCCAttitudeWidget(QWidget *parent = 0); ~ConfigCCAttitudeWidget(); + virtual void updateObjectsFromWidgets(); + private slots: void attitudeRawUpdated(UAVObject * obj); void timeout(); From 682ab20f940e0e2d4e52cc14a8ebd2c34df7fd11 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Mon, 4 Jun 2012 17:13:55 -0700 Subject: [PATCH 13/15] add accels.h, gyros.h zapped during conflict resolution --- .../openpilotgcs/src/plugins/config/configccattitudewidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp index d689b25f2..10064b835 100644 --- a/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configccattitudewidget.cpp @@ -33,6 +33,8 @@ #include #include #include +#include "accels.h" +#include "gyros.h" ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) : ConfigTaskWidget(parent), From 01820904a2220311b6c78e458471e3e4526fac74 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 6 Jun 2012 08:58:18 -0700 Subject: [PATCH 14/15] Merge conflict resolution: alter configvehicle,configoutput refreshWidgetsValues signatures to conform to virtual in ConfigTaskWidget; add multirotor mixer sliders to apply/save dirty monitor, fix slider signals; --- .../src/plugins/config/airframe.ui | 18 +++++++++++++++++- .../src/plugins/config/configoutputwidget.cpp | 4 +++- .../src/plugins/config/configoutputwidget.h | 2 +- .../plugins/config/configvehicletypewidget.cpp | 8 ++++++-- .../plugins/config/configvehicletypewidget.h | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 68ed8d40b..e9370d07d 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -91,7 +91,7 @@ QGroupBox::title { } - 2 + 1 @@ -3048,5 +3048,21 @@ p, li { white-space: pre-wrap; } + + mrPitchMixLevel + valueChanged(int) + mrPitchMixValue + setNum(int) + + + 92 + 222 + + + 92 + 151 + + + diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp index 0b818c8cf..c73a0b9dc 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.cpp @@ -242,8 +242,10 @@ void ConfigOutputWidget::sendChannelTest(int index, int value) /** Request the current config from the board (RC Output) */ -void ConfigOutputWidget::refreshWidgetsValues() +void ConfigOutputWidget::refreshWidgetsValues(UAVObject * obj) { + Q_UNUSED(obj); + bool dirty=isDirty(); // Get Actuator Settings diff --git a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h index 9a3a32fdf..b4d3c99dd 100644 --- a/ground/openpilotgcs/src/plugins/config/configoutputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configoutputwidget.h @@ -69,7 +69,7 @@ private: private slots: void stopTests(); void disableIfNotMe(UAVObject *obj); - virtual void refreshWidgetsValues(); + virtual void refreshWidgetsValues(UAVObject * obj=NULL); void updateObjectsFromWidgets(); void runChannelTests(bool state); void sendChannelTest(int index, int value); diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index eee76d1c7..45e4285e9 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -230,7 +230,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // Connect the help pushbutton connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); - enableControls(false); refreshWidgetsValues(); addToDirtyMonitor(); @@ -609,8 +608,10 @@ void ConfigVehicleTypeWidget::updateCustomThrottle2CurveValue(QList list /** Refreshes the current value of the SystemSettings which holds the aircraft type */ -void ConfigVehicleTypeWidget::refreshWidgetsValues() +void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) { + Q_UNUSED(o); + if(!allObjectsUpdated()) return; @@ -971,6 +972,9 @@ void ConfigVehicleTypeWidget::addToDirtyMonitor() addWidget(m_aircraft->multiMotorChannelBox6); addWidget(m_aircraft->multiMotorChannelBox7); addWidget(m_aircraft->multiMotorChannelBox8); + addWidget(m_aircraft->mrPitchMixLevel); + addWidget(m_aircraft->mrRollMixLevel); + addWidget(m_aircraft->mrYawMixLevel); addWidget(m_aircraft->triYawChannelBox); addWidget(m_aircraft->aircraftType); addWidget(m_aircraft->fwEngineChannelBox); diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index c85cb5f30..d128acaf5 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -81,7 +81,7 @@ private: private slots: - virtual void refreshWidgetsValues(); + virtual void refreshWidgetsValues(UAVObject * o=NULL); virtual void updateObjectsFromWidgets(); void setComboCurrentIndex(QComboBox* box, int index); From aa5832b1e88276b7e78e27529981cc51fd43ff51 Mon Sep 17 00:00:00 2001 From: James Cotton Date: Wed, 6 Jun 2012 13:01:15 -0500 Subject: [PATCH 15/15] Remove some style sheets that got dragged back in from conflict --- .../src/plugins/config/airframe.ui | 23 +++---------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index e9370d07d..620faf6c5 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -73,23 +73,6 @@ - - #groupBox,#groupBox_2,#groupBox_3,#groupBox_6,#elevonMixBox{ -background-color: qlineargradient(spread:pad, x1:0.507, y1:0.869318, x2:0.507, y2:0.0965909, stop:0 rgba(243, 243, 243, 255), stop:1 rgba(250, 250, 250, 255)); -border: 1px outset #999; -border-radius: 3; -font:bold; -} - -QGroupBox::title { - subcontrol-origin: margin; - subcontrol-position: top center; /* position at the top center */ - padding: 0 3px; - background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #FFOECE, stop: 1 #FFFFFF); - top: 5px; - } - 1 @@ -2801,14 +2784,14 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD IS DANGEROUS</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</p></td></tr></table></body></html>