setEnabled(false);
}
//issue user instructions
- m_ccpm->SwashLvlStepInstruction->setText("levelling verification
Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel.");
- break;
+ m_aircraft->SwashLvlStepInstruction->setText(
+ "
levelling verification
Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel.");
+ break;
case 5: //levelling complete
//check verify status as complete
- m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Checked);
+ m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Checked);
//issue user instructions
- m_ccpm->SwashLvlStepInstruction->setText("
levelling complete
Press the Finish button to save these settings to the SD card
Press the cancel button to return to the pre-levelling settings");
+ m_aircraft->SwashLvlStepInstruction->setText(
+ "
levelling complete
Press the Finish button to save these settings to the SD card
Press the cancel button to return to the pre-levelling settings");
//disable position slider
- m_ccpm->SwashLvlPositionSlider->setEnabled(false);
- m_ccpm->SwashLvlPositionSpinBox->setEnabled(false);
+ m_aircraft->SwashLvlPositionSlider->setEnabled(false);
+ m_aircraft->SwashLvlPositionSpinBox->setEnabled(false);
//disconnect levelling slots from signals
- disconnect(m_ccpm->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
- for (i=0;iSwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int)));
+ for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
disconnect(SwashLvlSpinBoxes[i], SIGNAL(valueChanged(int)), this, SLOT(SwashLvlSpinBoxChanged(int)));
}
- m_ccpm->SwashLvlStartButton->setEnabled(false);
- m_ccpm->SwashLvlNextButton->setEnabled(false);
- m_ccpm->SwashLvlCancelButton->setEnabled(true);
- m_ccpm->SwashLvlFinishButton->setEnabled(true);
+ m_aircraft->SwashLvlStartButton->setEnabled(false);
+ m_aircraft->SwashLvlNextButton->setEnabled(false);
+ m_aircraft->SwashLvlCancelButton->setEnabled(true);
+ m_aircraft->SwashLvlFinishButton->setEnabled(true);
default:
//restore collective/cyclic setting
@@ -1230,24 +1227,24 @@ void ConfigCcpmWidget::SwashLvlNextButtonPressed()
break;
}
}
+
void ConfigCcpmWidget::SwashLvlCancelButtonPressed()
{
- int i;
- SwashLvlState=0;
+ SwashLvlState = 0;
- UAVObjectField* MinField;
- UAVObjectField* NeutralField;
- UAVObjectField* MaxField;
+ UAVObjectField *MinField;
+ UAVObjectField *NeutralField;
+ UAVObjectField *MaxField;
- m_ccpm->SwashLvlStartButton->setEnabled(true);
- m_ccpm->SwashLvlNextButton->setEnabled(false);
- m_ccpm->SwashLvlCancelButton->setEnabled(false);
- m_ccpm->SwashLvlFinishButton->setEnabled(false);
+ m_aircraft->SwashLvlStartButton->setEnabled(true);
+ m_aircraft->SwashLvlNextButton->setEnabled(false);
+ m_aircraft->SwashLvlCancelButton->setEnabled(false);
+ m_aircraft->SwashLvlFinishButton->setEnabled(false);
- m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
- m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
- m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
- m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
+ m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked);
+ m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked);
+ m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked);
+ m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked);
//restore old Actuator Settings
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@@ -1259,110 +1256,110 @@ void ConfigCcpmWidget::SwashLvlCancelButtonPressed()
NeutralField = obj->getField(QString("ChannelNeutral"));
MaxField = obj->getField(QString("ChannelMax"));
- //min,neutral,max values for the servos
- for (i=0;isetValue(oldSwashLvlConfiguration.Min[i],oldSwashLvlConfiguration.ServoChannels[i]);
- NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i],oldSwashLvlConfiguration.ServoChannels[i]);
- MaxField->setValue(oldSwashLvlConfiguration.Max[i],oldSwashLvlConfiguration.ServoChannels[i]);
+ // min,neutral,max values for the servos
+ for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
+ MinField->setValue(oldSwashLvlConfiguration.Min[i], oldSwashLvlConfiguration.ServoChannels[i]);
+ NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i], oldSwashLvlConfiguration.ServoChannels[i]);
+ MaxField->setValue(oldSwashLvlConfiguration.Max[i], oldSwashLvlConfiguration.ServoChannels[i]);
}
obj->updated();
-
- //restore Flight control of ActuatorCommand
+ // restore Flight control of ActuatorCommand
enableSwashplateLevellingControl(false);
- m_ccpm->SwashLvlStepInstruction->setText("Levelling Cancelled
Previous settings have been restored.");
-
+ m_aircraft->SwashLvlStepInstruction->setText(
+ "
Levelling Cancelled
Previous settings have been restored.");
}
void ConfigCcpmWidget::SwashLvlFinishButtonPressed()
{
- int i;
+ UAVObjectField *MinField;
+ UAVObjectField *NeutralField;
+ UAVObjectField *MaxField;
- UAVObjectField* MinField;
- UAVObjectField* NeutralField;
- UAVObjectField* MaxField;
+ m_aircraft->SwashLvlStartButton->setEnabled(true);
+ m_aircraft->SwashLvlNextButton->setEnabled(false);
+ m_aircraft->SwashLvlCancelButton->setEnabled(false);
+ m_aircraft->SwashLvlFinishButton->setEnabled(false);
- m_ccpm->SwashLvlStartButton->setEnabled(true);
- m_ccpm->SwashLvlNextButton->setEnabled(false);
- m_ccpm->SwashLvlCancelButton->setEnabled(false);
- m_ccpm->SwashLvlFinishButton->setEnabled(false);
-
- //save new Actuator Settings to memory and SD card
+ // save new Actuator Settings to memory and SD card
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject();
UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ActuatorSettings")));
Q_ASSERT(obj);
- //update settings to match our changes.
+
+ // update settings to match our changes.
MinField = obj->getField(QString("ChannelMin"));
NeutralField = obj->getField(QString("ChannelNeutral"));
MaxField = obj->getField(QString("ChannelMax"));
- //min,neutral,max values for the servos
- for (i=0;isetValue(newSwashLvlConfiguration.Min[i],newSwashLvlConfiguration.ServoChannels[i]);
- NeutralField->setValue(newSwashLvlConfiguration.Neutral[i],newSwashLvlConfiguration.ServoChannels[i]);
- MaxField->setValue(newSwashLvlConfiguration.Max[i],newSwashLvlConfiguration.ServoChannels[i]);
+ // min,neutral,max values for the servos
+ for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
+ MinField->setValue(newSwashLvlConfiguration.Min[i], newSwashLvlConfiguration.ServoChannels[i]);
+ NeutralField->setValue(newSwashLvlConfiguration.Neutral[i], newSwashLvlConfiguration.ServoChannels[i]);
+ MaxField->setValue(newSwashLvlConfiguration.Max[i], newSwashLvlConfiguration.ServoChannels[i]);
}
obj->updated();
saveObjectToSD(obj);
- //restore Flight control of ActuatorCommand
+ // restore Flight control of ActuatorCommand
enableSwashplateLevellingControl(false);
- m_ccpm->SwashLvlStepInstruction->setText("Levelling Completed
New settings have been saved to the SD card");
+ m_aircraft->SwashLvlStepInstruction->setText(
+ "
Levelling Completed
New settings have been saved to the SD card");
ShowDisclaimer(0);
//ShowDisclaimer(2);
-
}
int ConfigCcpmWidget::ShowDisclaimer(int messageID)
{
- QMessageBox msgBox;
- msgBox.setText("Warning!!!
");
- int ret;
- switch (messageID) {
- case 0:
- // Basic disclaimer
- msgBox.setInformativeText("
This code has many configurations.
Please double check all settings before attempting flight!");
- msgBox.setStandardButtons(QMessageBox::Ok);
- msgBox.setDefaultButton(QMessageBox::Ok);
- msgBox.setIcon(QMessageBox::Information);
- ret = msgBox.exec();
- return 0;
- break;
- case 1:
- // Not Tested disclaimer
- msgBox.setInformativeText("
The CCPM mixer code needs more testing!
Use it at your own risk!
Do you wish to continue?");
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
- msgBox.setDefaultButton(QMessageBox::Cancel);
- msgBox.setIcon(QMessageBox::Warning);
- ret = msgBox.exec();
- switch (ret)
- {
- case QMessageBox::Cancel: return -1;
- case QMessageBox::Yes: return 0;
- }
- break;
- case 2:
- // DO NOT use
- msgBox.setInformativeText("
The CCPM swashplate levelling code is NOT complete!
DO NOT use it for flight!");
- msgBox.setStandardButtons(QMessageBox::Ok);
- msgBox.setDefaultButton(QMessageBox::Ok);
- msgBox.setIcon(QMessageBox::Critical);
- ret = msgBox.exec();
+ QMessageBox msgBox;
+ msgBox.setText("Warning!!!
");
+ int ret;
+ switch (messageID) {
+ case 0:
+ // Basic disclaimer
+ msgBox.setInformativeText(
+ "
This code has many configurations.
Please double check all settings before attempting flight!");
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.setDefaultButton(QMessageBox::Ok);
+ msgBox.setIcon(QMessageBox::Information);
+ ret = msgBox.exec();
+ return 0;
+ break;
+ case 1:
+ // Not Tested disclaimer
+ msgBox.setInformativeText(
+ "
The CCPM mixer code needs more testing!
Use it at your own risk!
Do you wish to continue?");
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+ msgBox.setIcon(QMessageBox::Warning);
+ ret = msgBox.exec();
+ switch (ret) {
+ case QMessageBox::Cancel:
+ return -1;
+ case QMessageBox::Yes:
return 0;
- break;
- default:
- // should never be reached
- break;
}
+ break;
+ case 2:
+ // DO NOT use
+ msgBox.setInformativeText(
+ "
The CCPM swashplate levelling code is NOT complete!
DO NOT use it for flight!");
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.setDefaultButton(QMessageBox::Ok);
+ msgBox.setIcon(QMessageBox::Critical);
+ ret = msgBox.exec();
+ return 0;
+ break;
+ default:
+ // should never be reached
+ break;
+ }
return -1;
}
@@ -1378,33 +1375,30 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state)
UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ActuatorCommand")));
UAVObject::Metadata mdata = obj->getMetadata();
- if (state)
- {
+ if (state) {
SwashLvlaccInitialData = mdata;
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY);
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
UAVObject::SetGcsTelemetryAcked(mdata, false);
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
mdata.gcsTelemetryUpdatePeriod = 100;
- SwashLvlConfigurationInProgress=1;
- m_ccpm->TabObject->setTabEnabled(0,0);
- m_ccpm->TabObject->setTabEnabled(2,0);
- m_ccpm->TabObject->setTabEnabled(3,0);
- m_ccpm->ccpmType->setEnabled(0);
- }
- else
- {
- mdata = SwashLvlaccInitialData; // Restore metadata
- SwashLvlConfigurationInProgress=0;
+ SwashLvlConfigurationInProgress = 1;
+ m_aircraft->TabObject->setTabEnabled(0, 0);
+ m_aircraft->TabObject->setTabEnabled(2, 0);
+ m_aircraft->TabObject->setTabEnabled(3, 0);
+ m_aircraft->ccpmType->setEnabled(0);
+ } else {
+ // Restore metadata
+ mdata = SwashLvlaccInitialData;
+ SwashLvlConfigurationInProgress = 0;
- m_ccpm->TabObject->setTabEnabled(0,1);
- m_ccpm->TabObject->setTabEnabled(2,1);
- m_ccpm->TabObject->setTabEnabled(3,1);
- m_ccpm->ccpmType->setEnabled(1);
+ m_aircraft->TabObject->setTabEnabled(0, 1);
+ m_aircraft->TabObject->setTabEnabled(2, 1);
+ m_aircraft->TabObject->setTabEnabled(3, 1);
+ m_aircraft->ccpmType->setEnabled(1);
}
obj->setMetadata(mdata);
-
}
/**
@@ -1413,26 +1407,34 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state)
*/
void ConfigCcpmWidget::setSwashplateLevel(int percent)
{
- if (percent<0)return;// -1;
- if (percent>100)return;// -1;
- if (SwashLvlConfigurationInProgress!=1)return;// -1;
- int i;
- double value;
- double level = ((double)percent /50.00) - 1.00;
+ if (percent < 0) {
+ return; // -1;
+ }
+ if (percent > 100) {
+ return; // -1;
+ }
+ if (SwashLvlConfigurationInProgress != 1) {
+ return; // -1;
+ }
- SwashLvlServoInterlock=1;
+ double level = ((double) percent / 50.00) - 1.00;
- ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
+ SwashLvlServoInterlock = 1;
+
+ ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData();
- for (i=0;i 0)
- value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i])*level + newSwashLvlConfiguration.Neutral[i];
- else if (level < 0)
- value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i])*level + newSwashLvlConfiguration.Neutral[i];
-
+ } else if (level > 0) {
+ value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i]) * level
+ + newSwashLvlConfiguration.Neutral[i];
+ } else if (level < 0) {
+ value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i]) * level
+ + newSwashLvlConfiguration.Neutral[i];
+ }
actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value;
SwashLvlSpinBoxes[i]->setValue(value);
}
@@ -1440,38 +1442,42 @@ void ConfigCcpmWidget::setSwashplateLevel(int percent)
actuatorCommand->setData(actuatorCommandData);
actuatorCommand->updated();
- SwashLvlServoInterlock=0;
-
-return;
+ SwashLvlServoInterlock = 0;
}
void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
{
Q_UNUSED(value);
- int i;
- if (SwashLvlServoInterlock==1)return;
- ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
+ if (SwashLvlServoInterlock == 1) {
+ return;
+ }
+
+ ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData();
- for (i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
+ for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) {
value = SwashLvlSpinBoxes[i]->value();
- switch (SwashLvlState)
- {
- case 1: //Neutral levelling
- newSwashLvlConfiguration.Neutral[i]=value;
+ switch (SwashLvlState) {
+ case 1:
+ // Neutral levelling
+ newSwashLvlConfiguration.Neutral[i] = value;
break;
- case 2: //Max levelling
+ case 2:
+ // Max levelling
newSwashLvlConfiguration.Max[i] = value;
break;
- case 3: //Min levelling
- newSwashLvlConfiguration.Min[i]= value;
+ case 3:
+ // Min levelling
+ newSwashLvlConfiguration.Min[i] = value;
break;
- case 4: //levelling verification
+ case 4:
+ // levelling verification
break;
- case 5: //levelling complete
+ case 5:
+ // levelling complete
break;
default:
break;
@@ -1480,7 +1486,6 @@ void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value;
}
-
actuatorCommand->setData(actuatorCommandData);
actuatorCommand->updated();
@@ -1496,63 +1501,45 @@ bool ConfigCcpmWidget::throwConfigError(QString airframeType)
bool error = false;
- if((m_ccpm->ccpmServoWChannel->currentIndex()==0) && (m_ccpm->ccpmServoWChannel->isEnabled()))
- {
- m_ccpm->ccpmServoWLabel->setText("" + m_ccpm->ccpmServoWLabel->text() + "");
+ if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isEnabled())) {
+ m_aircraft->ccpmServoWLabel->setText("" + m_aircraft->ccpmServoWLabel->text() + "");
error = true;
- }
- else
- {
- m_ccpm->ccpmServoWLabel->setText(QTextEdit(m_ccpm->ccpmServoWLabel->text()).toPlainText());
+ } else {
+ m_aircraft->ccpmServoWLabel->setText(QTextEdit(m_aircraft->ccpmServoWLabel->text()).toPlainText());
}
- if((m_ccpm->ccpmServoXChannel->currentIndex()==0) && (m_ccpm->ccpmServoXChannel->isEnabled()))
- {
- m_ccpm->ccpmServoXLabel->setText("" + m_ccpm->ccpmServoXLabel->text() + "");
+ if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isEnabled())) {
+ m_aircraft->ccpmServoXLabel->setText("" + m_aircraft->ccpmServoXLabel->text() + "");
error = true;
- }
- else
- {
- m_ccpm->ccpmServoXLabel->setText(QTextEdit(m_ccpm->ccpmServoXLabel->text()).toPlainText());
+ } else {
+ m_aircraft->ccpmServoXLabel->setText(QTextEdit(m_aircraft->ccpmServoXLabel->text()).toPlainText());
}
- if((m_ccpm->ccpmServoYChannel->currentIndex()==0) && (m_ccpm->ccpmServoYChannel->isEnabled()))
- {
- m_ccpm->ccpmServoYLabel->setText("" + m_ccpm->ccpmServoYLabel->text() + "");
+ if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isEnabled())) {
+ m_aircraft->ccpmServoYLabel->setText("" + m_aircraft->ccpmServoYLabel->text() + "");
error = true;
- }
- else
- {
- m_ccpm->ccpmServoYLabel->setText(QTextEdit(m_ccpm->ccpmServoYLabel->text()).toPlainText());
+ } else {
+ m_aircraft->ccpmServoYLabel->setText(QTextEdit(m_aircraft->ccpmServoYLabel->text()).toPlainText());
}
- if((m_ccpm->ccpmServoZChannel->currentIndex()==0) && (m_ccpm->ccpmServoZChannel->isEnabled()))
- {
- m_ccpm->ccpmServoZLabel->setText("" + m_ccpm->ccpmServoZLabel->text()+ "");
+ if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isEnabled())) {
+ m_aircraft->ccpmServoZLabel->setText("" + m_aircraft->ccpmServoZLabel->text() + "");
error = true;
- }
- else
- {
- m_ccpm->ccpmServoZLabel->setText(QTextEdit(m_ccpm->ccpmServoZLabel->text()).toPlainText());
+ } else {
+ m_aircraft->ccpmServoZLabel->setText(QTextEdit(m_aircraft->ccpmServoZLabel->text()).toPlainText());
}
- if((m_ccpm->ccpmEngineChannel->currentIndex()==0) && (m_ccpm->ccpmEngineChannel->isEnabled()))
- {
- m_ccpm->ccpmEngineLabel->setText("" + m_ccpm->ccpmEngineLabel->text() + "");
- }
- else
- {
- m_ccpm->ccpmEngineLabel->setText(QTextEdit(m_ccpm->ccpmEngineLabel->text()).toPlainText());
+ if ((m_aircraft->ccpmEngineChannel->currentIndex() == 0) && (m_aircraft->ccpmEngineChannel->isEnabled())) {
+ m_aircraft->ccpmEngineLabel->setText("" + m_aircraft->ccpmEngineLabel->text() + "");
+ } else {
+ m_aircraft->ccpmEngineLabel->setText(QTextEdit(m_aircraft->ccpmEngineLabel->text()).toPlainText());
}
- if((m_ccpm->ccpmTailChannel->currentIndex()==0) && (m_ccpm->ccpmTailChannel->isEnabled()))
- {
- m_ccpm->ccpmTailLabel->setText("" + m_ccpm->ccpmTailLabel->text() + "");
+ if ((m_aircraft->ccpmTailChannel->currentIndex() == 0) && (m_aircraft->ccpmTailChannel->isEnabled())) {
+ m_aircraft->ccpmTailLabel->setText("" + m_aircraft->ccpmTailLabel->text() + "");
error = true;
- }
- else
- {
- m_ccpm->ccpmTailLabel->setText(QTextEdit(m_ccpm->ccpmTailLabel->text()).toPlainText());
+ } else {
+ m_aircraft->ccpmTailLabel->setText(QTextEdit(m_aircraft->ccpmTailLabel->text()).toPlainText());
}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h
index 7f091c1fb..2890cffdb 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h
@@ -28,7 +28,7 @@
#define CONFIGccpmWIDGET_H
#include "cfg_vehicletypes/vehicleconfig.h"
-#include "ui_ccpm.h"
+#include "ui_airframe_ccpm.h"
#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
@@ -52,7 +52,6 @@ typedef struct {
int Min[CCPM_MAX_SWASH_SERVOS];
} SwashplateServoSettingsStruct;
-
class ConfigCcpmWidget: public VehicleConfig
{
Q_OBJECT
@@ -64,7 +63,9 @@ public:
friend class ConfigVehicleTypeWidget;
private:
- Ui_ccpmWidget *m_ccpm;
+ //Ui_ccpmWidget *m_ccpm;
+ Ui_CcpmConfigWidget *m_aircraft;
+
QGraphicsSvgItem *SwashplateImg;
QGraphicsSvgItem *CurveImg;
QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
@@ -90,7 +91,7 @@ private:
bool updatingFromHardware;
bool updatingToHardware;
- virtual void ResetActuators(GUIConfigDataUnion* configData);
+ virtual void ResetActuators(GUIConfigDataUnion *configData);
static QStringList getChannelDescriptions();
QString updateConfigObjects();
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp
new file mode 100644
index 000000000..07c453c93
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp
@@ -0,0 +1,293 @@
+/**
+ ******************************************************************************
+ *
+ * @file configmultirotorwidget.cpp
+ * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
+ * @addtogroup GCSPlugins GCS Plugins
+ * @{
+ * @addtogroup ConfigPlugin Config Plugin
+ * @{
+ * @brief ccpm 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
+ */
+#include "configcustomwidget.h"
+#include "mixersettings.h"
+//#include "systemsettings.h"
+//#include "actuatorsettings.h"
+//#include "actuatorcommand.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+//const QString ConfigCustomWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
+
+ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget())
+{
+ m_aircraft->setupUi(this);
+
+ // Put combo boxes in line one of the custom mixer table:
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ UAVObjectField* field = mixer->getField(QString("Mixer1Type"));
+ QStringList list = field->getOptions();
+ for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+ QComboBox* qb = new QComboBox(m_aircraft->customMixerTable);
+ qb->addItems(list);
+ m_aircraft->customMixerTable->setCellWidget(0, i, qb);
+ }
+
+ SpinBoxDelegate *sbd = new SpinBoxDelegate();
+ for (int i = 1; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+ m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
+ }
+}
+
+ConfigCustomWidget::~ConfigCustomWidget()
+{
+ delete m_aircraft;
+}
+
+void ConfigCustomWidget::setupUI(QString frameType)
+{
+ Q_ASSERT(m_aircraft);
+
+ m_aircraft->customMixerTable->resizeColumnsToContents();
+
+ for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+ m_aircraft->customMixerTable->setColumnWidth(i,
+ (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10);
+ }
+}
+
+QStringList ConfigCustomWidget::getChannelDescriptions()
+{
+ QStringList channelDesc;
+
+ for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+ channelDesc.append(QString("-"));
+ }
+
+ return channelDesc;
+}
+
+/**
+ Helper function to update the UI widget objects
+ */
+QString ConfigCustomWidget::updateConfigObjectsFromWidgets()
+{
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
+ setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve());
+
+ // Update the table:
+ for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) {
+ QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel);
+ if (q->currentText() == "Disabled") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
+ } else if (q->currentText() == "Motor") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
+ } else if (q->currentText() == "Servo") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
+ } else if (q->currentText() == "CameraRoll") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL);
+ } else if (q->currentText() == "CameraPitch") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH);
+ } else if (q->currentText() == "CameraYaw") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW);
+ } else if (q->currentText() == "Accessory0") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0);
+ } else if (q->currentText() == "Accessory1") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1);
+ } else if (q->currentText() == "Accessory2") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2);
+ } else if (q->currentText() == "Accessory3") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3);
+ } else if (q->currentText() == "Accessory4") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4);
+ } else if (q->currentText() == "Accessory5") {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5);
+ }
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
+ m_aircraft->customMixerTable->item(1, channel)->text().toDouble());
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
+ m_aircraft->customMixerTable->item(2, channel)->text().toDouble());
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL,
+ m_aircraft->customMixerTable->item(3, channel)->text().toDouble());
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH,
+ m_aircraft->customMixerTable->item(4, channel)->text().toDouble());
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW,
+ m_aircraft->customMixerTable->item(5, channel)->text().toDouble());
+ }
+
+ return "Custom";
+}
+
+/**
+ Helper function to refresh the UI widget values
+ */
+void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
+{
+ Q_ASSERT(m_aircraft);
+
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ QList curveValues;
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+
+ // is at least one of the curve values != 0?
+ if (isValidThrottleCurve(&curveValues)) {
+ // yes, use the curve we just read from mixersettings
+ m_aircraft->customThrottle1Curve->initCurve(&curveValues);
+ }
+ else {
+ // no, init a straight curve
+ m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
+ }
+
+ if (MixerSettings *mxr = qobject_cast(mixer)) {
+ MixerSettings::DataFields mixerSettingsData = mxr->getData();
+ if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
+ m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
+ else {
+ m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
+ }
+ }
+
+ // Setup all Throttle2 curves for all types of airframes
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
+
+ if (isValidThrottleCurve(&curveValues)) {
+ m_aircraft->customThrottle2Curve->initCurve(&curveValues);
+ }
+ else {
+ m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_aircraft->customThrottle2Curve->getMin());
+ }
+
+ // Update the mixer table:
+ for (int channel = 0; channel < m_aircraft->customMixerTable->columnCount(); channel++) {
+ UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
+ if (field) {
+ QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel);
+ if (q) {
+ QString s = field->getValue().toString();
+ setComboCurrentIndex(q, q->findText(s));
+ }
+
+ m_aircraft->customMixerTable->item(1, channel)->setText(
+ QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
+ m_aircraft->customMixerTable->item(2, channel)->setText(
+ QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
+ m_aircraft->customMixerTable->item(3, channel)->setText(
+ QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL)));
+ m_aircraft->customMixerTable->item(4, channel)->setText(
+ QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH)));
+ m_aircraft->customMixerTable->item(5, channel)->setText(
+ QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW)));
+ }
+ }
+}
+
+/**
+ This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
+ */
+bool ConfigCustomWidget::throwConfigError(int numMotors)
+{
+ return false;
+}
+
+/**
+ WHAT DOES THIS DO???
+ */
+void ConfigCustomWidget::showEvent(QShowEvent *event)
+{
+ Q_UNUSED(event)
+ m_aircraft->customMixerTable->resizeColumnsToContents();
+ for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+ m_aircraft->customMixerTable->setColumnWidth(i,
+ (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10);
+ }
+}
+
+/**
+ Resize the GUI contents when the user changes the window size
+ */
+void ConfigCustomWidget::resizeEvent(QResizeEvent *event)
+{
+ Q_UNUSED(event);
+ // Make the custom table columns autostretch:
+ m_aircraft->customMixerTable->resizeColumnsToContents();
+ int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM;
+ for (int i = 0; i < channelCount; i++) {
+ m_aircraft->customMixerTable->setColumnWidth(i,
+ (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount);
+ }
+}
+
+/**
+ Helper delegate for the custom mixer editor table.
+ Taken straight from Qt examples, thanks!
+*/
+SpinBoxDelegate::SpinBoxDelegate(QObject *parent) :
+ QItemDelegate(parent)
+{
+}
+
+QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ QSpinBox *editor = new QSpinBox(parent);
+ editor->setMinimum(-127);
+ editor->setMaximum(127);
+
+ return editor;
+}
+
+void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+{
+ int value = index.model()->data(index, Qt::EditRole).toInt();
+
+ QSpinBox *spinBox = static_cast(editor);
+ spinBox->setValue(value);
+}
+
+void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
+{
+ QSpinBox *spinBox = static_cast(editor);
+ spinBox->interpretText();
+ int value = spinBox->value();
+
+ model->setData(index, value, Qt::EditRole);
+}
+
+void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const
+{
+ editor->setGeometry(option.rect);
+}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h
new file mode 100644
index 000000000..08fcd549a
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h
@@ -0,0 +1,91 @@
+/**
+ ******************************************************************************
+ *
+ * @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 CONFIGCUSTOMWIDGET_H
+#define CONFIGCUSTOMWIDGET_H
+
+#include "cfg_vehicletypes/vehicleconfig.h"
+#include "ui_airframe_custom.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 ConfigCustomWidget: public VehicleConfig
+{
+ Q_OBJECT
+
+public:
+ ConfigCustomWidget(QWidget *parent = 0);
+ ~ConfigCustomWidget();
+
+ friend class ConfigVehicleTypeWidget;
+
+private:
+ Ui_CustomConfigWidget *m_aircraft;
+
+ //virtual void ResetActuators(GUIConfigDataUnion *configData);
+ static QStringList getChannelDescriptions();
+// static const QString CHANNELBOXNAME;
+
+private slots:
+ virtual void setupUI(QString airframeType);
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
+ virtual bool throwConfigError(int numMotors);
+
+protected:
+ void showEvent(QShowEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+signals:
+ void configurationChanged();
+
+};
+
+class SpinBoxDelegate : public QItemDelegate
+{
+ Q_OBJECT
+
+public:
+ SpinBoxDelegate(QObject *parent = 0);
+
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
+ void setEditorData(QWidget *editor, const QModelIndex &index) const;
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
+
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+};
+
+#endif // CONFIGCUSTOMWIDGET_H
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp
index 27a62ec9c..8c3ae1167 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp
@@ -41,20 +41,24 @@
#include
#include
-/**
- Constructor
- */
-ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
+ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget())
{
- m_aircraft = aircraft;
+ m_aircraft->setupUi(this);
+
+ QStringList fixedWingTypes;
+ fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
+ m_aircraft->fixedWingType->addItems(fixedWingTypes);
+
+ // Set default model to "Elevator aileron rudder"
+ m_aircraft->fixedWingType->setCurrentIndex(0);
+
+ connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
}
-/**
- Destructor
- */
ConfigFixedWingWidget::~ConfigFixedWingWidget()
{
- // Do nothing
+ delete m_aircraft;
}
/**
@@ -65,7 +69,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
Q_ASSERT(m_aircraft);
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
- // Setup the UI
//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);
@@ -210,6 +213,30 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
{
Q_ASSERT(m_aircraft);
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ QList curveValues;
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+
+ // is at least one of the curve values != 0?
+ if (isValidThrottleCurve(&curveValues)) {
+ // yes, use the curve we just read from mixersettings
+ m_aircraft->fixedWingThrottle->initCurve(&curveValues);
+ }
+ else {
+ // no, init a straight curve
+ m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
+ }
+
+
+
+
+
+
+
+
+
GUIConfigDataUnion config = GetConfigData();
fixedGUISettingsStruct fixed = config.fixedwing;
@@ -222,26 +249,32 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
- UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixer);
+ //UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ //Q_ASSERT(mixer);
int channel;
- if (frameType == "FixedWingElevon") {
+ if (frameType == "FixedWingElevon") {
// If the airframe is elevon, restore the slider setting
// Find the channel number for Elevon1 (FixedWingRoll1)
- channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
- if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
- m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)*100);
- m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
- }
- }
- if (frameType == "FixedWingVtail") {
- channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
- if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
- m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)*100);
- m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
+ channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
+ if (channel > -1) {
+ // If for some reason the actuators were incoherent, we might fail here, hence the check.
+ m_aircraft->elevonSlider1->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
+ m_aircraft->elevonSlider2->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
}
- }
+ }
+ else if (frameType == "FixedWingVtail") {
+ channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
+ if (channel > -1) {
+ // If for some reason the actuators were incoherent, we might fail here, hence the check.
+ m_aircraft->elevonSlider1->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) * 100);
+ m_aircraft->elevonSlider2->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
+ }
+ }
}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
index 282fc3447..21dff9658 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
@@ -46,7 +46,7 @@ class ConfigFixedWingWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft = 0, QWidget *parent = 0);
+ ConfigFixedWingWidget(QWidget *parent = 0);
~ConfigFixedWingWidget();
friend class ConfigVehicleTypeWidget;
@@ -67,10 +67,8 @@ private slots:
virtual QString updateConfigObjectsFromWidgets();
virtual bool 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 01a7d3492..b2e419f42 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp
@@ -41,29 +41,42 @@
#include
#include
-ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
+ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget())
{
- m_aircraft = aircraft;
+ m_aircraft->setupUi(this);
+
+ QStringList groundVehicleTypes;
+ groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
+ m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
+
+ // Set default model to "Turnable (car)"
+ m_aircraft->groundVehicleType->setCurrentIndex(0);
+
+ setupUI(m_aircraft->groundVehicleType->currentText());
+
+ connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
}
ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
{
- // Do nothing
+ delete m_aircraft;
}
/**
Virtual function to setup the UI
+ TODO move to constructor or make private
*/
void ConfigGroundVehicleWidget::setupUI(QString frameType)
{
m_aircraft->differentialSteeringMixBox->setHidden(true);
//STILL NEEDS WORK
+
// Setup the UI
//setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
m_aircraft->gvEngineChannelBox->setEnabled(false);
m_aircraft->gvEngineLabel->setEnabled(false);
-
m_aircraft->gvAileron1ChannelBox->setEnabled(false);
m_aircraft->gvAileron1Label->setEnabled(false);
@@ -71,7 +84,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvAileron2ChannelBox->setEnabled(false);
m_aircraft->gvAileron2Label->setEnabled(false);
- if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank
+ if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") {
+ // Tank
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
m_aircraft->gvMotor1Label->setEnabled(true);
@@ -96,7 +110,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
}
- else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle
+ else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") {
+ // Motorcycle
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle"));
m_aircraft->gvMotor1ChannelBox->setEnabled(false);
m_aircraft->gvMotor1Label->setEnabled(false);
@@ -120,7 +135,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType)
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
}
- else {//Car
+ else {
+ // Car
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
@@ -159,28 +175,28 @@ QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
QStringList channelDesc;
// init a channel_numelem list of channel desc defaults
- for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++)
- {
+ 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");
-
+ 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;
}
-
-
/**
Virtual function to update the UI widget objects
*/
@@ -195,33 +211,68 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
setMixerValue(mixer, "FeedForward", 0.0);
// set the throttle curves
- setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve() );
- setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve() );
+ setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve());
+ setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve());
- //All airframe types must start with "GroundVehicle"
- if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)" ) {
- airframeType = "GroundVehicleCar";
- setupGroundVehicleCar(airframeType);
- } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
- airframeType = "GroundVehicleDifferential";
- setupGroundVehicleDifferential(airframeType);
- } else { // "Motorcycle"
- airframeType = "GroundVehicleMotorcycle";
- setupGroundVehicleMotorcycle(airframeType);
- }
+ // All airframe types must start with "GroundVehicle"
+ if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") {
+ airframeType = "GroundVehicleCar";
+ setupGroundVehicleCar(airframeType);
+ } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
+ airframeType = "GroundVehicleDifferential";
+ setupGroundVehicleDifferential(airframeType);
+ } else { // "Motorcycle"
+ airframeType = "GroundVehicleMotorcycle";
+ setupGroundVehicleMotorcycle(airframeType);
+ }
return airframeType;
}
-
-
/**
Virtual function to refresh the UI widget values
*/
void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
{
- UAVDataObject* obj;
-// UAVObjectField *field;
+ qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType;
+
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ QList curveValues;
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+
+ // is at least one of the curve values != 0?
+ if (isValidThrottleCurve(&curveValues)) {
+ // yes, use the curve we just read from mixersettings
+ m_aircraft->groundVehicleThrottle1->initCurve(&curveValues);
+ }
+ else {
+ // no, init a straight curve
+ m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
+ }
+
+ // Setup all Throttle2 curves for all types of airframes
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
+
+ if (isValidThrottleCurve(&curveValues)) {
+ m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
+ }
+ else {
+ m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
+ }
+
+
+
+
+
+
+
+
+
+
+ //UAVDataObject *obj;
+ //UAVObjectField *field;
GUIConfigDataUnion config = GetConfigData();
@@ -237,16 +288,18 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
// If the vehicle type is "differential", restore the slider setting
// Find the channel number for Motor1
- obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(obj);
- int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
- 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);
- m_aircraft->differentialSteeringSlider2->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_PITCH)*100);
- }
+ //obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ //Q_ASSERT(obj);
+ int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
+ if (channel > -1) {
+ // If for some reason the actuators were incoherent, we might fail here, hence the check.
+ m_aircraft->differentialSteeringSlider1->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
+ m_aircraft->differentialSteeringSlider2->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
+ }
}
- if (frameType == "GroundVehicleMotorcycle") {
+ else if (frameType == "GroundVehicleMotorcycle") {
//CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
// Q_ASSERT(obj);
@@ -311,8 +364,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp
return true;
}
-
-
/**
Setup differentially steered ground vehicle.
@@ -355,11 +406,8 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
m_aircraft->gvStatusLabel->setText("Mixer generated");
return true;
-
}
-
-
/**
Setup steerable ground vehicle.
@@ -505,4 +553,3 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
}
return error;
}
-
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h
index 804b0bfa7..97b35c8e4 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h
@@ -46,7 +46,7 @@ class ConfigGroundVehicleWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft = 0, QWidget *parent = 0);
+ ConfigGroundVehicleWidget(QWidget *parent = 0);
~ConfigGroundVehicleWidget();
friend class ConfigVehicleTypeWidget;
@@ -71,5 +71,4 @@ 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 678688c6b..f93aceba8 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp
@@ -43,14 +43,50 @@
const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
-ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1)
+ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1)
{
- m_aircraft = aircraft;
+ m_aircraft->setupUi(this);
+
+ // Setup the Multirotor picture in the Quad settings interface
+ m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ QSvgRenderer *renderer = new QSvgRenderer();
+ renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
+
+ quad = new QGraphicsSvgItem();
+ quad->setSharedRenderer(renderer);
+ quad->setElementId("quad-x");
+
+ QGraphicsScene *scene = new QGraphicsScene(this);
+ scene->addItem(quad);
+ scene->setSceneRect(quad->boundingRect());
+ m_aircraft->quadShape->setScene(scene);
+
+ //m_multirotor = new ConfigMultiRotorWidget(m_aircraft);
+ //m_multirotor->quad = quad;
+ uiowner = this;
+ setupUI(m_aircraft->multirotorFrameType->currentText());
+
+ QStringList multiRotorTypes;
+ multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" <<
+ "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
+ "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
+ m_aircraft->multirotorFrameType->addItems(multiRotorTypes);
+ // Set default model to "Quad X"
+ m_aircraft->multirotorFrameType->setCurrentIndex(2);
+
+ connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
+
+ // Connect the multirotor motor reverse checkbox
+ connect(m_aircraft->MultirotorRevMixerCheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
+
+ //m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
}
ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
{
- // Do nothing
+ delete m_aircraft;
}
void ConfigMultiRotorWidget::setupUI(QString frameType)
@@ -59,11 +95,12 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
Q_ASSERT(uiowner);
Q_ASSERT(quad);
- qDebug() << "ConfigMultiRotorWidget::setupUI - begin";
qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType;
- // set aircraftType to Multirotor, disable triyaw channel
+ // set aircraftType to Multirotor
//setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
+
+ // disable triyaw channel
m_aircraft->triYawChannelBox->setEnabled(false);
// disable all motor channel boxes
@@ -77,9 +114,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
}
if (frameType == "Tri" || frameType == "Tricopter Y") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true);
m_aircraft->mrRollMixLevel->setValue(100);
@@ -89,9 +126,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
m_aircraft->triYawChannelBox->setEnabled(true);
}
else if (frameType == "QuadX" || frameType == "Quad X") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
// init mixer levels
@@ -100,9 +137,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
setYawMixLevel(50);
}
else if (frameType == "QuadP" || frameType == "Quad +") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
m_aircraft->mrRollMixLevel->setValue(100);
@@ -110,9 +147,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
setYawMixLevel(50);
}
else if (frameType == "Hexa" || frameType == "Hexacopter") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(50);
@@ -120,31 +157,31 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
setYawMixLevel(33);
}
else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType,
+ m_aircraft->multirotorFrameType->findText("Hexacopter X"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(33);
-
}
else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType,
+ m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
- //Enable all necessary motor channel boxes...
+ // Enable all necessary motor channel boxes...
enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(66);
-
}
else if (frameType == "Octo" || frameType == "Octocopter") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
- //Enable all necessary motor channel boxes
+ // Enable all necessary motor channel boxes
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(33);
@@ -152,31 +189,30 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
setYawMixLevel(25);
}
else if (frameType == "OctoV" || frameType == "Octocopter V") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType,
+ m_aircraft->multirotorFrameType->findText("Octocopter V"));
- //Enable all necessary motor channel boxes
+ // Enable all necessary motor channel boxes
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(25);
m_aircraft->mrPitchMixLevel->setValue(25);
setYawMixLevel(25);
-
}
else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
- //Enable all necessary motor channel boxes
+ // Enable all necessary motor channel boxes
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
-
}
else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
- //Enable all necessary motor channel boxes
+ // Enable all necessary motor channel boxes
enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(50);
@@ -186,15 +222,14 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
// Draw the appropriate airframe
drawAirframe(frameType);
- qDebug() << "ConfigMultiRotorWidget::setupUI - end";
}
void ConfigMultiRotorWidget::drawAirframe(QString frameType)
{
- qDebug() << "ConfigMultiRotorWidget::drawAirframe - begin";
- qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type:" << frameType;
+ qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType;
- invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1;
+ invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1;
+ qDebug() << "ConfigMultiRotorWidget::drawAirframe - invert motors" << invertMotors;
if (frameType == "Tri" || frameType == "Tricopter Y") {
if (invertMotors > 0) {
@@ -203,13 +238,11 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType)
quad->setElementId("tri_reverse");
}
} else if (frameType == "QuadX" || frameType == "Quad X") {
- qDebug() << "ConfigMultiRotorWidget::drawAirframe - 1";
if (invertMotors > 0) {
quad->setElementId("quad-x");
} else {
quad->setElementId("quad-x_reverse");
}
- qDebug() << "ConfigMultiRotorWidget::drawAirframe - 2";
} else if (frameType == "QuadP" || frameType == "Quad +") {
if (invertMotors > 0) {
quad->setElementId("quad-plus");
@@ -259,7 +292,8 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType)
quad->setElementId("octo-coax-X_reverse");
}
}
- qDebug() << "ConfigMultiRotorWidget::drawAirframe - end";
+ m_aircraft->quadShape->setSceneRect(quad->boundingRect());
+ m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
}
void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
@@ -316,12 +350,12 @@ void ConfigMultiRotorWidget::setYawMixLevel(int value)
if(value<0)
{
m_aircraft->mrYawMixLevel->setValue((-1)*value);
- m_aircraft->MultirotorRevMixercheckBox->setChecked(true);
+ m_aircraft->MultirotorRevMixerCheckBox->setChecked(true);
}
else
{
m_aircraft->mrYawMixLevel->setValue(value);
- m_aircraft->MultirotorRevMixercheckBox->setChecked(false);
+ m_aircraft->MultirotorRevMixerCheckBox->setChecked(false);
}
}
@@ -337,11 +371,11 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
QString airframeType;
QList motorList;
- UAVDataObject* mixerObj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixerObj);
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
// Curve is also common to all quads:
- setThrottleCurve(mixerObj, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
+ setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() );
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
airframeType = "QuadP";
@@ -368,17 +402,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
// Motor 1 to 6, Y6 Layout:
// pitch roll yaw
- double mixer [8][3] = {
- { 0.5, 1, -1},
- { 0.5, 1, 1},
- { 0.5, -1, -1},
- { 0.5, -1, 1},
- { -1, 0, -1},
- { -1, 0, 1},
- { 0, 0, 0},
- { 0, 0, 0}
+ double mixerMatrix[8][3] = {
+ { 0.5, 1, -1 },
+ { 0.5, 1, 1 },
+ { 0.5, -1, -1 },
+ { 0.5, -1, 1 },
+ { -1, 0, -1 },
+ { -1, 0, 1 },
+ { 0, 0, 0 },
+ { 0, 0, 0 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
m_aircraft->mrStatusLabel->setText("Configuration OK");
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
@@ -394,17 +428,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
setupMotors(motorList);
// Motor 1 to 8:
// pitch roll yaw
- double mixer [8][3] = {
- { 1, 0, -1},
- { 1, -1, 1},
- { 0, -1, -1},
- { -1, -1, 1},
- { -1, 0, -1},
- { -1, 1, 1},
- { 0, 1, -1},
- { 1, 1, 1}
+ double mixerMatrix[8][3] = {
+ { 1, 0, -1 },
+ { 1, -1, 1 },
+ { 0, -1, -1 },
+ { -1, -1, 1 },
+ { -1, 0, -1 },
+ { -1, 1, 1 },
+ { 0, 1, -1 },
+ { 1, 1, 1 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
m_aircraft->mrStatusLabel->setText("Configuration OK");
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
@@ -420,17 +454,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
// Motor 1 to 8:
// IMPORTANT: Assumes evenly spaced engines
// pitch roll yaw
- double mixer [8][3] = {
- { 0.33, -1, -1},
- { 1 , -1, 1},
- { -1 , -1, -1},
- { -0.33, -1, 1},
- { -0.33, 1, -1},
- { -1 , 1, 1},
- { 1 , 1, -1},
- { 0.33, 1, 1}
+ double mixerMatrix[8][3] = {
+ { 0.33, -1, -1 },
+ { 1 , -1, 1 },
+ { -1 , -1, -1 },
+ { -0.33, -1, 1 },
+ { -0.33, 1, -1 },
+ { -1 , 1, 1 },
+ { 1 , 1, -1 },
+ { 0.33, 1, 1 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
m_aircraft->mrStatusLabel->setText("Configuration OK");
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
@@ -445,17 +479,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
setupMotors(motorList);
// Motor 1 to 8:
// pitch roll yaw
- double mixer [8][3] = {
- { 1, 0, -1},
- { 1, 0, 1},
- { 0, -1, -1},
- { 0, -1, 1},
- { -1, 0, -1},
- { -1, 0, 1},
- { 0, 1, -1},
- { 0, 1, 1}
+ double mixerMatrix[8][3] = {
+ { 1, 0, -1 },
+ { 1, 0, 1 },
+ { 0, -1, -1 },
+ { 0, -1, 1 },
+ { -1, 0, -1 },
+ { -1, 0, 1 },
+ { 0, 1, -1 },
+ { 0, 1, 1 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
m_aircraft->mrStatusLabel->setText("Configuration OK");
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
@@ -470,17 +504,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
setupMotors(motorList);
// Motor 1 to 8:
// pitch roll yaw
- double mixer [8][3] = {
- { 1, 1, -1},
- { 1, 1, 1},
- { 1, -1, -1},
- { 1, -1, 1},
- { -1, -1, -1},
- { -1, -1, 1},
- { -1, 1, -1},
- { -1, 1, 1}
+ double mixerMatrix[8][3] = {
+ { 1, 1, -1 },
+ { 1, 1, 1 },
+ { 1, -1, -1 },
+ { 1, -1, 1 },
+ { -1, -1, -1 },
+ { -1, -1, 1 },
+ { -1, 1, -1 },
+ { -1, 1, 1 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
m_aircraft->mrStatusLabel->setText("Configuration OK");
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
@@ -505,24 +539,24 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
// Motor 1 to 6, Y6 Layout:
// pitch roll yaw
- double mixer [8][3] = {
- { 0.5, 1, 0},
- { 0.5, -1, 0},
- { -1, 0, 0},
- { 0, 0, 0},
- { 0, 0, 0},
- { 0, 0, 0},
- { 0, 0, 0},
- { 0, 0, 0}
+ double mixerMatrix[8][3] = {
+ { 0.5, 1, 0 },
+ { 0.5, -1, 0 },
+ { -1, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 },
+ { 0, 0, 0 }
};
- setupMultiRotorMixer(mixer);
+ setupMultiRotorMixer(mixerMatrix);
- //tell the mixer about tricopter yaw channel
+ // tell the mixer about tricopter yaw channel
- int channel = m_aircraft->triYawChannelBox->currentIndex()-1;
- if (channel > -1){
- setMixerType(mixerObj, channel, VehicleConfig::MIXERTYPE_SERVO);
- setMixerVectorValue(mixerObj, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
+ int channel = m_aircraft->triYawChannelBox->currentIndex() - 1;
+ if (channel > -1) {
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
}
m_aircraft->mrStatusLabel->setText(tr("Configuration OK"));
@@ -532,21 +566,45 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
return airframeType;
}
-
+void ConfigMultiRotorWidget::reverseMultirotorMotor(){
+ QString frameType = m_aircraft->multirotorFrameType->currentText();
+ drawAirframe(frameType);
+}
/**
Helper function to refresh the UI widget values
*/
void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
{
+ Q_ASSERT(m_aircraft);
+
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ QList curveValues;
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+
+ // is at least one of the curve values != 0?
+ if (isValidThrottleCurve(&curveValues)) {
+ // yes, use the curve we just read from mixersettings
+ m_aircraft->multiThrottleCurve->initCurve(&curveValues);
+ }
+ else {
+ // no, init a straight curve
+ m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
+ }
+
+
+
+
int channel;
double value;
GUIConfigDataUnion config = GetConfigData();
multiGUISettingsStruct multi = config.multi;
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixer);
+// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+// Q_ASSERT(mixer);
if (frameType == "QuadP")
{
@@ -1022,7 +1080,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
// and enable only the relevant channels:
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
- invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1:1;
+ invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1:1;
double yFactor =invertMotors * (double)m_aircraft->mrYawMixLevel->value()/100;
for (int i=0 ; i<8; i++) {
if(mmList.at(i)->isEnabled())
@@ -1070,4 +1128,23 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
return error;
}
+/**
+ WHAT DOES THIS DO???
+ */
+void ConfigMultiRotorWidget::showEvent(QShowEvent *event)
+{
+ Q_UNUSED(event)
+ // Thit fitInView method should only be called now, once the
+ // widget is shown, otherwise it cannot compute its values and
+ // the result is usually a ahrsbargraph that is way too small.
+ m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+}
+/**
+ Resize the GUI contents when the user changes the window size
+ */
+void ConfigMultiRotorWidget::resizeEvent(QResizeEvent *event)
+{
+ Q_UNUSED(event);
+ m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h
index 64b8dd388..210133a48 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h
@@ -46,7 +46,7 @@ class ConfigMultiRotorWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft = 0, QWidget *parent = 0);
+ ConfigMultiRotorWidget(QWidget *parent = 0);
~ConfigMultiRotorWidget();
friend class ConfigVehicleTypeWidget;
@@ -66,7 +66,7 @@ private:
float invertMotors;
- virtual void ResetActuators(GUIConfigDataUnion* configData);
+ virtual void ResetActuators(GUIConfigDataUnion *configData);
static QStringList getChannelDescriptions();
static const QString CHANNELBOXNAME;
void setYawMixLevel(int);
@@ -79,13 +79,15 @@ private slots:
virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(int numMotors);
+ void reverseMultirotorMotor();
protected:
+ void showEvent(QShowEvent *event);
+ void resizeEvent(QResizeEvent *event);
signals:
void configurationChanged();
};
-
#endif // CONFIGMULTIROTORWIDGET_H
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp
index ad76c1632..caba82a7f 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp
@@ -104,7 +104,22 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) {
guiConfig->setValue(configData.UAVObject[i], i);
}
-void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
+
+void VehicleConfig::setupUI(QString frameType)
+{
+
+}
+
+QString VehicleConfig::updateConfigObjectsFromWidgets()
+{
+ return QString();
+}
+
+void VehicleConfig::refreshWidgetsValues(QString frameType)
+{
+}
+
+void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData)
{
}
@@ -113,27 +128,30 @@ void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
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)
+void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index)
{
Q_ASSERT(box);
- if (index >= 0 && index < box->count())
+ if (index >= 0 && index < box->count()) {
box->setCurrentIndex(index);
+ }
}
/**
Helper function:
enables/disables the named comboboxes within supplied uiowner
*/
-void VehicleConfig::enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable)
+void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
{
for (int i = 1; i <= boxCount; i++) {
QComboBox* box = qFindChild(owner, QString("%0%1").arg(boxName).arg(i));
- if (box)
+ if (box) {
box->setEnabled(enable);
+ }
}
}
-QString VehicleConfig::getMixerType(UAVDataObject* mixer, int channel)
+
+QString VehicleConfig::getMixerType(UAVDataObject *mixer, int channel)
{
Q_ASSERT(mixer);
@@ -246,28 +264,22 @@ void VehicleConfig::setMixerValue(UAVDataObject* mixer, QString elementName, dou
}
}
-
-void VehicleConfig::setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve)
+void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve)
{
QPointer field;
- switch (curveType)
- {
- case MIXER_THROTTLECURVE1:
- {
- field = mixer->getField("ThrottleCurve1");
- break;
- }
- case MIXER_THROTTLECURVE2:
- {
- field = mixer->getField("ThrottleCurve2");
- break;
- }
+ switch (curveType) {
+ case MIXER_THROTTLECURVE1:
+ field = mixer->getField("ThrottleCurve1");
+ break;
+ case MIXER_THROTTLECURVE2:
+ field = mixer->getField("ThrottleCurve2");
+ break;
}
if (field && field->getNumElements() == curve.length()) {
- for (int i=0;isetValue(curve.at(i),i);
+ for (int i = 0; i < curve.length(); i++) {
+ field->setValue(curve.at(i), i);
}
}
}
@@ -279,23 +291,18 @@ void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveEle
QPointer field;
- switch (curveType)
- {
- case MIXER_THROTTLECURVE1:
- {
- field = mixer->getField("ThrottleCurve1");
- break;
- }
- case MIXER_THROTTLECURVE2:
- {
- field = mixer->getField("ThrottleCurve2");
- break;
- }
+ switch (curveType) {
+ case MIXER_THROTTLECURVE1:
+ field = mixer->getField("ThrottleCurve1");
+ break;
+ case MIXER_THROTTLECURVE2:
+ field = mixer->getField("ThrottleCurve2");
+ break;
}
if (field) {
curve->clear();
- for (unsigned int i=0; i < field->getNumElements(); i++) {
+ for (unsigned int i = 0; i < field->getNumElements(); i++) {
curve->append(field->getValue(i).toDouble());
}
}
@@ -306,7 +313,7 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve)
Q_ASSERT(curve);
if (curve) {
- for (int i=0; i < curve->count(); i++) {
+ for (int i = 0; i < curve->count(); i++) {
if (curve->at(i) != 0)
return true;
}
@@ -314,21 +321,21 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve)
return false;
}
-double VehicleConfig::getCurveMin(QList* curve)
+double VehicleConfig::getCurveMin(QList *curve)
{
double min = 0;
- for (int i=0; icount(); i++)
+ for (int i = 0; i < curve->count(); i++) {
min = std::min(min, curve->at(i));
-
+ }
return min;
}
-double VehicleConfig::getCurveMax(QList* curve)
+double VehicleConfig::getCurveMax(QList *curve)
{
double max = 0;
- for (int i=0; icount(); i++)
+ for (int i = 0; i < curve->count(); i++) {
max = std::max(max, curve->at(i));
-
+ }
return max;
}
/**
@@ -336,8 +343,8 @@ double VehicleConfig::getCurveMax(QList* curve)
*/
void VehicleConfig::resetField(UAVObjectField * field)
{
- for (unsigned int i=0;igetNumElements();i++) {
- field->setValue(0,i);
+ for (unsigned int i = 0; i < field->getNumElements(); i++) {
+ field->setValue(0, i);
}
}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
index e8de31427..1be3037e0 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
@@ -140,25 +140,33 @@ public:
MIXERVECTOR_YAW = 4
} MixerVectorElem;
+ // TODO remove 1st capital
static GUIConfigDataUnion GetConfigData();
static void SetConfigData(GUIConfigDataUnion configData);
- static void resetField(UAVObjectField * field);
- static void setComboCurrentIndex(QComboBox* box, int index);
- static void enableComboBoxes(QWidget* owner, QString boxName, int boxCount, 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);
- void resetMotorAndServoMixers(UAVDataObject* mixer);
- QString getMixerType(UAVDataObject* mixer, int channel);
- void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType);
- double getMixerValue(UAVDataObject* mixer, QString elementName);
- void setMixerValue(UAVDataObject* mixer, QString elementName, double value);
- void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve);
- void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve);
- bool isValidThrottleCurve(QList* curve);
- double getCurveMin(QList* curve);
- double getCurveMax(QList* curve);
- virtual void ResetActuators(GUIConfigDataUnion* configData);
+
+ static void resetField(UAVObjectField *field);
+ static void setComboCurrentIndex(QComboBox *box, int index);
+ static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable);
+
+ virtual void setupUI(QString airframeType);
+ virtual QString updateConfigObjectsFromWidgets();
+ virtual void refreshWidgetsValues(QString frameType);
+
+ virtual void ResetActuators(GUIConfigDataUnion *configData);
+
+ double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName);
+ void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value);
+ void resetMixerVector(UAVDataObject *mixer, int channel);
+ void resetMotorAndServoMixers(UAVDataObject *mixer);
+ QString getMixerType(UAVDataObject *mixer, int channel);
+ void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType);
+ double getMixerValue(UAVDataObject *mixer, QString elementName);
+ void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
+ void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve);
+ void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList* curve);
+ bool isValidThrottleCurve(QList *curve);
+ double getCurveMin(QList *curve);
+ double getCurveMax(QList *curve);
QStringList channelNames;
QStringList mixerTypes;
@@ -168,7 +176,7 @@ public:
static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
private:
- static UAVObjectManager* getUAVObjectManager();
+ static UAVObjectManager *getUAVObjectManager();
private slots:
diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro
index d05c66252..af016c2ac 100644
--- a/ground/openpilotgcs/src/plugins/config/config.pro
+++ b/ground/openpilotgcs/src/plugins/config/config.pro
@@ -32,6 +32,7 @@ HEADERS += configplugin.h \
cfg_vehicletypes/configmultirotorwidget.h \
cfg_vehicletypes/configfixedwingwidget.h \
cfg_vehicletypes/configgroundvehiclewidget.h \
+ cfg_vehicletypes/configcustomwidget.h \
configrevowidget.h \
config_global.h \
mixercurve.h \
@@ -65,6 +66,7 @@ SOURCES += configplugin.cpp \
cfg_vehicletypes/configmultirotorwidget.cpp \
cfg_vehicletypes/configfixedwingwidget.cpp \
cfg_vehicletypes/configgroundvehiclewidget.cpp \
+ cfg_vehicletypes/configcustomwidget.cpp \
outputchannelform.cpp \
mixercurve.cpp \
dblspindelegate.cpp \
@@ -77,7 +79,6 @@ FORMS += airframe.ui \
airframe_multirotor.ui \
airframe_custom.ui \
cc_hw_settings.ui \
- ccpm.ui \
stabilization.ui \
input.ui \
output.ui \
diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
index c14045755..b9c98ab89 100644
--- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
@@ -26,70 +26,29 @@
*/
#include "configvehicletypewidget.h"
#include "systemsettings.h"
-#include "mixersettings.h"
#include "actuatorsettings.h"
+#include "cfg_vehicletypes/configccpmwidget.h"
+#include "cfg_vehicletypes/configfixedwingwidget.h"
+#include "cfg_vehicletypes/configgroundvehiclewidget.h"
+#include "cfg_vehicletypes/configmultirotorwidget.h"
+#include "cfg_vehicletypes/configcustomwidget.h"
+
#include
#include
#include
#include
-#include
-#include
-#include
-#include
+//#include
+//#include
+//#include
#include
#include
-#include
+//#include
#include
#include
-/**
- Helper delegate for the custom mixer editor table.
- Taken straight from Qt examples, thanks!
- */
-SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
- : QItemDelegate(parent)
- {
- }
-
-QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &/* option */,
- const QModelIndex &/* index */) const
-{
- QSpinBox *editor = new QSpinBox(parent);
- editor->setMinimum(-127);
- editor->setMaximum(127);
-
- return editor;
-}
-
-void SpinBoxDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
-{
- int value = index.model()->data(index, Qt::EditRole).toInt();
-
- QSpinBox *spinBox = static_cast(editor);
- spinBox->setValue(value);
-}
-
-void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
-{
- QSpinBox *spinBox = static_cast(editor);
- spinBox->interpretText();
- int value = spinBox->value();
-
- model->setData(index, value, Qt::EditRole);
-}
-
-void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
-{
- editor->setGeometry(option.rect);
-}
-
-/**********************************************************************************/
+//#include
ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
@@ -102,7 +61,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
m_aircraft->saveAircraftToRAM->setVisible(false);
}
- addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
+ addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD);
addUAVObject("SystemSettings");
addUAVObject("MixerSettings");
@@ -120,76 +79,90 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
// *****************************************************************************************************************
// create and setup a FixedWing config widget
- QWidget *fixedwingConfigWidget = new QWidget();
- m_fixedwingUi = new Ui_FixedWingConfigWidget();
- m_fixedwingUi->setupUi(fixedwingConfigWidget);
- m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget);
+ qDebug() << "create fixedwing ui";
+ m_fixedwing = new ConfigFixedWingWidget();
+ m_aircraft->airframesWidget->addWidget(m_fixedwing);
- m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi);
- m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() );
- QStringList fixedWingTypes;
- fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
- m_fixedwingUi->fixedWingType->addItems(fixedWingTypes);
- m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
- connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
+// QWidget *fixedwingConfigWidget = new QWidget();
+// m_fixedwingUi = new Ui_FixedWingConfigWidget();
+// m_fixedwingUi->setupUi(fixedwingConfigWidget);
+// m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget);
+
+// m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi);
+// m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() );
+
+// QStringList fixedWingTypes;
+// fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
+// m_fixedwingUi->fixedWingType->addItems(fixedWingTypes);
+// m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
+//
+// connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
// *****************************************************************************************************************
// MULTIROTOR
// *****************************************************************************************************************
// create and setup a MultiRotor config widget
- qDebug() << "create multirotor ui";
- QWidget *multirotorConfigWidget = new QWidget();
- m_multirotorUi = new Ui_MultiRotorConfigWidget();
- m_multirotorUi->setupUi(multirotorConfigWidget);
- m_aircraft->airframesWidget->addWidget(multirotorConfigWidget);
+ m_multirotor = new ConfigMultiRotorWidget();
+ m_aircraft->airframesWidget->addWidget(m_multirotor);
- // Setup the Multirotor picture in the Quad settings interface
- m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- QSvgRenderer *renderer = new QSvgRenderer();
- renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
- quad = new QGraphicsSvgItem();
- quad->setSharedRenderer(renderer);
- quad->setElementId("quad-x");
- QGraphicsScene *scene = new QGraphicsScene(this);
- scene->addItem(quad);
- scene->setSceneRect(quad->boundingRect());
- m_multirotorUi->quadShape->setScene(scene);
- m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi);
- m_multirotor->quad = quad;
- m_multirotor->uiowner = this;
- m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText());
- QStringList multiRotorTypes;
- multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" <<
- "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
- "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
- m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes);
- m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X"
+// qDebug() << "create multirotor ui";
+// QWidget *multirotorConfigWidget = new QWidget();
+// m_multirotorUi = new Ui_MultiRotorConfigWidget();
+// m_multirotorUi->setupUi(multirotorConfigWidget);
+// m_aircraft->airframesWidget->addWidget(multirotorConfigWidget);
- connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
-
- // Connect the multirotor motor reverse checkbox
- connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
-
- m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+// // Setup the Multirotor picture in the Quad settings interface
+// m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+// m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+// QSvgRenderer *renderer = new QSvgRenderer();
+// renderer->load(QString(":/configgadget/images/multirotor-shapes.svg"));
+// quad = new QGraphicsSvgItem();
+// quad->setSharedRenderer(renderer);
+// quad->setElementId("quad-x");
+// QGraphicsScene *scene = new QGraphicsScene(this);
+// scene->addItem(quad);
+// scene->setSceneRect(quad->boundingRect());
+// m_multirotorUi->quadShape->setScene(scene);
+//
+// m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi);
+// m_multirotor->quad = quad;
+// m_multirotor->uiowner = this;
+// m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText());
+//
+// QStringList multiRotorTypes;
+// multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" <<
+// "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
+// "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
+// m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes);
+// m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X"
+//
+// connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
+//
+// // Connect the multirotor motor reverse checkbox
+// connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
+//
+// m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
// *****************************************************************************************************************
// HELICOPTER
// *****************************************************************************************************************
// create and setup a Helicopter config widget
- QWidget *ccpmConfigWidget = new QWidget();
- m_ccpmUi = new Ui_CcpmConfigWidget();
- m_ccpmUi->setupUi(ccpmConfigWidget);
- m_aircraft->airframesWidget->addWidget(ccpmConfigWidget);
+// QWidget *ccpmConfigWidget = new QWidget();
+// m_ccpmUi = new Ui_CcpmConfigWidget();
+// m_ccpmUi->setupUi(ccpmConfigWidget);
+// m_aircraft->airframesWidget->addWidget(ccpmConfigWidget);
- m_heli = m_ccpmUi->widget_3;
- m_heli->setupUI(QString("HeliCP"));
+ m_heli = new ConfigCcpmWidget();
+ m_aircraft->airframesWidget->addWidget(m_heli);
+
+ //m_heli = m_ccpmUi->widget_3;
+ //m_heli->setupUI(QString("HeliCP"));
//mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
@@ -199,45 +172,49 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
// *****************************************************************************************************************
// create and setup a GroundVehicle config widget
- qDebug() << "create ground ui";
- QWidget *groundConfigWidget = new QWidget();
- m_groundUi = new Ui_GroundConfigWidget();
- m_groundUi->setupUi(groundConfigWidget);
- m_aircraft->airframesWidget->addWidget(groundConfigWidget);
+// QWidget *groundConfigWidget = new QWidget();
+// m_groundUi = new Ui_GroundConfigWidget();
+// m_groundUi->setupUi(groundConfigWidget);
+// m_aircraft->airframesWidget->addWidget(groundConfigWidget);
- m_groundvehicle = new ConfigGroundVehicleWidget(m_groundUi);
- m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText());
+ m_groundvehicle = new ConfigGroundVehicleWidget();
+ //m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText());
+ m_aircraft->airframesWidget->addWidget(m_groundvehicle);
- QStringList groundVehicleTypes;
- groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
- m_groundUi->groundVehicleType->addItems(groundVehicleTypes);
- m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
+// QStringList groundVehicleTypes;
+// groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
+// m_groundUi->groundVehicleType->addItems(groundVehicleTypes);
+// m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
- connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
+// connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
// *****************************************************************************************************************
// CUSTOM
// *****************************************************************************************************************
- QWidget *customConfigWidget = new QWidget();
- m_customUi = new Ui_CustomConfigWidget();
- m_customUi->setupUi(customConfigWidget);
- m_aircraft->airframesWidget->addWidget(customConfigWidget);
+ m_custom = new ConfigCustomWidget();
+ m_aircraft->airframesWidget->addWidget(m_custom);
- // Put combo boxes in line one of the custom mixer table:
- UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- UAVObjectField* field = obj->getField(QString("Mixer1Type"));
- QStringList list = field->getOptions();
- for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
- QComboBox* qb = new QComboBox(m_customUi->customMixerTable);
- qb->addItems(list);
- m_customUi->customMixerTable->setCellWidget(0,i,qb);
- }
- SpinBoxDelegate *sbd = new SpinBoxDelegate();
- for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
- m_customUi->customMixerTable->setItemDelegateForRow(i, sbd);
- }
+// QWidget *customConfigWidget = new QWidget();
+// m_customUi = new Ui_CustomConfigWidget();
+// m_customUi->setupUi(customConfigWidget);
+// m_aircraft->airframesWidget->addWidget(customConfigWidget);
+
+// // Put combo boxes in line one of the custom mixer table:
+// UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+// UAVObjectField* field = obj->getField(QString("Mixer1Type"));
+// QStringList list = field->getOptions();
+// for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
+// QComboBox* qb = new QComboBox(m_customUi->customMixerTable);
+// qb->addItems(list);
+// m_customUi->customMixerTable->setCellWidget(0,i,qb);
+// }
+//
+// SpinBoxDelegate *sbd = new SpinBoxDelegate();
+// for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
+// m_customUi->customMixerTable->setItemDelegateForRow(i, sbd);
+// }
// *****************************************************************************************************************
@@ -249,9 +226,9 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
// Generate lists of mixerTypeNames, mixerVectorNames, channelNames
channelNames << "None";
for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
- mixerTypes << QString("Mixer%1Type").arg(i+1);
- mixerVectors << QString("Mixer%1Vector").arg(i+1);
- channelNames << QString("Channel%1").arg(i+1);
+ mixerTypes << QString("Mixer%1Type").arg(i + 1);
+ mixerVectors << QString("Mixer%1Vector").arg(i + 1);
+ channelNames << QString("Channel%1").arg(i + 1);
}
// NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
@@ -298,73 +275,52 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
*/
QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
{
- int i;
- QStringList channelDesc;
-
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
- UAVObjectManager * objMngr = pm->getObject();
+ UAVObjectManager *objMngr = pm->getObject();
Q_ASSERT(objMngr);
// get an instance of systemsettings
- SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr);
+ SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
Q_ASSERT(systemSettings);
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
- switch (systemSettingsData.AirframeType)
- {
+ QStringList channelDesc;
+ switch (systemSettingsData.AirframeType) {
+ case SystemSettings::AIRFRAMETYPE_FIXEDWING:
+ case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
+ case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
// fixed wing
- case SystemSettings::AIRFRAMETYPE_FIXEDWING:
- case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
- case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
- {
- channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
- }
+ channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
break;
-
+ case SystemSettings::AIRFRAMETYPE_HELICP:
// helicp
- case SystemSettings::AIRFRAMETYPE_HELICP:
- {
- channelDesc = ConfigCcpmWidget::getChannelDescriptions();
- }
+ channelDesc = ConfigCcpmWidget::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:
- {
- channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
- }
+ 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:
+ // multirotor
+ channelDesc = ConfigMultiRotorWidget::getChannelDescriptions();
break;
-
+ case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
+ case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
+ case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
// ground
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
- {
- channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
- }
+ channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
break;
-
- default:
- {
- for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++)
- channelDesc.append(QString("-"));
- }
+ default:
+ channelDesc = ConfigCustomWidget::getChannelDescriptions();
break;
}
-// for (i=0; i < channelDesc.count(); i++)
-// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]);
-
return channelDesc;
}
@@ -376,83 +332,83 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
*/
void ConfigVehicleTypeWidget::switchAirframeType(int index)
{
+ //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
+ //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+// m_customUi->customMixerTable->resizeColumnsToContents();
+// for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) {
+// m_customUi->customMixerTable->setColumnWidth(i,
+// (m_customUi->customMixerTable->width() - m_customUi->customMixerTable->verticalHeader()->width()) / 10);
+// }
+
m_aircraft->airframesWidget->setCurrentIndex(index);
- m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
- m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- m_customUi->customMixerTable->resizeColumnsToContents();
- for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
- m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
- m_customUi->customMixerTable->verticalHeader()->width())/ 10);
- }
}
/**
WHAT DOES THIS DO???
*/
-void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
-{
- Q_UNUSED(event)
- // Thit fitInView method should only be called now, once the
- // widget is shown, otherwise it cannot compute its values and
- // the result is usually a ahrsbargraph that is way too small.
- m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- m_customUi->customMixerTable->resizeColumnsToContents();
- for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
- m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
- m_customUi->customMixerTable->verticalHeader()->width())/ 10);
- }
-}
+//void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
+//{
+// Q_UNUSED(event)
+// // Thit fitInView method should only be called now, once the
+// // widget is shown, otherwise it cannot compute its values and
+// // the result is usually a ahrsbargraph that is way too small.
+// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+//// m_customUi->customMixerTable->resizeColumnsToContents();
+//// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
+//// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
+//// m_customUi->customMixerTable->verticalHeader()->width())/ 10);
+//// }
+//}
/**
Resize the GUI contents when the user changes the window size
*/
-void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event)
-{
- Q_UNUSED(event);
- m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- // Make the custom table columns autostretch:
- m_customUi->customMixerTable->resizeColumnsToContents();
- for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
- m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
- m_customUi->customMixerTable->verticalHeader()->width())/ 10);
- }
+//void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent *event)
+//{
+// Q_UNUSED(event);
+// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+// // Make the custom table columns autostretch:
+// m_customUi->customMixerTable->resizeColumnsToContents();
+// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
+// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()-
+// m_customUi->customMixerTable->verticalHeader()->width())/ 10);
+// }
+//
+//}
-}
+//void ConfigVehicleTypeWidget::toggleAileron2(int index)
+//{
+// if (index) {
+// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true);
+// m_fixedwingUi->fwAileron2Label->setEnabled(true);
+// } else {
+// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false);
+// m_fixedwingUi->fwAileron2Label->setEnabled(false);
+// }
+//}
+//void ConfigVehicleTypeWidget::toggleElevator2(int index)
+//{
+// if (index) {
+// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true);
+// m_fixedwingUi->fwElevator2Label->setEnabled(true);
+// } else {
+// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false);
+// m_fixedwingUi->fwElevator2Label->setEnabled(false);
+// }
+//}
-void ConfigVehicleTypeWidget::toggleAileron2(int index)
-{
- if (index) {
- m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true);
- m_fixedwingUi->fwAileron2Label->setEnabled(true);
- } else {
- m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false);
- m_fixedwingUi->fwAileron2Label->setEnabled(false);
- }
-}
-
-void ConfigVehicleTypeWidget::toggleElevator2(int index)
-{
- if (index) {
- m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true);
- m_fixedwingUi->fwElevator2Label->setEnabled(true);
- } else {
- m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false);
- m_fixedwingUi->fwElevator2Label->setEnabled(false);
- }
-}
-
-void ConfigVehicleTypeWidget::toggleRudder2(int index)
-{
- if (index) {
- m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true);
- m_fixedwingUi->fwRudder2Label->setEnabled(true);
- } else {
- m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false);
- m_fixedwingUi->fwRudder2Label->setEnabled(false);
- }
-}
+//void ConfigVehicleTypeWidget::toggleRudder2(int index)
+//{
+// if (index) {
+// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true);
+// m_fixedwingUi->fwRudder2Label->setEnabled(true);
+// } else {
+// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false);
+// m_fixedwingUi->fwRudder2Label->setEnabled(false);
+// }
+//}
/////////////////////////////////////////////////////////
/// Feed Forward Testing
@@ -522,81 +478,84 @@ void ConfigVehicleTypeWidget::enableFFTest()
/**
Refreshes the current value of the SystemSettings which holds the aircraft type
*/
-void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o)
+void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
{
Q_UNUSED(o);
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin";
- if(!allObjectsUpdated())
+ if (!allObjectsUpdated()) {
return;
+ }
bool dirty = isDirty();
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty;
// Get the Airframe type from the system settings:
- UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
+ UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
Q_ASSERT(system);
UAVObjectField *field = system->getField(QString("AirframeType"));
Q_ASSERT(field);
+
// At this stage, we will need to have some hardcoded settings in this code, this
// is not ideal, but there you go.
QString frameType = field->getValue().toString();
qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType;
setupAirframeUI(frameType);
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixer);
-
- QPointer vconfig = new VehicleConfig();
-
- QList curveValues;
- vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+// Q_ASSERT(mixer);
+//
+// QPointer vconfig = new VehicleConfig();
+//
+// QList curveValues;
+// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
// is at least one of the curve values != 0?
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- // yes, use the curve we just read from mixersettings
- m_multirotorUi->multiThrottleCurve->initCurve(&curveValues);
- m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues);
- m_groundUi->groundVehicleThrottle1->initCurve(&curveValues);
- }
- else {
- // no, init a straight curve
- m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
- m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
- m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
- }
+// if (vconfig->isValidThrottleCurve(&curveValues)) {
+// // yes, use the curve we just read from mixersettings
+// //m_multirotorUi->multiThrottleCurve->initCurve(&curveValues);
+// //m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues);
+// //m_groundUi->groundVehicleThrottle1->initCurve(&curveValues);
+// }
+// else {
+// // no, init a straight curve
+// //m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
+// //m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
+// //m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0);
+// }
// Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES
- vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
+// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
+//
+// if (vconfig->isValidThrottleCurve(&curveValues)) {
+// m_groundUi->groundVehicleThrottle2->initCurve(&curveValues);
+// }
+// else {
+// m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
+// }
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- m_groundUi->groundVehicleThrottle2->initCurve(&curveValues);
- }
- else {
- m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
- }
-
- // Load the Settings for fixed wing frames:
if (frameType.startsWith("FixedWing")) {
// Retrieve fixed wing settings
+ setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
m_fixedwing->refreshWidgetsValues(frameType);
- } else if (frameType == "Tri" ||
- frameType == "QuadX" || frameType == "QuadP" ||
- frameType == "Hexa" || frameType == "HexaCoax" || frameType == "HexaX" ||
- frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) {
-
- // Retrieve multirotor settings
- m_multirotor->refreshWidgetsValues(frameType);
+ } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa"
+ || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV"
+ || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") {
+ // Retrieve multirotor settings
+ setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
+ m_multirotor->refreshWidgetsValues(frameType);
} else if (frameType == "HeliCP") {
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
m_heli->refreshWidgetsValues(frameType);
} else if (frameType.startsWith("GroundVehicle")) {
// Retrieve ground vehicle settings
+ setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground"));
m_groundvehicle->refreshWidgetsValues(frameType);
} else if (frameType == "Custom") {
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
+ m_custom->refreshWidgetsValues(frameType);
}
updateCustomAirframeUI();
@@ -614,36 +573,31 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin";
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType;
bool dirty = isDirty();
+
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
|| frameType == "Elevon" || 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" ||
- frameType == "HexaX" || frameType == "Hexacopter X" ||
- frameType == "HexaCoax" || frameType == "Hexacopter Y6" ||
- frameType == "Octo" || frameType == "Octocopter" ||
- frameType == "OctoV" || frameType == "Octocopter V" ||
- frameType == "OctoCoaxP" || frameType == "Octo Coax +" ||
- frameType == "OctoCoaxX" || frameType == "Octo Coax X" ) {
-
- //Call multi-rotor setup UI
- m_multirotor->setupUI(frameType);
- }
- else if (frameType == "HeliCP") {
+ } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X"
+ || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter"
+ || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax"
+ || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV"
+ || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +"
+ || frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
+
+ 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") {
+ } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
+ || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
+ || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
m_groundvehicle->setupUI(frameType);
+ } else {
+ m_custom->setupUI(frameType);
}
-
+
//SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST???
- m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
- m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+ //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect());
+ //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio);
setDirty(dirty);
qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end";
@@ -655,8 +609,8 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
*/
void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
{
- for (unsigned int i=0;igetNumElements();i++) {
- field->setValue(0,i);
+ for (unsigned int i = 0; i < field->getNumElements(); i++) {
+ field->setValue(0, i);
}
}
@@ -665,6 +619,7 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
Note: does NOT ask for an object refresh itself!
*/
+// TODO rename to FF
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
{
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
@@ -672,61 +627,61 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
QPointer vconfig = new VehicleConfig();
- QList curveValues;
- vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
-
- // is at least one of the curve values != 0?
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- m_customUi->customThrottle1Curve->initCurve(&curveValues);
- }
- else {
- // no, init a straight curve
- m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
- }
-
- if (MixerSettings* mxr = qobject_cast(mixer)) {
- MixerSettings::DataFields mixerSettingsData = mxr->getData();
- if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
- m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
- else {
- m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
- }
- }
-
- // Setup all Throttle2 curves for all types of airframes
- vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
-
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- m_customUi->customThrottle2Curve->initCurve(&curveValues);
- }
- else {
- m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin());
- }
-
- // Update the mixer table:
- for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) {
- UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
- if (field)
- {
- QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
- if (q)
- {
- QString s = field->getValue().toString();
- setComboCurrentIndex(q, q->findText(s));
- }
-
- m_customUi->customMixerTable->item(1,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
- m_customUi->customMixerTable->item(2,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
- m_customUi->customMixerTable->item(3,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
- m_customUi->customMixerTable->item(4,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
- m_customUi->customMixerTable->item(5,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)));
- }
- }
+// QList curveValues;
+// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
+//
+// // is at least one of the curve values != 0?
+// if (vconfig->isValidThrottleCurve(&curveValues)) {
+// m_customUi->customThrottle1Curve->initCurve(&curveValues);
+// }
+// else {
+// // no, init a straight curve
+// m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0);
+// }
+//
+// if (MixerSettings* mxr = qobject_cast(mixer)) {
+// MixerSettings::DataFields mixerSettingsData = mxr->getData();
+// if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE)
+// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
+// else {
+// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
+// }
+// }
+//
+// // Setup all Throttle2 curves for all types of airframes
+// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
+//
+// if (vconfig->isValidThrottleCurve(&curveValues)) {
+// m_customUi->customThrottle2Curve->initCurve(&curveValues);
+// }
+// else {
+// m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin());
+// }
+//
+// // Update the mixer table:
+// for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) {
+// UAVObjectField* field = mixer->getField(mixerTypes.at(channel));
+// if (field)
+// {
+// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
+// if (q)
+// {
+// QString s = field->getValue().toString();
+// setComboCurrentIndex(q, q->findText(s));
+// }
+//
+// m_customUi->customMixerTable->item(1,channel)->setText(
+// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
+// m_customUi->customMixerTable->item(2,channel)->setText(
+// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
+// m_customUi->customMixerTable->item(3,channel)->setText(
+// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
+// m_customUi->customMixerTable->item(4,channel)->setText(
+// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
+// m_customUi->customMixerTable->item(5,channel)->setText(
+// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)));
+// }
+// }
// Update feed forward settings
m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer,"FeedForward") * 100);
@@ -745,7 +700,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
*/
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
{
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
QPointer vconfig = new VehicleConfig();
@@ -756,7 +711,8 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
- QString airframeType = "Custom"; //Sets airframe type default to "Custom"
+ // Sets airframe type default to "Custom"
+ QString airframeType = "Custom";
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
}
@@ -770,57 +726,59 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
}
else {
- vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve());
- vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve());
-
- // Update the table:
- for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) {
- QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
- if(q->currentText()=="Disabled")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
- else if(q->currentText()=="Motor")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
- else if(q->currentText()=="Servo")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
- else if(q->currentText()=="CameraRoll")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL);
- else if(q->currentText()=="CameraPitch")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH);
- else if(q->currentText()=="CameraYaw")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW);
- else if(q->currentText()=="Accessory0")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0);
- else if(q->currentText()=="Accessory1")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1);
- else if(q->currentText()=="Accessory2")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2);
- else if(q->currentText()=="Accessory3")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3);
- else if(q->currentText()=="Accessory4")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4);
- else if(q->currentText()=="Accessory5")
- vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5);
-
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
- m_customUi->customMixerTable->item(1,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
- m_customUi->customMixerTable->item(2,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
- m_customUi->customMixerTable->item(3,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
- m_customUi->customMixerTable->item(4,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
- m_customUi->customMixerTable->item(5,channel)->text().toDouble());
- }
+ airframeType = m_custom->updateConfigObjectsFromWidgets();
+// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve());
+// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve());
+//
+// // Update the table:
+// for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) {
+// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel);
+// if(q->currentText()=="Disabled")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED);
+// else if(q->currentText()=="Motor")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
+// else if(q->currentText()=="Servo")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+// else if(q->currentText()=="CameraRoll")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL);
+// else if(q->currentText()=="CameraPitch")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH);
+// else if(q->currentText()=="CameraYaw")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW);
+// else if(q->currentText()=="Accessory0")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0);
+// else if(q->currentText()=="Accessory1")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1);
+// else if(q->currentText()=="Accessory2")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2);
+// else if(q->currentText()=="Accessory3")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3);
+// else if(q->currentText()=="Accessory4")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4);
+// else if(q->currentText()=="Accessory5")
+// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5);
+//
+// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1,
+// m_customUi->customMixerTable->item(1,channel)->text().toDouble());
+// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
+// m_customUi->customMixerTable->item(2,channel)->text().toDouble());
+// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
+// m_customUi->customMixerTable->item(3,channel)->text().toDouble());
+// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
+// m_customUi->customMixerTable->item(4,channel)->text().toDouble());
+// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
+// m_customUi->customMixerTable->item(5,channel)->text().toDouble());
+// }
}
// set the airframe type
- UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
+ UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
Q_ASSERT(system);
QPointer field = system->getField(QString("AirframeType"));
- if (field)
+ if (field) {
field->setValue(airframeType);
+ }
updateCustomAirframeUI();
}
@@ -830,7 +788,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
*/
void ConfigVehicleTypeWidget::openHelp()
{
-
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/44Cf", QUrl::StrictMode) );
}
@@ -841,16 +798,11 @@ void ConfigVehicleTypeWidget::openHelp()
*/
void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index)
{
- if (index >= 0 && index < box->count())
+ if (index >= 0 && index < box->count()) {
box->setCurrentIndex(index);
+ }
}
-void ConfigVehicleTypeWidget::reverseMultirotorMotor(){
- QString frameType = m_multirotorUi->multirotorFrameType->currentText();
- m_multirotor->drawAirframe(frameType);
-}
-
-
/**
WHAT DOES THIS DO???
*/
diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
index c1ad6b473..2a4bb867e 100644
--- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
+++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
@@ -28,29 +28,14 @@
#define CONFIGVEHICLETYPEWIDGET_H
#include "ui_airframe.h"
-#include "../uavobjectwidgetutils/configtaskwidget.h"
-#include "extensionsystem/pluginmanager.h"
-#include "uavobjectmanager.h"
-#include "uavobject.h"
-#include "uavtalk/telemetrymanager.h"
-
#include "cfg_vehicletypes/vehicleconfig.h"
-#include "cfg_vehicletypes/configccpmwidget.h"
-#include "cfg_vehicletypes/configfixedwingwidget.h"
-#include "cfg_vehicletypes/configgroundvehiclewidget.h"
-#include "cfg_vehicletypes/configmultirotorwidget.h"
+#include "uavobject.h"
+#include "../uavobjectwidgetutils/configtaskwidget.h"
-#include "ui_airframe_ccpm.h"
-#include "ui_airframe_fixedwing.h"
-#include "ui_airframe_ground.h"
-#include "ui_airframe_multirotor.h"
-#include "ui_airframe_custom.h"
-
-#include
-#include
-#include
-
-class Ui_Widget;
+#include
+#include
+#include
+#include
class ConfigVehicleTypeWidget: public ConfigTaskWidget
{
@@ -65,16 +50,11 @@ public:
private:
Ui_AircraftWidget *m_aircraft;
- Ui_CcpmConfigWidget *m_ccpmUi;
- Ui_FixedWingConfigWidget *m_fixedwingUi;
- Ui_MultiRotorConfigWidget *m_multirotorUi;
- Ui_GroundConfigWidget *m_groundUi;
- Ui_CustomConfigWidget *m_customUi;
-
- ConfigCcpmWidget *m_heli;
- ConfigFixedWingWidget *m_fixedwing;
- ConfigMultiRotorWidget *m_multirotor;
- ConfigGroundVehicleWidget *m_groundvehicle;
+ VehicleConfig *m_heli;
+ VehicleConfig *m_fixedwing;
+ VehicleConfig *m_multirotor;
+ VehicleConfig *m_groundvehicle;
+ VehicleConfig *m_custom;
void updateCustomAirframeUI();
void addToDirtyMonitor();
@@ -86,7 +66,6 @@ private:
QStringList mixerTypes;
QStringList mixerVectors;
- QGraphicsSvgItem *quad;
bool ffTuningInProgress;
bool ffTuningPhase;
UAVObject::Metadata accInitialData;
@@ -100,36 +79,14 @@ private slots:
void setupAirframeUI(QString type);
- void toggleAileron2(int index);
- void toggleElevator2(int index);
- void toggleRudder2(int index);
+// void toggleAileron2(int index);
+// void toggleElevator2(int index);
+// void toggleRudder2(int index);
void switchAirframeType(int index);
void enableFFTest();
void openHelp();
- void reverseMultirotorMotor();
-protected:
- void showEvent(QShowEvent *event);
- void resizeEvent(QResizeEvent *event);
-
-
-
-};
-
-class SpinBoxDelegate : public QItemDelegate
-{
- Q_OBJECT
-
-public:
- SpinBoxDelegate(QObject *parent = 0);
-
- QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
- void setEditorData(QWidget *editor, const QModelIndex &index) const;
- void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
-
- void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
};
#endif // CONFIGVEHICLETYPEWIDGET_H