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
@@ -1231,24 +1241,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();
@@ -1260,110 +1270,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;
}
@@ -1379,33 +1389,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);
-
}
/**
@@ -1414,26 +1421,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);
}
@@ -1441,38 +1456,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;
@@ -1481,7 +1500,6 @@ void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value;
}
-
actuatorCommand->setData(actuatorCommandData);
actuatorCommand->updated();
@@ -1497,63 +1515,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 2d52eed8f..a0e4fa094 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h
@@ -27,12 +27,13 @@
#ifndef CONFIGccpmWIDGET_H
#define CONFIGccpmWIDGET_H
-#include "ui_ccpm.h"
-#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "cfg_vehicletypes/vehicleconfig.h"
+#include "ui_airframe_ccpm.h"
+#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
+
#include
#include
#include
@@ -51,83 +52,85 @@ typedef struct {
int Min[CCPM_MAX_SWASH_SERVOS];
} SwashplateServoSettingsStruct;
-
class ConfigCcpmWidget: public VehicleConfig
{
Q_OBJECT
public:
+ static QStringList getChannelDescriptions();
+
ConfigCcpmWidget(QWidget *parent = 0);
~ConfigCcpmWidget();
- friend class ConfigVehicleTypeWidget;
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
-private:
- Ui_ccpmWidget *m_ccpm;
- QGraphicsSvgItem *SwashplateImg;
- QGraphicsSvgItem *CurveImg;
- QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
- QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS];
- QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS];
- QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS];
- QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS];
-
- QString TypeText;
-
- bool SwashLvlConfigurationInProgress;
- UAVObject::Metadata SwashLvlaccInitialData;
- int SwashLvlState;
- int SwashLvlServoInterlock;
-
- SwashplateServoSettingsStruct oldSwashLvlConfiguration;
- SwashplateServoSettingsStruct newSwashLvlConfiguration;
-
- int MixerChannelData[6];
- int ShowDisclaimer(int messageID);
- virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget
-
- bool updatingFromHardware;
- bool updatingToHardware;
-
- virtual void ResetActuators(GUIConfigDataUnion* configData);
- static QStringList getChannelDescriptions();
-
- QString updateConfigObjects();
- private slots:
- virtual void setupUI(QString airframeType);
- virtual void refreshWidgetsValues(QString frameType);
- virtual QString updateConfigObjectsFromWidgets();
- virtual bool throwConfigError(QString airframeType);
-
- void ccpmSwashplateUpdate();
- void ccpmSwashplateRedraw();
- void UpdateMixer();
- void UpdateType();
-
- void SwashLvlStartButtonPressed();
- void SwashLvlNextButtonPressed();
- void SwashLvlCancelButtonPressed();
- void SwashLvlFinishButtonPressed();
-
- //void UpdateCCPMOptionsFromUI();
- //void UpdateCCPMUIFromOptions();
-
- void SetUIComponentVisibilities();
-
- void enableSwashplateLevellingControl(bool state);
- void setSwashplateLevel(int percent);
- void SwashLvlSpinBoxChanged(int value);
- virtual void refreshValues() {}; // Not used
-
- public slots:
- void getMixer();
- void setMixer();
- void saveccpmUpdate();
+public slots:
+ void getMixer();
+ void setMixer();
+ void saveccpmUpdate();
protected:
void showEvent(QShowEvent *event);
void resizeEvent(QResizeEvent *event);
+private:
+ Ui_CcpmConfigWidget *m_aircraft;
+
+ QGraphicsSvgItem *SwashplateImg;
+ QGraphicsSvgItem *CurveImg;
+ QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS];
+ QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS];
+ QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS];
+ QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS];
+ QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS];
+
+ QString TypeText;
+
+ bool SwashLvlConfigurationInProgress;
+ UAVObject::Metadata SwashLvlaccInitialData;
+ int SwashLvlState;
+ int SwashLvlServoInterlock;
+
+ SwashplateServoSettingsStruct oldSwashLvlConfiguration;
+ SwashplateServoSettingsStruct newSwashLvlConfiguration;
+
+ int MixerChannelData[6];
+
+ virtual void registerWidgets(ConfigTaskWidget &parent);
+ virtual void resetActuators(GUIConfigDataUnion *configData);
+
+ int ShowDisclaimer(int messageID);
+ virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget
+
+ bool updatingFromHardware;
+ bool updatingToHardware;
+
+ QString updateConfigObjects();
+
+private slots:
+ virtual void setupUI(QString airframeType);
+ virtual bool throwConfigError(QString airframeType);
+
+ void ccpmSwashplateUpdate();
+ void ccpmSwashplateRedraw();
+ void UpdateMixer();
+ void UpdateType();
+
+ void SwashLvlStartButtonPressed();
+ void SwashLvlNextButtonPressed();
+ void SwashLvlCancelButtonPressed();
+ void SwashLvlFinishButtonPressed();
+
+ //void UpdateCCPMOptionsFromUI();
+ //void UpdateCCPMUIFromOptions();
+
+ void SetUIComponentVisibilities();
+
+ void enableSwashplateLevellingControl(bool state);
+ void setSwashplateLevel(int percent);
+ void SwashLvlSpinBoxChanged(int value);
+ virtual void refreshValues() {}; // Not used
};
#endif // CONFIGccpmWIDGET_H
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..684435b0a
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp
@@ -0,0 +1,296 @@
+/**
+ ******************************************************************************
+ *
+ * @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
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+QStringList ConfigCustomWidget::getChannelDescriptions()
+{
+ QStringList channelDesc;
+ for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) {
+ channelDesc.append(QString("-"));
+ }
+ return channelDesc;
+}
+
+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);
+}
+
+void ConfigCustomWidget::registerWidgets(ConfigTaskWidget &parent) {
+ parent.addWidget(m_aircraft->customMixerTable);
+ parent.addWidget(m_aircraft->customThrottle1Curve->getCurveWidget());
+ parent.addWidget(m_aircraft->customThrottle2Curve->getCurveWidget());
+}
+
+void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData)
+{
+}
+
+/**
+ Helper function to refresh the UI widget values
+ */
+void ConfigCustomWidget::refreshWidgetsValues(QString frameType)
+{
+ Q_ASSERT(m_aircraft);
+
+ setupUI(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->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)));
+ }
+ }
+}
+
+/**
+ Helper function to
+ */
+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";
+}
+
+/**
+ 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);
+ // 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);
+ }
+}
+
+/**
+ 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..1bf7bbf75
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h
@@ -0,0 +1,88 @@
+/**
+ ******************************************************************************
+ *
+ * @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:
+ static QStringList getChannelDescriptions();
+
+ ConfigCustomWidget(QWidget *parent = 0);
+ ~ConfigCustomWidget();
+
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
+
+protected:
+ void showEvent(QShowEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+private:
+ Ui_CustomConfigWidget *m_aircraft;
+
+ virtual void registerWidgets(ConfigTaskWidget &parent);
+ virtual void resetActuators(GUIConfigDataUnion *configData);
+
+private slots:
+ virtual void setupUI(QString airframeType);
+ virtual bool throwConfigError(int numMotors);
+
+};
+
+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 ac6d91165..a2b7bf79f 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp
@@ -25,8 +25,10 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configfixedwingwidget.h"
-#include "configvehicletypewidget.h"
#include "mixersettings.h"
+#include "systemsettings.h"
+#include "actuatorsettings.h"
+#include "actuatorcommand.h"
#include
#include
@@ -38,29 +40,65 @@
#include
#include
-#include "mixersettings.h"
-#include "systemsettings.h"
-#include "actuatorsettings.h"
-#include "actuatorcommand.h"
-
-
-/**
- Constructor
- */
-ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
+QStringList ConfigFixedWingWidget::getChannelDescriptions()
{
- m_aircraft = aircraft;
+ // init a channel_numelem list of channel desc defaults
+ QStringList channelDesc;
+ for (int i = 0; i < (int) ConfigFixedWingWidget::CHANNEL_NUMELEM; i++) {
+ channelDesc.append(QString("-"));
+ }
+
+ // get the gui config data
+ GUIConfigDataUnion configData = getConfigData();
+
+ if (configData.fixedwing.FixedWingPitch1 > 0) {
+ channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1");
+ }
+ if (configData.fixedwing.FixedWingPitch2 > 0) {
+ channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2");
+ }
+ if (configData.fixedwing.FixedWingRoll1 > 0) {
+ channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1");
+ }
+ if (configData.fixedwing.FixedWingRoll2 > 0) {
+ channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2");
+ }
+ if (configData.fixedwing.FixedWingYaw1 > 0) {
+ channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1");
+ }
+ if (configData.fixedwing.FixedWingYaw2 > 0) {
+ channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2");
+ }
+ if (configData.fixedwing.FixedWingThrottle > 0) {
+ channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle");
+ }
+ return channelDesc;
+}
+
+ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget())
+{
+ m_aircraft->setupUi(this);
+
+ populateChannelComboBoxes();
+
+ QStringList fixedWingTypes;
+ fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
+ m_aircraft->fixedWingType->addItems(fixedWingTypes);
+
+ // Set default model to "Elevator aileron rudder"
+ m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
+
+ //setupUI(m_aircraft->fixedWingType->currentText());
+
+ connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
}
-/**
- Destructor
- */
ConfigFixedWingWidget::~ConfigFixedWingWidget()
{
- // Do nothing
+ delete m_aircraft;
}
-
/**
Virtual function to setup the UI
*/
@@ -69,8 +107,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);
m_aircraft->fwRudder1Label->setEnabled(true);
@@ -92,7 +128,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonMixBox->setHidden(true);
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
- setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon"));
m_aircraft->fwAileron1Label->setText("Elevon 1");
m_aircraft->fwAileron2Label->setText("Elevon 2");
@@ -111,7 +146,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
m_aircraft->elevonLabel2->setText("Pitch");
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
- setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing"));
setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail"));
m_aircraft->fwRudder1ChannelBox->setEnabled(false);
m_aircraft->fwRudder1Label->setEnabled(false);
@@ -131,7 +165,22 @@ void ConfigFixedWingWidget::setupUI(QString frameType)
}
}
-void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData)
+void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent) {
+ parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget());
+ parent.addWidget(m_aircraft->fixedWingType);
+
+ parent.addWidget(m_aircraft->fwEngineChannelBox);
+ parent.addWidget(m_aircraft->fwAileron1ChannelBox);
+ parent.addWidget(m_aircraft->fwAileron2ChannelBox);
+ parent.addWidget(m_aircraft->fwElevator1ChannelBox);
+ parent.addWidget(m_aircraft->fwElevator2ChannelBox);
+ parent.addWidget(m_aircraft->fwRudder1ChannelBox);
+ parent.addWidget(m_aircraft->fwRudder2ChannelBox);
+ parent.addWidget(m_aircraft->elevonSlider1);
+ parent.addWidget(m_aircraft->elevonSlider2);
+}
+
+void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->fixedwing.FixedWingPitch1 = 0;
configData->fixedwing.FixedWingPitch2 = 0;
@@ -142,36 +191,65 @@ void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData)
configData->fixedwing.FixedWingThrottle = 0;
}
-QStringList ConfigFixedWingWidget::getChannelDescriptions()
+/**
+ Virtual function to refresh the UI widget values
+ */
+void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
{
- int i;
- QStringList channelDesc;
+ Q_ASSERT(m_aircraft);
- // init a channel_numelem list of channel desc defaults
- for (i=0; i < (int)(ConfigFixedWingWidget::CHANNEL_NUMELEM); i++)
- {
- channelDesc.append(QString("-"));
+ setupUI(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->fixedWingThrottle->initCurve(&curveValues);
+ }
+ else {
+ // no, init a straight curve
+ m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
}
- // get the gui config data
- GUIConfigDataUnion configData = GetConfigData();
+ GUIConfigDataUnion config = getConfigData();
+ fixedGUISettingsStruct fixed = config.fixedwing;
- if (configData.fixedwing.FixedWingPitch1 > 0)
- channelDesc[configData.fixedwing.FixedWingPitch1-1] = QString("FixedWingPitch1");
- if (configData.fixedwing.FixedWingPitch2 > 0)
- channelDesc[configData.fixedwing.FixedWingPitch2-1] = QString("FixedWingPitch2");
- if (configData.fixedwing.FixedWingRoll1 > 0)
- channelDesc[configData.fixedwing.FixedWingRoll1-1] = QString("FixedWingRoll1");
- if (configData.fixedwing.FixedWingRoll2 > 0)
- channelDesc[configData.fixedwing.FixedWingRoll2-1] = QString("FixedWingRoll2");
- if (configData.fixedwing.FixedWingYaw1 > 0)
- channelDesc[configData.fixedwing.FixedWingYaw1-1] = QString("FixedWingYaw1");
- if (configData.fixedwing.FixedWingYaw2 > 0)
- channelDesc[configData.fixedwing.FixedWingYaw2-1] = QString("FixedWingYaw2");
- if (configData.fixedwing.FixedWingThrottle > 0)
- channelDesc[configData.fixedwing.FixedWingThrottle-1] = QString("FixedWingThrottle");
+ // Then retrieve how channels are setup
+ setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle);
+ setComboCurrentIndex(m_aircraft->fwAileron1ChannelBox, fixed.FixedWingRoll1);
+ setComboCurrentIndex(m_aircraft->fwAileron2ChannelBox, fixed.FixedWingRoll2);
+ setComboCurrentIndex(m_aircraft->fwElevator1ChannelBox, fixed.FixedWingPitch1);
+ setComboCurrentIndex(m_aircraft->fwElevator2ChannelBox, fixed.FixedWingPitch2);
+ setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
+ setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
- return channelDesc;
+ if (frameType == "FixedWingElevon") {
+ // If the airframe is elevon, restore the slider setting
+ // Find the channel number for Elevon1 (FixedWingRoll1)
+ int 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") {
+ int 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);
+ }
+ }
}
/**
@@ -180,18 +258,18 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions()
QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
{
QString airframeType = "FixedWing";
-
+
// Save the curve (common to all Fixed wing frames)
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
// Remove Feed Forward, it is pointless on a plane:
setMixerValue(mixer, "FeedForward", 0.0);
-
+
// Set the throttle curve
setThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve());
- //All airframe types must start with "FixedWing"
+ // All airframe types must start with "FixedWing"
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) {
airframeType = "FixedWing";
setupFrameFixedWing( airframeType );
@@ -206,50 +284,6 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets()
return airframeType;
}
-
-/**
- Virtual function to refresh the UI widget values
- */
-void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
-{
- Q_ASSERT(m_aircraft);
-
- GUIConfigDataUnion config = GetConfigData();
- fixedGUISettingsStruct fixed = config.fixedwing;
-
- // Then retrieve how channels are setup
- setComboCurrentIndex(m_aircraft->fwEngineChannelBox, fixed.FixedWingThrottle);
- setComboCurrentIndex(m_aircraft->fwAileron1ChannelBox, fixed.FixedWingRoll1);
- setComboCurrentIndex(m_aircraft->fwAileron2ChannelBox, fixed.FixedWingRoll2);
- setComboCurrentIndex(m_aircraft->fwElevator1ChannelBox, fixed.FixedWingPitch1);
- setComboCurrentIndex(m_aircraft->fwElevator2ChannelBox, fixed.FixedWingPitch2);
- setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1);
- setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2);
-
- UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixer);
-
- int channel;
- 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);
- }
- }
-}
-
-
-
/**
Setup Elevator/Aileron/Rudder airframe.
@@ -260,15 +294,14 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType)
bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
{
// Check coherence:
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
- return false;
- }
+ return false;
+ }
// Now setup the channels:
-
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
@@ -277,8 +310,8 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex();
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
- SetConfigData(config);
-
+ setConfigData(config);
+
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
@@ -289,58 +322,56 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType)
// 1. Assign the servo/motor/none for each channel
- //motor
- int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
- setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
+ // motor
+ int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
- //rudder
- channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ // rudder
+ channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
- //ailerons
- channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
+ // ailerons
+ channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127);
- channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127);
}
- //elevators
- channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
+ // elevators
+ channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1;
if (channel > -1) {
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127);
- channel = m_aircraft->fwElevator2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127);
}
m_aircraft->fwStatusLabel->setText("Mixer generated");
-
+
return true;
}
-
-
/**
Setup Elevon
*/
bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
{
// Check coherence:
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
return false;
}
-
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
+
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex();
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
@@ -348,8 +379,8 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex();
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
- SetConfigData(config);
-
+ setConfigData(config);
+
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
@@ -363,34 +394,34 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
double value;
- //motor
- int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
- setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
+ // motor
+ int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
- //rudders
- channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ // rudders
+ channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
- channel = m_aircraft->fwRudder2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
- //ailerons
- channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
+ // ailerons
+ channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1;
if (channel > -1) {
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
- value = (double)(m_aircraft->elevonSlider2->value()*1.27);
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
+ value = (double) (m_aircraft->elevonSlider2->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value);
- value = (double)(m_aircraft->elevonSlider1->value()*1.27);
+ value = (double) (m_aircraft->elevonSlider1->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, value);
- channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
- value = (double)(m_aircraft->elevonSlider2->value()*1.27);
+ channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
+ value = (double) (m_aircraft->elevonSlider2->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value);
- value = (double)(m_aircraft->elevonSlider1->value()*1.27);
+ value = (double) (m_aircraft->elevonSlider1->value() * 1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value);
}
@@ -398,21 +429,19 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType)
return true;
}
-
-
/**
Setup VTail
*/
bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
{
// Check coherence:
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
return false;
}
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex();
config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex();
@@ -420,7 +449,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex();
config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex();
- SetConfigData(config);
+ setConfigData(config);
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
@@ -433,14 +462,12 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
// 1. Assign the servo/motor/none for each channel
- double value;
-
- //motor
+ // motor
int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1;
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR);
setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
- //rudders
+ // rudders
channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1;
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
@@ -449,7 +476,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
- //ailerons
+ // ailerons
channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
if (channel > -1) {
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
@@ -460,11 +487,11 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127);
}
- //vtail
+ // vtail
channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
if (channel > -1) {
setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO);
- value = (double)(m_aircraft->elevonSlider2->value()*1.27);
+ double value = (double)(m_aircraft->elevonSlider2->value()*1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value);
value = (double)(m_aircraft->elevonSlider1->value()*1.27);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, value);
@@ -486,96 +513,88 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType)
*/
bool ConfigFixedWingWidget::throwConfigError(QString airframeType)
{
- //Initialize configuration error flag
- bool error=false;
-
- //Create a red block. All combo boxes are the same size, so any one should do as a model
- int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
- QPixmap pixmap(size,size);
- pixmap.fill(QColor("red"));
-
- if (airframeType == "FixedWing" ) {
- if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
- m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if (m_aircraft->fwElevator1ChannelBox->currentText() == "None"){
- m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None") && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) {
- pixmap.fill(QColor("green"));
- m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
- } else if (airframeType == "FixedWingElevon"){
- if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
- m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if(m_aircraft->fwAileron1ChannelBox->currentText() == "None"){
- m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if (m_aircraft->fwAileron2ChannelBox->currentText() == "None"){
- m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- } else if ( airframeType == "FixedWingVtail"){
- if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
- m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if(m_aircraft->fwElevator1ChannelBox->currentText() == "None"){
- m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if(m_aircraft->fwElevator2ChannelBox->currentText() == "None"){
- m_aircraft->fwElevator2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->fwElevator2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- }
-
- if (error){
- m_aircraft->fwStatusLabel->setText(QString("ERROR: Assign all necessary channels"));
- }
+ // Initialize configuration error flag
+ bool error = false;
+
+ // Create a red block. All combo boxes are the same size, so any one should do as a model
+ int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
+ QPixmap pixmap(size, size);
+ pixmap.fill(QColor("red"));
+
+ if (airframeType == "FixedWing") {
+ if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
+ m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") {
+ m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None")
+ && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) {
+ pixmap.fill(QColor("green"));
+ m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+ } else if (airframeType == "FixedWingElevon") {
+ if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
+ m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->fwAileron1ChannelBox->currentText() == "None") {
+ m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->fwAileron2ChannelBox->currentText() == "None") {
+ m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ } else if (airframeType == "FixedWingVtail") {
+ if (m_aircraft->fwEngineChannelBox->currentText() == "None") {
+ m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") {
+ m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->fwElevator2ChannelBox->currentText() == "None") {
+ m_aircraft->fwElevator2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->fwElevator2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ }
+
+ if (error) {
+ m_aircraft->fwStatusLabel->setText(QString("ERROR: Assign all necessary channels"));
+ }
return error;
}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
index 7897829b3..c738920d9 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h
@@ -27,12 +27,14 @@
#ifndef CONFIGFIXEDWINGWIDGET_H
#define CONFIGFIXEDWINGWIDGET_H
-#include "ui_airframe.h"
+#include "cfg_vehicletypes/vehicleconfig.h"
+#include "ui_airframe_fixedwing.h"
#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include "uavtalk/telemetrymanager.h"
+
#include
#include
#include
@@ -44,31 +46,28 @@ class ConfigFixedWingWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigFixedWingWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
+ static QStringList getChannelDescriptions();
+
+ ConfigFixedWingWidget(QWidget *parent = 0);
~ConfigFixedWingWidget();
- friend class ConfigVehicleTypeWidget;
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
private:
- Ui_AircraftWidget *m_aircraft;
+ Ui_FixedWingConfigWidget *m_aircraft;
+
+ virtual void registerWidgets(ConfigTaskWidget &parent);
+ virtual void resetActuators(GUIConfigDataUnion *configData);
bool setupFrameFixedWing(QString airframeType);
bool setupFrameElevon(QString airframeType);
bool setupFrameVtail(QString airframeType);
- virtual void ResetActuators(GUIConfigDataUnion* configData);
- static QStringList getChannelDescriptions();
-
private slots:
virtual void setupUI(QString airframeType);
- virtual void refreshWidgetsValues(QString frameType);
- 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 a23b758df..771a2afb5 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp
@@ -25,8 +25,10 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configgroundvehiclewidget.h"
-#include "configvehicletypewidget.h"
#include "mixersettings.h"
+#include "systemsettings.h"
+#include "actuatorsettings.h"
+#include "actuatorcommand.h"
#include
#include
@@ -35,29 +37,58 @@
#include
#include
#include
-#include
#include
-#include "mixersettings.h"
-#include "systemsettings.h"
-#include "actuatorsettings.h"
-#include "actuatorcommand.h"
+#include
-
-/**
- Constructor
- */
-ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
+QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
{
- m_aircraft = aircraft;
+ // init a channel_numelem list of channel desc defaults
+ QStringList channelDesc;
+ for (int i = 0; i < (int) ConfigGroundVehicleWidget::CHANNEL_NUMELEM; i++) {
+ channelDesc.append(QString("-"));
+ }
+
+ // get the gui config data
+ GUIConfigDataUnion configData = getConfigData();
+
+ if (configData.ground.GroundVehicleSteering1 > 0) {
+ channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1");
+ }
+ if (configData.ground.GroundVehicleSteering2 > 0) {
+ channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2");
+ }
+ if (configData.ground.GroundVehicleThrottle1 > 0) {
+ channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1");
+ }
+ if (configData.ground.GroundVehicleThrottle2 > 0) {
+ channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2");
+ }
+ return channelDesc;
+}
+
+ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget())
+{
+ m_aircraft->setupUi(this);
+
+ populateChannelComboBoxes();
+
+ QStringList groundVehicleTypes;
+ groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
+ m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
+
+ // Set default model to "Turnable (car)"
+ m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
+
+ //setupUI(m_aircraft->groundVehicleType->currentText());
+
+ connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
}
-/**
- Destructor
- */
ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
{
- // Do nothing
+ delete m_aircraft;
}
/**
@@ -65,96 +96,103 @@ ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget()
*/
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->differentialSteeringMixBox->setHidden(true);
+ //STILL NEEDS WORK
-
- m_aircraft->gvAileron1ChannelBox->setEnabled(false);
- m_aircraft->gvAileron1Label->setEnabled(false);
-
- m_aircraft->gvAileron2ChannelBox->setEnabled(false);
- m_aircraft->gvAileron2Label->setEnabled(false);
-
- 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);
-
- m_aircraft->gvMotor2ChannelBox->setEnabled(true);
- m_aircraft->gvMotor2Label->setEnabled(true);
+ // Setup the UI
- m_aircraft->gvMotor1Label->setText("Left motor");
- m_aircraft->gvMotor2Label->setText("Right motor");
+ m_aircraft->gvEngineChannelBox->setEnabled(false);
+ m_aircraft->gvEngineLabel->setEnabled(false);
- m_aircraft->gvSteering1ChannelBox->setEnabled(false);
- m_aircraft->gvSteering1Label->setEnabled(false);
-
- m_aircraft->gvSteering2ChannelBox->setEnabled(false);
- m_aircraft->gvSteering2Label->setEnabled(false);
+ m_aircraft->gvAileron1ChannelBox->setEnabled(false);
+ m_aircraft->gvAileron1Label->setEnabled(false);
- m_aircraft->gvSteering2Label->setText("Rear steering");
+ m_aircraft->gvAileron2ChannelBox->setEnabled(false);
+ m_aircraft->gvAileron2Label->setEnabled(false);
- m_aircraft->differentialSteeringMixBox->setHidden(false);
+ 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);
- m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve");
- m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
+ m_aircraft->gvMotor2ChannelBox->setEnabled(true);
+ m_aircraft->gvMotor2Label->setEnabled(true);
- }
- else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle
+ m_aircraft->gvMotor1Label->setText("Left motor");
+ m_aircraft->gvMotor2Label->setText("Right motor");
+
+ m_aircraft->gvSteering1ChannelBox->setEnabled(false);
+ m_aircraft->gvSteering1Label->setEnabled(false);
+
+ m_aircraft->gvSteering2ChannelBox->setEnabled(false);
+ m_aircraft->gvSteering2Label->setEnabled(false);
+
+ m_aircraft->gvSteering2Label->setText("Rear steering");
+
+ m_aircraft->differentialSteeringMixBox->setHidden(false);
+
+ m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve");
+ m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
+
+ } 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);
+ m_aircraft->gvMotor1ChannelBox->setEnabled(false);
+ m_aircraft->gvMotor1Label->setEnabled(false);
- m_aircraft->gvMotor2ChannelBox->setEnabled(true);
- m_aircraft->gvMotor2Label->setEnabled(true);
+ m_aircraft->gvMotor2ChannelBox->setEnabled(true);
+ m_aircraft->gvMotor2Label->setEnabled(true);
- m_aircraft->gvMotor1Label->setText("Front motor");
- m_aircraft->gvMotor2Label->setText("Rear motor");
+ m_aircraft->gvMotor1Label->setText("Front motor");
+ m_aircraft->gvMotor2Label->setText("Rear motor");
- m_aircraft->gvSteering1ChannelBox->setEnabled(true);
- m_aircraft->gvSteering1Label->setEnabled(true);
-
- m_aircraft->gvSteering2ChannelBox->setEnabled(true);
- m_aircraft->gvSteering2Label->setEnabled(true);
+ m_aircraft->gvSteering1ChannelBox->setEnabled(true);
+ m_aircraft->gvSteering1Label->setEnabled(true);
- m_aircraft->gvSteering2Label->setText("Balancing");
+ m_aircraft->gvSteering2ChannelBox->setEnabled(true);
+ m_aircraft->gvSteering2Label->setEnabled(true);
- m_aircraft->differentialSteeringMixBox->setHidden(true);
-
- m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
- m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
- }
- else {//Car
+ m_aircraft->gvSteering2Label->setText("Balancing");
+
+ m_aircraft->differentialSteeringMixBox->setHidden(true);
+
+ m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
+ m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
+ } else {
+ // Car
setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)"));
-
- m_aircraft->gvMotor1ChannelBox->setEnabled(true);
- m_aircraft->gvMotor1Label->setEnabled(true);
- m_aircraft->gvMotor2ChannelBox->setEnabled(true);
- m_aircraft->gvMotor2Label->setEnabled(true);
-
- m_aircraft->gvMotor1Label->setText("Front motor");
- m_aircraft->gvMotor2Label->setText("Rear motor");
-
- m_aircraft->gvSteering1ChannelBox->setEnabled(true);
- m_aircraft->gvSteering1Label->setEnabled(true);
-
- m_aircraft->gvSteering2ChannelBox->setEnabled(true);
- m_aircraft->gvSteering2Label->setEnabled(true);
-
- m_aircraft->differentialSteeringMixBox->setHidden(true);
-
- m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
- m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
- }
+ m_aircraft->gvMotor1ChannelBox->setEnabled(true);
+ m_aircraft->gvMotor1Label->setEnabled(true);
+
+ m_aircraft->gvMotor2ChannelBox->setEnabled(true);
+ m_aircraft->gvMotor2Label->setEnabled(true);
+
+ m_aircraft->gvMotor1Label->setText("Front motor");
+ m_aircraft->gvMotor2Label->setText("Rear motor");
+
+ m_aircraft->gvSteering1ChannelBox->setEnabled(true);
+ m_aircraft->gvSteering1Label->setEnabled(true);
+
+ m_aircraft->gvSteering2ChannelBox->setEnabled(true);
+ m_aircraft->gvSteering2Label->setEnabled(true);
+
+ m_aircraft->differentialSteeringMixBox->setHidden(true);
+
+ m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
+ m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
+ }
}
-void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData)
+void ConfigGroundVehicleWidget::registerWidgets(ConfigTaskWidget &parent) {
+ parent.addWidget(m_aircraft->groundVehicleThrottle1->getCurveWidget());
+ parent.addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget());
+ parent.addWidget(m_aircraft->groundVehicleType);
+}
+
+void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->ground.GroundVehicleSteering1 = 0;
configData->ground.GroundVehicleSteering2 = 0;
@@ -162,213 +200,202 @@ void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData)
configData->ground.GroundVehicleThrottle2 = 0;
}
-QStringList ConfigGroundVehicleWidget::getChannelDescriptions()
+/**
+ Virtual function to refresh the UI widget values
+ */
+void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
{
- int i;
- QStringList channelDesc;
+ setupUI(frameType);
- // init a channel_numelem list of channel desc defaults
- for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++)
- {
- channelDesc.append(QString("-"));
+ 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);
}
- // get the gui config data
- GUIConfigDataUnion configData = GetConfigData();
+ // Setup all Throttle2 curves for all types of airframes
+ getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
- 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 (isValidThrottleCurve(&curveValues)) {
+ m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
+ } else {
+ m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
+ }
+ GUIConfigDataUnion config = getConfigData();
- return channelDesc;
+ // THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
+ // Retrieve channel setup values
+ setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1);
+ setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2);
+ setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1);
+ setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2);
+
+ if (frameType == "GroundVehicleDifferential") {
+ //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE
+ // 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(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100);
+ m_aircraft->differentialSteeringSlider2->setValue(
+ getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100);
+ }
+ } else if (frameType == "GroundVehicleMotorcycle") {
+ // CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
+// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+// Q_ASSERT(obj);
+// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
+// if (chMixerNumber >=0) {
+// field = obj->getField(mixerVectors.at(chMixerNumber));
+// int ti = field->getElementNames().indexOf("Yaw");
+// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100);
+//
+// ti = field->getElementNames().indexOf("Pitch");
+// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100);
+// }
+ }
}
-
-
/**
Virtual function to update the UI widget objects
*/
QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets()
{
- QString airframeType = "GroundVehicleCar";
-
- // Save the curve (common to all ground vehicle frames)
+ QString airframeType = "GroundVehicleCar";
+
+ // Save the curve (common to all ground vehicle frames)
UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
-
- // Remove Feed Forward, it is pointless on a ground vehicle:
+
+ // Remove Feed Forward, it is pointless on a ground vehicle:
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;
+ return airframeType;
}
-
-
-/**
- Virtual function to refresh the UI widget values
- */
-void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType)
-{
- UAVDataObject* obj;
-// UAVObjectField *field;
-
- GUIConfigDataUnion config = GetConfigData();
-
- //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
- // Retrieve channel setup values
- setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1);
- setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2);
- setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1);
- setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2);
-
- if (frameType == "GroundVehicleDifferential") {
- //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE
- // 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);
- }
- }
- if (frameType == "GroundVehicleMotorcycle") {
- //CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
-// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
-// Q_ASSERT(obj);
-// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
-// if (chMixerNumber >=0) {
-// field = obj->getField(mixerVectors.at(chMixerNumber));
-// int ti = field->getElementNames().indexOf("Yaw");
-// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100);
-//
-// ti = field->getElementNames().indexOf("Pitch");
-// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100);
-// }
- }
-}
-
-
/**
Setup balancing ground vehicle.
Returns False if impossible to create the mixer.
*/
-bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType){
- // Check coherence:
- //Show any config errors in GUI
+bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType)
+{
+ // Check coherence:
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
- return false;
- }
+ return false;
+ }
- // Now setup the channels:
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
+ // Now setup the channels:
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
- SetConfigData(config);
-
+ setConfigData(config);
+
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
- //motor
- int channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
+ // motor
+ int channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
- //steering
- channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
+ // steering
+ channel = m_aircraft->gvSteering1ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127);
- //balance
- channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1;
+ // balance
+ channel = m_aircraft->gvSteering2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127);
- m_aircraft->gvStatusLabel->setText("Mixer generated");
-
+ m_aircraft->gvStatusLabel->setText("Mixer generated");
+
return true;
}
-
-
/**
Setup differentially steered ground vehicle.
Returns False if impossible to create the mixer.
*/
-bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType){
- // Check coherence:
- //Show any config errors in GUI
+bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType)
+{
+ // Check coherence:
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
- return false;
- }
+ return false;
+ }
// Now setup the channels:
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
-
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
+
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
- SetConfigData((config));
-
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ setConfigData(config);
+
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
- //left motor
- int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
+ // left motor
+ int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
- //right motor
- channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
+ // right motor
+ channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1;
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
- //Output success message
- m_aircraft->gvStatusLabel->setText("Mixer generated");
-
+ // Output success message
+ m_aircraft->gvStatusLabel->setText("Mixer generated");
+
return true;
-
}
-
-
/**
Setup steerable ground vehicle.
@@ -377,45 +404,45 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT
bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
{
// Check coherence:
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(airframeType)) {
- return false;
- }
+ return false;
+ }
// Now setup the channels:
- GUIConfigDataUnion config = GetConfigData();
- ResetActuators(&config);
-
+ GUIConfigDataUnion config = getConfigData();
+ resetActuators(&config);
+
config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex();
config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex();
config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex();
config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex();
- SetConfigData(config);
+ setConfigData(config);
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
- int channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO);
+ int channel = m_aircraft->gvSteering1ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127);
- channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->gvSteering2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127);
- channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
- channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
- setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO);
+ channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1;
+ setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127);
- //Output success message
+ // Output success message
m_aircraft->gvStatusLabel->setText("Mixer generated");
-
+
return true;
}
@@ -424,94 +451,91 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType)
*/
bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType)
{
- //Initialize configuration error flag
- bool error=false;
+ // Initialize configuration error flag
+ bool error = false;
-
- //Create a red block. All combo boxes are the same size, so any one should do as a model
- int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
- QPixmap pixmap(size,size);
- pixmap.fill(QColor("red"));
-
- if (airframeType == "GroundVehicleCar" ) { //Car
- if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
- pixmap.fill(QColor("green"));
- m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
-// m_aircraft->gvMotor1Label->setText("" + m_aircraft->gvMotor1Label->text() + "");
-// m_aircraft->gvMotor2Label->setText("" + m_aircraft->gvMotor2Label->text() + "");
- error=true;
+ // Create a red block. All combo boxes are the same size, so any one should do as a model
+ int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
+ QPixmap pixmap(size, size);
+ pixmap.fill(QColor("red"));
- }
- else{
- m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
-// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags.
-// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText());
-// delete htmlText;
-//
-// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags.
-// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText());
- }
-
- if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
- m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
-// m_aircraft->gvStatusLabel->setText("ERROR: check steering channel assignment");
-// m_aircraft->gvSteering1Label->setText("" + m_aircraft->gvSteering1Label->text() + "");
-// m_aircraft->gvSteering2Label->setText("" + m_aircraft->gvSteering2Label->text() + "");
- error=true;
- }
- else{
- m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
-// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags.
-// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText());
-// delete htmlText;
-//
-// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags.
-// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText());
- }
-
- } else if (airframeType == "GroundVehicleDifferential"){ //Tank
- if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" || m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
- m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- //Always reset
- m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- } else if ( airframeType == "GroundVehicleMotorcycle"){ //Motorcycle
- if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
- m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
- m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else{
- m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- //Always reset
- m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
- }
-
- if (error){
- m_aircraft->gvStatusLabel->setText(QString("ERROR: Assign all necessary channels"));
- }
+ if (airframeType == "GroundVehicleCar") { //Car
+ if (m_aircraft->gvMotor1ChannelBox->currentText() == "None"
+ && m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
+ pixmap.fill(QColor("green"));
+ m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ //m_aircraft->gvMotor1Label->setText("" + m_aircraft->gvMotor1Label->text() + "");
+ //m_aircraft->gvMotor2Label->setText("" + m_aircraft->gvMotor2Label->text() + "");
+ error = true;
+
+ } else {
+ m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ //QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags.
+ //m_aircraft->gvMotor1Label->setText(htmlText->toPlainText());
+ //delete htmlText;
+
+ //htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags.
+ //m_aircraft->gvMotor2Label->setText(htmlText->toPlainText());
+ }
+
+ if (m_aircraft->gvSteering1ChannelBox->currentText() == "None"
+ && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
+ m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ //m_aircraft->gvStatusLabel->setText("ERROR: check steering channel assignment");
+ //m_aircraft->gvSteering1Label->setText("" + m_aircraft->gvSteering1Label->text() + "");
+ //m_aircraft->gvSteering2Label->setText("" + m_aircraft->gvSteering2Label->text() + "");
+ error = true;
+ } else {
+ m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ //QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags.
+ //m_aircraft->gvSteering1Label->setText(htmlText->toPlainText());
+ //delete htmlText;
+
+ //htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags.
+ //m_aircraft->gvSteering2Label->setText(htmlText->toPlainText());
+ }
+ } else if (airframeType == "GroundVehicleDifferential") { //Tank
+ if (m_aircraft->gvMotor1ChannelBox->currentText() == "None"
+ || m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
+ m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ // Always reset
+ m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ } else if (airframeType == "GroundVehicleMotorcycle") { //Motorcycle
+ if (m_aircraft->gvMotor1ChannelBox->currentText() == "None"
+ && m_aircraft->gvMotor2ChannelBox->currentText() == "None") {
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (m_aircraft->gvSteering1ChannelBox->currentText() == "None"
+ && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
+ m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ // Always reset
+ m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
+ }
+
+ if (error) {
+ m_aircraft->gvStatusLabel->setText(QString("ERROR: Assign all necessary channels"));
+ }
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 fb6cc48b2..475f54a19 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h
@@ -27,12 +27,14 @@
#ifndef CONFIGGROUNDVEHICLEWIDGET_H
#define CONFIGGROUNDVEHICLEWIDGET_H
-#include "ui_airframe.h"
+#include "cfg_vehicletypes/vehicleconfig.h"
+#include "ui_airframe_ground.h"
#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include "uavtalk/telemetrymanager.h"
+
#include
#include
#include
@@ -44,31 +46,28 @@ class ConfigGroundVehicleWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
+ static QStringList getChannelDescriptions();
+
+ ConfigGroundVehicleWidget(QWidget *parent = 0);
~ConfigGroundVehicleWidget();
- friend class ConfigVehicleTypeWidget;
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
private:
- Ui_AircraftWidget *m_aircraft;
+ Ui_GroundConfigWidget *m_aircraft;
+
+ virtual void registerWidgets(ConfigTaskWidget &parent);
+ virtual void resetActuators(GUIConfigDataUnion *configData);
bool setupGroundVehicleCar(QString airframeType);
bool setupGroundVehicleDifferential(QString airframeType);
bool setupGroundVehicleMotorcycle(QString airframeType);
- virtual void ResetActuators(GUIConfigDataUnion* configData);
- static QStringList getChannelDescriptions();
-
private slots:
virtual void setupUI(QString airframeType);
- virtual void refreshWidgetsValues(QString frameType);
- virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(QString airframeType);
-
-protected:
-
};
-
#endif // CONFIGGROUNDVEHICLEWIDGET_H
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp
index 7db57f5d1..7fc9d46a5 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp
@@ -25,6 +25,10 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configmultirotorwidget.h"
+#include "mixersettings.h"
+#include "systemsettings.h"
+#include "actuatorsettings.h"
+#include "actuatorcommand.h"
#include
#include
@@ -37,48 +41,106 @@
#include
#include
-#include "mixersettings.h"
-#include "systemsettings.h"
-#include "actuatorsettings.h"
-#include "actuatorcommand.h"
-
-
const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox");
-
-/**
- Constructor
- */
-ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1)
+QStringList ConfigMultiRotorWidget::getChannelDescriptions()
{
- m_aircraft = aircraft;
+ // init a channel_numelem list of channel desc defaults
+ QStringList channelDesc;
+ for (int i = 0; i < (int) ConfigMultiRotorWidget::CHANNEL_NUMELEM; i++) {
+ channelDesc.append(QString("-"));
+ }
+
+ // get the gui config data
+ GUIConfigDataUnion configData = getConfigData();
+ multiGUISettingsStruct multi = configData.multi;
+
+ if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorN - 1] = QString("VTOLMotorN");
+ }
+ if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorNE - 1] = QString("VTOLMotorNE");
+ }
+ if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorNW - 1] = QString("VTOLMotorNW");
+ }
+ if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorS - 1] = QString("VTOLMotorS");
+ }
+ if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorSE - 1] = QString("VTOLMotorSE");
+ }
+ if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorSW - 1] = QString("VTOLMotorSW");
+ }
+ if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorW - 1] = QString("VTOLMotorW");
+ }
+ if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.VTOLMotorE - 1] = QString("VTOLMotorE");
+ }
+ if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) {
+ channelDesc[multi.TRIYaw - 1] = QString("Tri-Yaw");
+ }
+ return channelDesc;
+}
+
+ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) :
+ VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(false)
+{
+ m_aircraft->setupUi(this);
+
+ populateChannelComboBoxes();
+
+ // 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();
+ scene->addItem(quad);
+ scene->setSceneRect(quad->boundingRect());
+ m_aircraft->quadShape->setScene(scene);
+
+ 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(m_aircraft->multirotorFrameType->findText("Quad X"));
+
+ //setupUI(m_aircraft->multirotorFrameType->currentText());
+
+ 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()));
}
-/**
- Destructor
- */
ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
{
- // Do nothing
+ delete m_aircraft;
}
-
void ConfigMultiRotorWidget::setupUI(QString frameType)
{
Q_ASSERT(m_aircraft);
- Q_ASSERT(uiowner);
Q_ASSERT(quad);
- int i;
-
- // set aircraftType to Multirotor, disable triyaw channel
- setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
+ // disable triyaw channel
m_aircraft->triYawChannelBox->setEnabled(false);
// disable all motor channel boxes
- for (i=1; i <=8; i++) {
+ for (int i = 1; i <= 8; i++) {
// do it manually so we can turn off any error decorations
- QComboBox *combobox = qFindChild(uiowner, "multiMotorChannelBox" + QString::number(i));
+ QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i));
if (combobox) {
combobox->setEnabled(false);
combobox->setItemData(0, 0, Qt::DecorationRole);
@@ -86,198 +148,125 @@ 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...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, CHANNELBOXNAME, 3, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
m_aircraft->triYawChannelBox->setEnabled(true);
- }
- else if (frameType == "QuadX" || frameType == "Quad X") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
+ } else if (frameType == "QuadX" || frameType == "Quad X") {
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X"));
- //Enable all necessary motor channel boxes...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, CHANNELBOXNAME, 4, true);
// init mixer levels
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
- }
- else if (frameType == "QuadP" || frameType == "Quad +") {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
+ } else if (frameType == "QuadP" || frameType == "Quad +") {
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +"));
- //Enable all necessary motor channel boxes...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, CHANNELBOXNAME, 4, true);
m_aircraft->mrRollMixLevel->setValue(100);
m_aircraft->mrPitchMixLevel->setValue(100);
setYawMixLevel(50);
- }
- else if (frameType == "Hexa" || frameType == "Hexacopter")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
+ } else if (frameType == "Hexa" || frameType == "Hexacopter") {
+ setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter"));
- //Enable all necessary motor channel boxes...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, CHANNELBOXNAME, 6, true);
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(33);
- }
- else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X"));
+ } else if (frameType == "HexaX" || frameType == "Hexacopter X") {
+ setComboCurrentIndex(m_aircraft->multirotorFrameType,
+ m_aircraft->multirotorFrameType->findText("Hexacopter X"));
- //Enable all necessary motor channel boxes...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, 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"));
- }
- else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
-
- //Enable all necessary motor channel boxes...
- enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true);
+ // Enable all necessary motor channel boxes...
+ enableComboBoxes(this, 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"));
- }
- else if (frameType == "Octo" || frameType == "Octocopter")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter"));
-
- //Enable all necessary motor channel boxes
- enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
+ // Enable all necessary motor channel boxes
+ enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(33);
m_aircraft->mrPitchMixLevel->setValue(33);
setYawMixLevel(25);
- }
- else if (frameType == "OctoV" || frameType == "Octocopter V")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V"));
+ } else if (frameType == "OctoV" || frameType == "Octocopter V") {
+ setComboCurrentIndex(m_aircraft->multirotorFrameType,
+ m_aircraft->multirotorFrameType->findText("Octocopter V"));
- //Enable all necessary motor channel boxes
- enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
+ // Enable all necessary motor channel boxes
+ enableComboBoxes(this, 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 +"));
- }
- else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +"));
-
- //Enable all necessary motor channel boxes
- enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
+ // Enable all necessary motor channel boxes
+ enableComboBoxes(this, 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"));
- }
- else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X")
- {
- setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X"));
-
- //Enable all necessary motor channel boxes
- enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true);
+ // Enable all necessary motor channel boxes
+ enableComboBoxes(this, CHANNELBOXNAME, 8, true);
m_aircraft->mrRollMixLevel->setValue(50);
m_aircraft->mrPitchMixLevel->setValue(50);
setYawMixLevel(50);
}
- //Draw the appropriate airframe
- drawAirframe(frameType);
+ // Draw the appropriate airframe
+ updateAirframe(frameType);
}
-void ConfigMultiRotorWidget::drawAirframe(QString frameType){
-
- invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1:1;
-
- if (frameType == "Tri" || frameType == "Tricopter Y") {
- if(invertMotors > 0)
- quad->setElementId("tri");
- else
- quad->setElementId("tri_reverse");
- }
- else if (frameType == "QuadX" || frameType == "Quad X") {
- if(invertMotors > 0)
- quad->setElementId("quad-x");
- else
- quad->setElementId("quad-x_reverse");
- }
- else if (frameType == "QuadP" || frameType == "Quad +") {
- if(invertMotors > 0)
- quad->setElementId("quad-plus");
- else
- quad->setElementId("quad-plus_reverse");
- }
- else if (frameType == "Hexa" || frameType == "Hexacopter")
- {
- if(invertMotors > 0)
- quad->setElementId("quad-hexa");
- else
- quad->setElementId("quad-hexa_reverse");
- }
- else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
- if(invertMotors > 0)
- quad->setElementId("quad-hexa-H");
- else
- quad->setElementId("quad-hexa-H_reverse");
- }
- else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6")
- {
- if(invertMotors > 0)
- quad->setElementId("hexa-coax");
- else
- quad->setElementId("hexa-coax_reverse");
- }
- else if (frameType == "Octo" || frameType == "Octocopter")
- {
- if(invertMotors > 0)
- quad->setElementId("quad-octo");
- else
- quad->setElementId("quad-octo_reverse");
- }
- else if (frameType == "OctoV" || frameType == "Octocopter V")
- {
- if(invertMotors > 0)
- quad->setElementId("quad-octo-v");
- else
- quad->setElementId("quad-octo-v_reverse");
- }
- else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +")
- {
- if(invertMotors > 0)
- quad->setElementId("octo-coax-P");
- else
- quad->setElementId("octo-coax-P_reverse");
-
- }
- else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X")
- {
- if(invertMotors > 0)
- quad->setElementId("octo-coax-X");
- else
- quad->setElementId("octo-coax-X_reverse");
-
- }
+void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent) {
+ parent.addWidget(m_aircraft->multiThrottleCurve->getCurveWidget());
+ parent.addWidget(m_aircraft->multirotorFrameType);
+ parent.addWidget(m_aircraft->multiMotorChannelBox1);
+ parent.addWidget(m_aircraft->multiMotorChannelBox2);
+ parent.addWidget(m_aircraft->multiMotorChannelBox3);
+ parent.addWidget(m_aircraft->multiMotorChannelBox4);
+ parent.addWidget(m_aircraft->multiMotorChannelBox5);
+ parent.addWidget(m_aircraft->multiMotorChannelBox6);
+ parent.addWidget(m_aircraft->multiMotorChannelBox7);
+ parent.addWidget(m_aircraft->multiMotorChannelBox8);
+ parent.addWidget(m_aircraft->mrPitchMixLevel);
+ parent.addWidget(m_aircraft->mrRollMixLevel);
+ parent.addWidget(m_aircraft->mrYawMixLevel);
+ parent.addWidget(m_aircraft->triYawChannelBox);
}
-void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
+void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData)
{
configData->multi.VTOLMotorN = 0;
configData->multi.VTOLMotorNE = 0;
@@ -290,74 +279,262 @@ void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData)
configData->multi.TRIYaw = 0;
}
-QStringList ConfigMultiRotorWidget::getChannelDescriptions()
+/**
+ Helper function to refresh the UI widget values
+ */
+void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
{
- QStringList channelDesc;
+ Q_ASSERT(m_aircraft);
- // init a channel_numelem list of channel desc defaults
- for (int i=0; i < (int)(ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++)
- {
- channelDesc.append(QString("-"));
+ setupUI(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->multiThrottleCurve->initCurve(&curveValues);
+ } else {
+ // no, init a straight curve
+ m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
}
- // get the gui config data
- GUIConfigDataUnion configData = GetConfigData();
- multiGUISettingsStruct multi = configData.multi;
+ GUIConfigDataUnion config = getConfigData();
+ multiGUISettingsStruct multi = config.multi;
- if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN");
- if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE");
- if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW");
- if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS");
- if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE");
- if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW");
- if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW");
- if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE");
- if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM)
- channelDesc[multi.TRIYaw-1] = QString("Tri-Yaw");
+ if (frameType == "QuadP") {
+ // Motors 1/2/3/4 are: N / E / S / W
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorW);
- return channelDesc;
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the "custom" setting.
+
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ }
+ } else if (frameType == "QuadX") {
+ // Motors 1/2/3/4 are: NW / NE / SE / SW
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSW);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27));
+ }
+ } else if (frameType == "Hexa") {
+ // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorSW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorNW);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ //change channels
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ }
+ } else if (frameType == "HexaX") {
+ // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorNW);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ }
+ } else if (frameType == "HexaCoax") {
+ // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorSE);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / 1.27));
+
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27));
+ }
+ } else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") {
+ // Motors 1 to 8 are N / NE / E / etc
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorSW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox7, multi.VTOLMotorW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox8, multi.VTOLMotorNW);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ if (frameType == "Octo") {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ //change channels
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ } else if (frameType == "OctoV") {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ //change channels
+ channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ } else if (frameType == "OctoCoaxP") {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ //change channels
+ channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1;
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27));
+ }
+ }
+ } else if (frameType == "OctoCoaxX") {
+ // Motors 1 to 8 are N / NE / E / etc
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorN);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorSE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox7, multi.VTOLMotorSW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox8, multi.VTOLMotorW);
+
+ // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
+ // This assumes that all vectors are identical - if not, the user should use the
+ // "custom" setting.
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
+ setYawMixLevel(-qRound(value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27));
+ }
+ } else if (frameType == "Tri") {
+ // Motors 1 to 8 are N / NE / E / etc
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorS);
+ setComboCurrentIndex(m_aircraft->triYawChannelBox, multi.TRIYaw);
+
+ int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
+ if (channel > -1) {
+ double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
+ m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / 1.27));
+
+ value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
+ m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27));
+
+ }
+ }
+
+ updateAirframe(frameType);
}
-void ConfigMultiRotorWidget::setYawMixLevel(int value)
-{
- if(value<0)
- {
- m_aircraft->mrYawMixLevel->setValue((-1)*value);
- m_aircraft->MultirotorRevMixercheckBox->setChecked(true);
- }
- else
- {
- m_aircraft->mrYawMixLevel->setValue(value);
- m_aircraft->MultirotorRevMixercheckBox->setChecked(false);
- }
-
-}
-
-
-
-
/**
Helper function to update the UI widget objects
*/
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() );
+ QString airframeType;
+ QList motorList;
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
airframeType = "QuadP";
setupQuad(true);
@@ -373,135 +550,134 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") {
airframeType = "HexaCoax";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(6)) {
return airframeType;
}
- motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE"
- << "VTOLMotorS" << "VTOLMotorSE";
+ motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorS" << "VTOLMotorSE";
setupMotors(motorList);
// 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") {
airframeType = "Octo";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(8)) {
return airframeType;
}
- motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
- << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
+ motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW"
+ << "VTOLMotorW" << "VTOLMotorNW";
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") {
airframeType = "OctoV";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(8)) {
return airframeType;
}
- motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
- << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
+ motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW"
+ << "VTOLMotorW" << "VTOLMotorNW";
setupMotors(motorList);
// 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 +") {
airframeType = "OctoCoaxP";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(8)) {
return airframeType;
}
- motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
- << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
+ motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW"
+ << "VTOLMotorW" << "VTOLMotorNW";
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") {
airframeType = "OctoCoaxX";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(8)) {
return airframeType;
}
- motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE"
- << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW";
+ motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS"
+ << "VTOLMotorSW" << "VTOLMotorW";
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") {
airframeType = "Tri";
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(3)) {
return airframeType;
@@ -513,31 +689,30 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
setupMotors(motorList);
- GUIConfigDataUnion config = GetConfigData();
+ GUIConfigDataUnion config = getConfigData();
config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex();
- SetConfigData(config);
-
+ setConfigData(config);
// 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"));
@@ -547,278 +722,61 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets()
return airframeType;
}
-
-
-/**
- Helper function to refresh the UI widget values
- */
-void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType)
+void ConfigMultiRotorWidget::setYawMixLevel(int value)
{
- int channel;
- double value;
-
- GUIConfigDataUnion config = GetConfigData();
- multiGUISettingsStruct multi = config.multi;
-
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
- Q_ASSERT(mixer);
-
- if (frameType == "QuadP")
- {
- // Motors 1/2/3/4 are: N / E / S / W
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
-
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27));
-
- }
- }
- else if (frameType == "QuadX")
- {
- // Motors 1/2/3/4 are: NW / NE / SE / SW
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27));
-
- }
-
- }
- else if (frameType == "Hexa")
- {
- // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
-
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- //change channels
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) );
-
- }
-
-
- }
- else if (frameType == "HexaX")
- {
- // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
-
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) );
- }
- }
- else if (frameType == "HexaCoax")
- {
- // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) );
-
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) );
- }
- }
- else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP")
- {
- // Motors 1 to 8 are N / NE / E / etc
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- if (frameType == "Octo") {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- //change channels
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) );
- }
- else if (frameType == "OctoV") {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- //change channels
- channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) );
- }
- else if (frameType == "OctoCoaxP") {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- //change channels
- channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1;
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) );
- }
-
- }
- }
- else if (frameType == "OctoCoaxX")
- {
- // Motors 1 to 8 are N / NE / E / etc
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorN);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW);
-
- // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
- // This assumes that all vectors are identical - if not, the user should use the
- // "custom" setting.
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW);
- setYawMixLevel( -qRound(value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) );
- }
- }
- else if (frameType == "Tri")
- {
- // Motors 1 to 8 are N / NE / E / etc
-
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS);
- setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw);
-
- channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1;
- if (channel > -1)
- {
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH);
- m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) );
-
- value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL);
- m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) );
-
- }
+ if (value < 0) {
+ m_aircraft->mrYawMixLevel->setValue(-value);
+ m_aircraft->MultirotorRevMixerCheckBox->setChecked(true);
+ } else {
+ m_aircraft->mrYawMixLevel->setValue(value);
+ m_aircraft->MultirotorRevMixerCheckBox->setChecked(false);
}
- drawAirframe(frameType);
}
+void ConfigMultiRotorWidget::reverseMultirotorMotor(){
+ QString frameType = m_aircraft->multirotorFrameType->currentText();
+ updateAirframe(frameType);
+}
+void ConfigMultiRotorWidget::updateAirframe(QString frameType)
+{
+ qDebug() << "ConfigMultiRotorWidget::updateAirframe - frame type" << frameType;
+
+ QString elementId;
+ if (frameType == "Tri" || frameType == "Tricopter Y") {
+ elementId = "tri";
+ } else if (frameType == "QuadX" || frameType == "Quad X") {
+ elementId = "quad-x";
+ } else if (frameType == "QuadP" || frameType == "Quad +") {
+ elementId = "quad-plus";
+ } else if (frameType == "Hexa" || frameType == "Hexacopter") {
+ elementId = "quad-hexa";
+ } else if (frameType == "HexaX" || frameType == "Hexacopter X") {
+ elementId = "quad-hexa-H";
+ } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
+ elementId = "hexa-coax";
+ } else if (frameType == "Octo" || frameType == "Octocopter") {
+ elementId = "quad-octo";
+ } else if (frameType == "OctoV" || frameType == "Octocopter V") {
+ elementId = "quad-octo-v";
+ } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
+ elementId = "octo-coax-P";
+ } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
+ elementId = "octo-coax-X";
+ }
+
+ invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked();
+ if (invertMotors) {
+ elementId += "_reverse";
+ }
+
+ if (elementId != "" && elementId != quad->elementId()) {
+ quad->setElementId(elementId);
+ m_aircraft->quadShape->setSceneRect(quad->boundingRect());
+ m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
+ }
+}
/**
Helper function: setupQuadMotor
@@ -832,54 +790,48 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127);
setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0);
- setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll*127);
- setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch*127);
- setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw*127);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll * 127);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch * 127);
+ setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw * 127);
}
-
-
/**
Helper function: setup motors. Takes a list of channel names in input.
*/
void ConfigMultiRotorWidget::setupMotors(QList motorList)
{
QList mmList;
- mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
- << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
- << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
+ mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2
+ << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4
+ << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
+ << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
- GUIConfigDataUnion configData = GetConfigData();
- ResetActuators(&configData);
+ GUIConfigDataUnion configData = getConfigData();
+ resetActuators(&configData);
- int index;
foreach (QString motor, motorList) {
-
- index = mmList.takeFirst()->currentIndex();
-
- if (motor == QString("VTOLMotorN"))
+ int index = mmList.takeFirst()->currentIndex();
+ if (motor == QString("VTOLMotorN")) {
configData.multi.VTOLMotorN = index;
- else if (motor == QString("VTOLMotorNE"))
+ } else if (motor == QString("VTOLMotorNE")) {
configData.multi.VTOLMotorNE = index;
- else if (motor == QString("VTOLMotorE"))
+ } else if (motor == QString("VTOLMotorE")) {
configData.multi.VTOLMotorE = index;
- else if (motor == QString("VTOLMotorSE"))
+ } else if (motor == QString("VTOLMotorSE")) {
configData.multi.VTOLMotorSE = index;
- else if (motor == QString( "VTOLMotorS"))
+ } else if (motor == QString("VTOLMotorS")) {
configData.multi.VTOLMotorS = index;
- else if (motor == QString( "VTOLMotorSW"))
+ } else if (motor == QString("VTOLMotorSW")) {
configData.multi.VTOLMotorSW = index;
- else if (motor == QString( "VTOLMotorW"))
+ } else if (motor == QString("VTOLMotorW")) {
configData.multi.VTOLMotorW = index;
- else if (motor == QString( "VTOLMotorNW"))
+ } else if (motor == QString("VTOLMotorNW")) {
configData.multi.VTOLMotorNW = index;
+ }
}
- SetConfigData(configData);
-
+ setConfigData(configData);
}
-
-
/**
Set up a Quad-X or Quad-P mixer
*/
@@ -887,19 +839,16 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout)
{
// Check coherence:
- //Show any config errors in GUI
+ // Show any config errors in GUI
if (throwConfigError(4)) {
return false;
}
-
QList motorList;
if (pLayout) {
- motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS"
- << "VTOLMotorW";
+ motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS" << "VTOLMotorW";
} else {
- motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE"
- << "VTOLMotorSW";
+ motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE" << "VTOLMotorSW";
}
setupMotors(motorList);
@@ -920,7 +869,7 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout)
{ 0, 0, 0},
{ 0, 0, 0}
};
- //
+
// Motor 1 to 4, P Layout:
// pitch roll yaw
// {1 ,0 ,-0.5 //Front motor (CW)
@@ -947,25 +896,22 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout)
return true;
}
-
-
/**
Set up a Hexa-X or Hexa-P mixer
*/
bool ConfigMultiRotorWidget::setupHexa(bool pLayout)
{
// Check coherence:
- //Show any config errors in GUI
- if (throwConfigError(6))
+ // Show any config errors in GUI
+ if (throwConfigError(6)) {
return false;
+ }
QList motorList;
if (pLayout) {
- motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE"
- << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW";
+ motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW";
} else {
- motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
- << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
+ motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
}
setupMotors(motorList);
@@ -979,7 +925,6 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout)
// 4 {-0.3 , 0 , 0.3 // S CCW
// 5 {-0.3 , 0.5 ,-0.3 // SW CW
// 6 { 0.3 , 0.5 , 0.3 // NW CCW
-
double pMixer [8][3] = {
{ 1, 0, -1},
{ 1, -1, 1},
@@ -991,7 +936,6 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout)
{ 0, 0, 0}
};
- //
// Motor 1 to 6, X Layout:
// 1 [ 0.5, -0.3, -0.3 ] NE
// 2 [ 0 , -0.3, 0.3 ] E
@@ -1025,64 +969,82 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout)
*/
bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3])
{
- QList mmList;
- mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
- << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
- << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
-
UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
resetMotorAndServoMixers(mixer);
// 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;
- double yFactor =invertMotors * (double)m_aircraft->mrYawMixLevel->value()/100;
- for (int i=0 ; i<8; i++) {
- if(mmList.at(i)->isEnabled())
- {
- int channel = mmList.at(i)->currentIndex()-1;
- if (channel > -1)
- setupQuadMotor(channel, mixerFactors[i][0]*pFactor,
- rFactor*mixerFactors[i][1], yFactor*mixerFactors[i][2]);
+ double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100.0;
+ double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100.0;
+ invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked();
+ double yFactor = (invertMotors ? -1.0 : 1.0) * (double) m_aircraft->mrYawMixLevel->value() / 100.0;
+
+ QList mmList;
+ mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2
+ << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4
+ << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
+ << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
+ for (int i = 0; i < 8; i++) {
+ if (mmList.at(i)->isEnabled()) {
+ int channel = mmList.at(i)->currentIndex() - 1;
+ if (channel > -1) {
+ setupQuadMotor(channel, mixerFactors[i][0] * pFactor, rFactor * mixerFactors[i][1],
+ yFactor * mixerFactors[i][2]);
+ }
}
}
return true;
}
-
/**
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
*/
bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
-{
- //Initialize configuration error flag
- bool error=false;
+{
+ // Initialize configuration error flag
+ bool error = false;
- //Iterate through all instances of multiMotorChannelBox
- for (int i=0; i(uiowner, "multiMotorChannelBox" + QString::number(i+1));
- if (combobox){
+ QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i + 1));
+ if (combobox) {
if (combobox->currentText() == "None") {
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
- QPixmap pixmap(size,size);
+ QPixmap pixmap(size, size);
pixmap.fill(QColor("red"));
- combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
- error=true;
- }
- else {
- combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
+ combobox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes
+ error = true;
+ } else {
+ combobox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes
}
}
}
-
- if (error){
- m_aircraft->mrStatusLabel->setText(QString("ERROR: Assign all %1 motor channels").arg(numMotors));
+ if (error) {
+ m_aircraft->mrStatusLabel->setText(
+ QString("ERROR: Assign all %1 motor channels").arg(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 4ce10aae3..9361c0755 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h
@@ -27,17 +27,17 @@
#ifndef CONFIGMULTIROTORWIDGET_H
#define CONFIGMULTIROTORWIDGET_H
-#include "ui_airframe.h"
-#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "cfg_vehicletypes/vehicleconfig.h"
-
+#include "ui_airframe_multirotor.h"
+#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
#include "uavtalk/telemetrymanager.h"
+
+#include
#include
-#include
-#include
+#include
class Ui_Widget;
@@ -46,16 +46,26 @@ class ConfigMultiRotorWidget: public VehicleConfig
Q_OBJECT
public:
- ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0);
+ static const QString CHANNELBOXNAME;
+ static QStringList getChannelDescriptions();
+
+ ConfigMultiRotorWidget(QWidget *parent = 0);
~ConfigMultiRotorWidget();
- friend class ConfigVehicleTypeWidget;
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
+
+protected:
+ void showEvent(QShowEvent *event);
+ void resizeEvent(QResizeEvent *event);
private:
- Ui_AircraftWidget *m_aircraft;
-
- QWidget *uiowner;
+ Ui_MultiRotorConfigWidget *m_aircraft;
QGraphicsSvgItem *quad;
+ bool invertMotors;
+
+ virtual void registerWidgets(ConfigTaskWidget &parent);
+ virtual void resetActuators(GUIConfigDataUnion *configData);
bool setupQuad(bool pLayout);
bool setupHexa(bool pLayout);
@@ -64,28 +74,15 @@ private:
void setupMotors(QList motorList);
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
- float invertMotors;
-
- virtual void ResetActuators(GUIConfigDataUnion* configData);
- static QStringList getChannelDescriptions();
- static const QString CHANNELBOXNAME;
void setYawMixLevel(int);
- void drawAirframe(QString multiRotorType);
+ void updateAirframe(QString multiRotorType);
private slots:
virtual void setupUI(QString airframeType);
- virtual void refreshWidgetsValues(QString frameType);
- virtual QString updateConfigObjectsFromWidgets();
virtual bool throwConfigError(int numMotors);
-
-protected:
-
-signals:
- void configurationChanged();
-
+ void reverseMultirotorMotor();
};
-
#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 64ab037c8..e70ee0835 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp
@@ -29,29 +29,27 @@
#include "extensionsystem/pluginmanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
-
#include "systemsettings.h"
#include
VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
{
- //Generate lists of mixerTypeNames, mixerVectorNames, channelNames
+ // Generate lists of mixerTypeNames, mixerVectorNames, channelNames
channelNames << "None";
- for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
- mixerTypes << QString("Mixer%1Type").arg(i+1);
- mixerVectors << QString("Mixer%1Vector").arg(i+1);
- channelNames << QString("Channel%1").arg(i+1);
+ for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) {
+ mixerTypes << QString("Mixer%1Type").arg(i + 1);
+ mixerVectors << QString("Mixer%1Vector").arg(i + 1);
+ channelNames << QString("Channel%1").arg(i + 1);
}
- mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch"
- << "CameraYaw" << "Accessory0" << "Accessory1" << "Accessory2"
- << "Accessory3" << "Accessory4" << "Accessory5";
+ mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch" << "CameraYaw"
+ << "Accessory0" << "Accessory1" << "Accessory2" << "Accessory3" << "Accessory4" << "Accessory5";
// This is needed because new style tries to compact things as much as possible in grid
// and on OSX the widget sizes of PushButtons is reported incorrectly:
// https://bugreports.qt-project.org/browse/QTBUG-14591
- foreach( QPushButton * btn, findChildren() ) {
+ foreach(QPushButton *btn, findChildren()) {
btn->setAttribute(Qt::WA_LayoutUsesWidgetRect);
}
}
@@ -61,52 +59,91 @@ VehicleConfig::~VehicleConfig()
// Do nothing
}
-GUIConfigDataUnion VehicleConfig::GetConfigData() {
-
- int i;
- GUIConfigDataUnion configData;
-
+GUIConfigDataUnion VehicleConfig::getConfigData()
+{
// get an instance of systemsettings
- SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
+ SystemSettings *systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
Q_ASSERT(systemSettings);
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
// copy systemsettings -> local configData
- for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
- configData.UAVObject[i]=systemSettingsData.GUIConfigData[i];
+ GUIConfigDataUnion configData;
+ for (int i = 0; i < (int) SystemSettings::GUICONFIGDATA_NUMELEM; i++) {
+ configData.UAVObject[i] = systemSettingsData.GUIConfigData[i];
+ }
// sanity check
- Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
- (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
+ Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
return configData;
}
-void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) {
-
- int i;
-
+void VehicleConfig::setConfigData(GUIConfigDataUnion configData)
+{
// sanity check
- Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM ==
- (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
+ Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0])));
// get an instance of systemsettings
- SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
+ SystemSettings *systemSettings = SystemSettings::GetInstance(getUAVObjectManager());
Q_ASSERT(systemSettings);
SystemSettings::DataFields systemSettingsData = systemSettings->getData();
- UAVObjectField* guiConfig = systemSettings->getField("GUIConfigData");
+ UAVObjectField *guiConfig = systemSettings->getField("GUIConfigData");
Q_ASSERT(guiConfig);
- if(!guiConfig)
+ if (!guiConfig) {
return;
+ }
// copy parameter configData -> systemsettings
- for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++)
+ for (int i = 0; i < (int) SystemSettings::GUICONFIGDATA_NUMELEM; i++) {
guiConfig->setValue(configData.UAVObject[i], i);
+ }
}
-void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData)
+void VehicleConfig::setupUI(QString frameType)
{
+ Q_UNUSED(frameType);
+}
+
+void VehicleConfig::refreshWidgetsValues(QString frameType)
+{
+ Q_UNUSED(frameType);
+}
+
+QString VehicleConfig::updateConfigObjectsFromWidgets()
+{
+ return NULL;
+}
+
+void VehicleConfig::refreshWidgetsValues(UAVObject *o)
+{
+ Q_UNUSED(o);
+}
+
+void VehicleConfig::updateObjectsFromWidgets()
+{
+
+}
+
+void VehicleConfig::resetActuators(GUIConfigDataUnion *configData)
+{
+ Q_UNUSED(configData);
+}
+
+
+void VehicleConfig::registerWidgets(ConfigTaskWidget &parent) {
+ Q_UNUSED(parent);
+}
+
+// NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
+// The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name
+// FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
+void VehicleConfig::populateChannelComboBoxes()
+{
+ QList l = findChildren(QRegExp("\\S+ChannelBo\\S+"));
+ foreach(QComboBox *combobox, l) {
+ combobox->addItems(channelNames);
+ }
}
/**
@@ -114,44 +151,48 @@ 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
+ enables/disables the named comboboxes within supplied owner
*/
-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);
- QString mixerType = mixerTypeDescriptions[0]; //default to disabled
+ // default to disabled
+ QString mixerType = mixerTypeDescriptions[0];
if (channel >= 0 && channel < mixerTypes.count()) {
UAVObjectField *field = mixer->getField(mixerTypes.at(channel));
Q_ASSERT(field);
- if (field)
- mixerType = field->getValue().toString();
+ if (field) {
+ mixerType = field->getValue().toString();
+ }
}
return mixerType;
}
-void VehicleConfig::setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType)
+void VehicleConfig::setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType)
{
Q_ASSERT(mixer);
@@ -160,15 +201,14 @@ void VehicleConfig::setMixerType(UAVDataObject* mixer, int channel, MixerTypeEle
Q_ASSERT(field);
if (field) {
- if (mixerType >= 0 && mixerType < mixerTypeDescriptions.count())
- {
+ if (mixerType >= 0 && mixerType < mixerTypeDescriptions.count()) {
field->setValue(mixerTypeDescriptions[mixerType]);
}
}
}
}
-void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel)
+void VehicleConfig::resetMixerVector(UAVDataObject *mixer, int channel)
{
Q_ASSERT(mixer);
@@ -184,7 +224,7 @@ void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel)
// Disable all servo/motor mixers (but keep camera and accessory ones)
void VehicleConfig::resetMotorAndServoMixers(UAVDataObject *mixer)
{
- for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) {
+ for (int channel = 0; channel < (int) VehicleConfig::CHANNEL_NUMELEM; channel++) {
QString type = getMixerType(mixer, channel);
if ((type == "Disabled") || (type == "Motor") || (type == "Servo")) {
setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED);
@@ -193,12 +233,10 @@ void VehicleConfig::resetMotorAndServoMixers(UAVDataObject *mixer)
}
}
-double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName)
+double VehicleConfig::getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName)
{
Q_ASSERT(mixer);
-
double value = 0;
-
if (channel >= 0 && channel < mixerVectors.count()) {
UAVObjectField *field = mixer->getField(mixerVectors.at(channel));
Q_ASSERT(field);
@@ -210,7 +248,7 @@ double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, Mix
return value;
}
-void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value)
+void VehicleConfig::setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value)
{
Q_ASSERT(mixer);
@@ -224,7 +262,7 @@ void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, Mixer
}
}
-double VehicleConfig::getMixerValue(UAVDataObject* mixer, QString elementName)
+double VehicleConfig::getMixerValue(UAVDataObject *mixer, QString elementName)
{
Q_ASSERT(mixer);
@@ -237,7 +275,7 @@ double VehicleConfig::getMixerValue(UAVDataObject* mixer, QString elementName)
return value;
}
-void VehicleConfig::setMixerValue(UAVDataObject* mixer, QString elementName, double value)
+void VehicleConfig::setMixerValue(UAVDataObject *mixer, QString elementName, double value)
{
Q_ASSERT(mixer);
@@ -247,67 +285,56 @@ 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);
+ if (field && (field->getNumElements() == (unsigned int) curve.length())) {
+ for (int i = 0; i < curve.length(); i++) {
+ field->setValue(curve.at(i), i);
}
}
}
-void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve)
+void VehicleConfig::getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList *curve)
{
Q_ASSERT(mixer);
Q_ASSERT(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) {
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());
}
}
}
-bool VehicleConfig::isValidThrottleCurve(QList* curve)
+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;
}
@@ -315,41 +342,44 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve)
return false;
}
-double VehicleConfig::getCurveMin(QList* curve)
+double VehicleConfig::getCurveMin(QList *curve)
{
+ // TODO initialize to max double
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)
{
+ // TODO initialize to min double
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;
}
+
/**
Reset the contents of a field
*/
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);
}
}
-
/**
* Util function to get a pointer to the object manager
* @return pointer to the UAVObjectManager
*/
-UAVObjectManager* VehicleConfig::getUAVObjectManager() {
+UAVObjectManager *VehicleConfig::getUAVObjectManager()
+{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
- UAVObjectManager * objMngr = pm->getObject();
+ UAVObjectManager *objMngr = pm->getObject();
Q_ASSERT(objMngr);
return objMngr;
}
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
index 3b729a6dd..f116d05b9 100644
--- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
+++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h
@@ -24,8 +24,8 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef GUIVEHICLECONFIG_H
-#define GUIVEHICLECONFIG_H
+#ifndef VEHICLECONFIG_H
+#define VEHICLECONFIG_H
#include "../uavobjectwidgetutils/configtaskwidget.h"
#include "extensionsystem/pluginmanager.h"
@@ -33,7 +33,6 @@
#include "uavobject.h"
#include "actuatorcommand.h"
-
typedef struct {
uint VTOLMotorN:4;
uint VTOLMotorS:4;
@@ -42,11 +41,11 @@ typedef struct {
uint VTOLMotorNW:4;
uint VTOLMotorNE:4;
uint VTOLMotorSW:4;
- uint VTOLMotorSE:4; //32bits
+ uint VTOLMotorSE:4; // 32 bits
uint TRIYaw:4;
- quint32 padding:28; //64bits
+ quint32 padding:28; // 64 bits
quint32 padding1;
- quint32 padding2; //128bits
+ quint32 padding2; // 128 bits
} __attribute__((packed)) multiGUISettingsStruct;
typedef struct {
@@ -58,15 +57,15 @@ typedef struct {
uint ccpmLinkRollState:1;
uint SliderValue0:7;
uint SliderValue1:7;
- uint SliderValue2:7;//41bits
+ uint SliderValue2:7; // 41 bits
uint ServoIndexW:4;
uint ServoIndexX:4;
uint ServoIndexY:4;
- uint ServoIndexZ:4;//57bits
+ uint ServoIndexZ:4; // 57 bits
uint Throttle:4;
- uint Tail:4; //65bits
- quint32 padding:31; //96bits
- quint32 padding1; //128bits
+ uint Tail:4; // 65bits
+ quint32 padding:31; // 96 bits
+ quint32 padding1; // 128 bits
} __attribute__((packed)) heliGUISettingsStruct;
typedef struct {
@@ -77,10 +76,10 @@ typedef struct {
uint FixedWingPitch2:4;
uint FixedWingYaw1:4;
uint FixedWingYaw2:4;
- uint padding:4; //32bits
+ uint padding:4; // 32 bits
quint32 padding1;
quint32 padding2;
- quint32 padding3; //128bits
+ quint32 padding3; // 128 bits
} __attribute__((packed)) fixedGUISettingsStruct;
typedef struct {
@@ -88,78 +87,119 @@ typedef struct {
uint GroundVehicleThrottle2:4;
uint GroundVehicleSteering1:4;
uint GroundVehicleSteering2:4;
- uint padding:16; //32bits
+ uint padding:16; // 32 bits
quint32 padding1;
quint32 padding2;
- quint32 padding3; //128bits
+ quint32 padding3; // 128 bits
} __attribute__((packed)) groundGUISettingsStruct;
typedef union
{
- uint UAVObject[4]; //32bits * 4
- heliGUISettingsStruct heli; //128bits
- fixedGUISettingsStruct fixedwing;
- multiGUISettingsStruct multi;
+ uint UAVObject[4]; // 32 bits * 4
+ heliGUISettingsStruct heli; // 128 bits
+ fixedGUISettingsStruct fixedwing;
+ multiGUISettingsStruct multi;
groundGUISettingsStruct ground;
} GUIConfigDataUnion;
+class ConfigTaskWidget;
+/*
+ * This class handles vehicle specific configuration UI and associated logic.
+ *
+ * This class derives from ConfigTaskWidget and overrides its the default "binding" mechanism.
+ * It does not use the "dirty" state management directlyand registers its relevant widgets with ConfigTaskWidget to do so.
+ */
class VehicleConfig: public ConfigTaskWidget
{
- Q_OBJECT
+Q_OBJECT
- public:
- VehicleConfig(QWidget *parent = 0);
- ~VehicleConfig();
+public:
- /* Enumeration options for ThrottleCurves */
- typedef enum { MIXER_THROTTLECURVE1=0, MIXER_THROTTLECURVE2=1 } MixerThrottleCurveElem;
+ /* Enumeration options for ThrottleCurves */
+ typedef enum {
+ MIXER_THROTTLECURVE1 = 0, MIXER_THROTTLECURVE2 = 1
+ } MixerThrottleCurveElem;
- /* Enumeration options for field MixerType */
- typedef enum { MIXERTYPE_DISABLED=0, MIXERTYPE_MOTOR=1, MIXERTYPE_SERVO=2, MIXERTYPE_CAMERAROLL=3, MIXERTYPE_CAMERAPITCH=4, MIXERTYPE_CAMERAYAW=5, MIXERTYPE_ACCESSORY0=6, MIXERTYPE_ACCESSORY1=7, MIXERTYPE_ACCESSORY2=8, MIXERTYPE_ACCESSORY3=9, MIXERTYPE_ACCESSORY4=10, MIXERTYPE_ACCESSORY5=11 } MixerTypeElem;
- /* Array element names for field MixerVector */
- typedef enum { MIXERVECTOR_THROTTLECURVE1=0, MIXERVECTOR_THROTTLECURVE2=1, MIXERVECTOR_ROLL=2, MIXERVECTOR_PITCH=3, MIXERVECTOR_YAW=4 } MixerVectorElem;
+ /* Enumeration options for field MixerType */
+ typedef enum {
+ MIXERTYPE_DISABLED = 0,
+ MIXERTYPE_MOTOR = 1,
+ MIXERTYPE_SERVO = 2,
+ MIXERTYPE_CAMERAROLL = 3,
+ MIXERTYPE_CAMERAPITCH = 4,
+ MIXERTYPE_CAMERAYAW = 5,
+ MIXERTYPE_ACCESSORY0 = 6,
+ MIXERTYPE_ACCESSORY1 = 7,
+ MIXERTYPE_ACCESSORY2 = 8,
+ MIXERTYPE_ACCESSORY3 = 9,
+ MIXERTYPE_ACCESSORY4 = 10,
+ MIXERTYPE_ACCESSORY5 = 11
+ } MixerTypeElem;
- 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);
+ /* Array element names for field MixerVector */
+ typedef enum {
+ MIXERVECTOR_THROTTLECURVE1 = 0,
+ MIXERVECTOR_THROTTLECURVE2 = 1,
+ MIXERVECTOR_ROLL = 2,
+ MIXERVECTOR_PITCH = 3,
+ MIXERVECTOR_YAW = 4
+ } MixerVectorElem;
- QStringList channelNames;
- QStringList mixerTypes;
- QStringList mixerVectors;
- QStringList mixerTypeDescriptions;
+ static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;;
- static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;
+ static GUIConfigDataUnion getConfigData();
+ static void setConfigData(GUIConfigDataUnion configData);
- private:
+ static void resetField(UAVObjectField *field);
- static UAVObjectManager* getUAVObjectManager();
+ static void setComboCurrentIndex(QComboBox *box, int index);
+ static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable);
- private slots:
+ // VehicleConfig class
+ VehicleConfig(QWidget *parent = 0);
+ ~VehicleConfig();
- public slots:
+ virtual void registerWidgets(ConfigTaskWidget &parent);
- signals:
- //void ConfigurationChanged();
+ virtual void refreshWidgetsValues(QString frameType);
+ virtual QString updateConfigObjectsFromWidgets();
+
+ double getMixerValue(UAVDataObject *mixer, QString elementName);
+ void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
protected:
+ QStringList channelNames;
+ QStringList mixerTypes;
+ QStringList mixerVectors;
+ QStringList mixerTypeDescriptions;
+
+ void populateChannelComboBoxes();
+
+ 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);
+ 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);
+
+protected slots:
+ virtual void refreshWidgetsValues(UAVObject *o = NULL);
+ virtual void updateObjectsFromWidgets();
+
+private:
+ static UAVObjectManager *getUAVObjectManager();
+
+ virtual void resetActuators(GUIConfigDataUnion *configData);
+
+private slots:
+ virtual void setupUI(QString airframeType);
};
-#endif // GUIVEHICLECONFIG_H
+#endif // VEHICLECONFIG_H
diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro
index 1f9d797c4..af016c2ac 100644
--- a/ground/openpilotgcs/src/plugins/config/config.pro
+++ b/ground/openpilotgcs/src/plugins/config/config.pro
@@ -18,7 +18,6 @@ HEADERS += configplugin.h \
config_cc_hw_widget.h \
configccattitudewidget.h \
configpipxtremewidget.h \
- cfg_vehicletypes/configccpmwidget.h \
configstabilizationwidget.h \
assertions.h \
calibration.h \
@@ -28,10 +27,12 @@ HEADERS += configplugin.h \
configcamerastabilizationwidget.h \
configtxpidwidget.h \
outputchannelform.h \
- cfg_vehicletypes/configmultirotorwidget.h \
- cfg_vehicletypes/configgroundvehiclewidget.h \
- cfg_vehicletypes/configfixedwingwidget.h \
cfg_vehicletypes/vehicleconfig.h \
+ cfg_vehicletypes/configccpmwidget.h \
+ cfg_vehicletypes/configmultirotorwidget.h \
+ cfg_vehicletypes/configfixedwingwidget.h \
+ cfg_vehicletypes/configgroundvehiclewidget.h \
+ cfg_vehicletypes/configcustomwidget.h \
configrevowidget.h \
config_global.h \
mixercurve.h \
@@ -60,19 +61,24 @@ SOURCES += configplugin.cpp \
configcamerastabilizationwidget.cpp \
configrevowidget.cpp \
configtxpidwidget.cpp \
- cfg_vehicletypes/configmultirotorwidget.cpp \
- cfg_vehicletypes/configgroundvehiclewidget.cpp \
- cfg_vehicletypes/configfixedwingwidget.cpp \
- cfg_vehicletypes/configccpmwidget.cpp \
- outputchannelform.cpp \
cfg_vehicletypes/vehicleconfig.cpp \
+ cfg_vehicletypes/configccpmwidget.cpp \
+ cfg_vehicletypes/configmultirotorwidget.cpp \
+ cfg_vehicletypes/configfixedwingwidget.cpp \
+ cfg_vehicletypes/configgroundvehiclewidget.cpp \
+ cfg_vehicletypes/configcustomwidget.cpp \
+ outputchannelform.cpp \
mixercurve.cpp \
dblspindelegate.cpp \
configrevohwwidget.cpp
FORMS += airframe.ui \
+ airframe_ccpm.ui \
+ airframe_fixedwing.ui \
+ airframe_ground.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/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc
index a5b006745..adffc9568 100644
--- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc
+++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc
@@ -3,7 +3,6 @@
images/help2.png
images/ahrs-calib.svg
images/paper-plane.svg
- images/curve-bg.svg
images/multirotor-shapes.svg
images/ccpm_setup.svg
images/PipXtreme.png
diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
index dd290073a..f22d84214 100644
--- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
+++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp
@@ -25,77 +25,81 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "configvehicletypewidget.h"
+#include "systemsettings.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 "systemsettings.h"
-#include "mixersettings.h"
-#include "actuatorsettings.h"
#include
#include
-
/**
- Helper delegate for the custom mixer editor table.
- Taken straight from Qt examples, thanks!
+ Static function to get currently assigned channelDescriptions
+ for all known vehicle types; instantiates the appropriate object
+ then asks it to supply channel descs
*/
-SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
- : QItemDelegate(parent)
- {
- }
-
-QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &/* option */,
- const QModelIndex &/* index */) const
+QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
{
- QSpinBox *editor = new QSpinBox(parent);
- editor->setMinimum(-127);
- editor->setMaximum(127);
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ UAVObjectManager *objMngr = pm->getObject();
+ Q_ASSERT(objMngr);
- return editor;
+ // get an instance of systemsettings
+ SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr);
+ Q_ASSERT(systemSettings);
+ SystemSettings::DataFields systemSettingsData = systemSettings->getData();
+
+ QStringList channelDesc;
+ switch (systemSettingsData.AirframeType) {
+ case SystemSettings::AIRFRAMETYPE_FIXEDWING:
+ case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
+ case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
+ // fixed wing
+ channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
+ break;
+ case SystemSettings::AIRFRAMETYPE_HELICP:
+ // helicp
+ channelDesc = ConfigCcpmWidget::getChannelDescriptions();
+ break;
+ 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
+ channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
+ break;
+ default:
+ channelDesc = ConfigCustomWidget::getChannelDescriptions();
+ break;
+ }
+
+ return channelDesc;
}
-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);
-}
-
-/**********************************************************************************/
-
-
-/**
- Constructor
- */
ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_aircraft = new Ui_AircraftWidget();
@@ -103,10 +107,11 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance();
Core::Internal::GeneralSettings * settings=pm->getObject();
- if(!settings->useExpertMode())
+ if (!settings->useExpertMode()) {
m_aircraft->saveAircraftToRAM->setVisible(false);
+ }
- addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
+ addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD);
addUAVObject("SystemSettings");
addUAVObject("MixerSettings");
@@ -115,120 +120,40 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
ffTuningInProgress = false;
ffTuningPhase = false;
- //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);
- }
-
QStringList airframeTypes;
airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom";
m_aircraft->aircraftType->addItems(airframeTypes);
- m_aircraft->aircraftType->setCurrentIndex(1); //Set default vehicle to MultiRotor
- m_aircraft->airframesWidget->setCurrentIndex(1); // Force the tab index to match
- QStringList fixedWingTypes;
- fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
- m_aircraft->fixedWingType->addItems(fixedWingTypes);
- m_aircraft->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
+ // Set default vehicle to MultiRotor
+ //m_aircraft->aircraftType->setCurrentIndex(3);
- QStringList groundVehicleTypes;
- groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
- m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
- m_aircraft->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
-
- 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);
- m_aircraft->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X"
-
-
- //NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
- // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name
- foreach(QComboBox *combobox, this->findChildren(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
- {
- combobox->addItems(channelNames);
- }
-
- // 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);
-
- // 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_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);
- }
-
- // create and setup a MultiRotor config widget
- m_multirotor = new ConfigMultiRotorWidget(m_aircraft);
- m_multirotor->quad = quad;
- m_multirotor->uiowner = this;
- m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText());
-
- // create and setup a GroundVehicle config widget
- m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft);
- m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() );
-
- // create and setup a FixedWing config widget
- m_fixedwing = new ConfigFixedWingWidget(m_aircraft);
- m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() );
-
- // create and setup a Helicopter config widget
- m_heli = m_aircraft->widget_3;
- m_heli->setupUI(QString("HeliCP"));
-
- //Connect aircraft type selection dropbox to callback function
+ // Connect aircraft type selection dropbox to callback function
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
- //Connect airframe selection dropbox to callback functions
- connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
- connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
- connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
- //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
-
- //Connect the three feed forward test checkboxes
+ // Connect the three feed forward test checkboxes
connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
- //Connect the multirotor motor reverse checkbox
- connect(m_aircraft->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor()));
-
// Connect the help pushbutton
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
+
enableControls(false);
+
refreshWidgetsValues();
- addToDirtyMonitor();
+
+ // register widgets for dirty state management
+ addWidget(m_aircraft->aircraftType);
+
+ // register FF widgets for dirty state management
+ addWidget(m_aircraft->feedForwardSlider);
+ addWidget(m_aircraft->accelTime);
+ addWidget(m_aircraft->decelTime);
+ addWidget(m_aircraft->maxAccelSlider);
disableMouseWheelEvents();
- m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
}
-
/**
Destructor
*/
@@ -237,174 +162,159 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
// Do nothing
}
-/**
- Static function to get currently assigned channelDescriptions
- for all known vehicle types; instantiates the appropriate object
- then asks it to supply channel descs
- */
-QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
-{
- int i;
- QStringList channelDesc;
-
- ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
- UAVObjectManager * objMngr = pm->getObject();
- Q_ASSERT(objMngr);
-
- // get an instance of systemsettings
- SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr);
- Q_ASSERT(systemSettings);
- SystemSettings::DataFields systemSettingsData = systemSettings->getData();
-
- switch (systemSettingsData.AirframeType)
- {
- // fixed wing
- case SystemSettings::AIRFRAMETYPE_FIXEDWING:
- case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
- case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
- {
- channelDesc = ConfigFixedWingWidget::getChannelDescriptions();
- }
- break;
-
- // helicp
- case SystemSettings::AIRFRAMETYPE_HELICP:
- {
- 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();
- }
- break;
-
- // ground
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR:
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
- case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
- {
- channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions();
- }
- break;
-
- default:
- {
- for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++)
- channelDesc.append(QString("-"));
- }
- break;
- }
-
-// for (i=0; i < channelDesc.count(); i++)
-// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]);
-
- return channelDesc;
-}
-
-
-/**
- Slot for switching the airframe type. We do it explicitely
- rather than a signal in the UI, because we want to force a fitInView of the quad shapes.
- This is because this method (fitinview) only works when the widget is shown.
- */
void ConfigVehicleTypeWidget::switchAirframeType(int index)
{
- m_aircraft->airframesWidget->setCurrentIndex(index);
- m_aircraft->quadShape->setSceneRect(quad->boundingRect());
- m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- if (m_aircraft->aircraftType->findText("Custom")) {
- 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);
- }
- }
-}
-
-
-/**
- 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_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- 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);
- }
+ // TODO not safe w/r to translation!!!
+ QString frameCategory = m_aircraft->aircraftType->currentText();
+ m_aircraft->airframesWidget->setCurrentWidget(getVehicleConfigWidget(frameCategory));
}
/**
- Resize the GUI contents when the user changes the window size
- */
-void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event)
+ Refreshes the current value of the SystemSettings which holds the aircraft type
+ Note: The default behavior of ConfigTaskWidget is bypassed.
+ Therefore no automatic synchronization of UAV Objects to UI is done.
+ */
+void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o)
{
- Q_UNUSED(event);
- m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
- // Make the custom table columns autostretch:
- 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);
- }
+ Q_UNUSED(o);
+ if (!allObjectsUpdated()) {
+ return;
+ }
+
+ bool dirty = isDirty();
+
+ // Get the Airframe type from the system settings:
+ 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;
+
+ QString category = frameCategory(frameType);
+ setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText(category));
+
+ VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
+ if (vehicleConfig) {
+ vehicleConfig->refreshWidgetsValues(frameType);
+ }
+
+ updateFeedForwardUI();
+
+ setDirty(dirty);
+
+ qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end";
}
+/**
+ Sends the config to the board (airframe type)
-void ConfigVehicleTypeWidget::toggleAileron2(int index)
+ We do all the tasks common to all airframes, or family of airframes, and
+ we call additional methods for specific frames, so that we do not have a code
+ that is too heavy.
+
+ Note: The default behavior of ConfigTaskWidget is bypassed.
+ Therefore no automatic synchronization of UI to UAV Objects is done.
+*/
+void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
{
- if (index) {
- m_aircraft->fwAileron2ChannelBox->setEnabled(true);
- m_aircraft->fwAileron2Label->setEnabled(true);
+ // Airframe type defaults to Custom
+ QString airframeType = "Custom";
+
+ VehicleConfig *vehicleConfig = (VehicleConfig *) m_aircraft->airframesWidget->currentWidget();
+ if (vehicleConfig) {
+ airframeType = vehicleConfig->updateConfigObjectsFromWidgets();
+ }
+
+ // set the airframe type
+ UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
+ Q_ASSERT(system);
+
+ QPointer field = system->getField(QString("AirframeType"));
+ if (field) {
+ field->setValue(airframeType);
+ }
+
+ // Update feed forward settings
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ Q_ASSERT(mixer);
+
+ QPointer vconfig = new VehicleConfig();
+
+ vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0);
+ vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value());
+ vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
+ vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
+
+ // TODO call refreshWidgetsValues() to reflect actual saved values ?
+ updateFeedForwardUI();
+}
+
+QString ConfigVehicleTypeWidget::frameCategory(QString frameType)
+{
+ QString category;
+ if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon"
+ || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") {
+ category = "Fixed Wing";
+ } 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") {
+ category = "Multirotor";
+ } else if (frameType == "HeliCP") {
+ category = "Helicopter";
+ } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)"
+ || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"
+ || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
+ category = "Ground";
} else {
- m_aircraft->fwAileron2ChannelBox->setEnabled(false);
- m_aircraft->fwAileron2Label->setEnabled(false);
+ category = "Custom";
}
+ return category;
}
-void ConfigVehicleTypeWidget::toggleElevator2(int index)
+VehicleConfig *ConfigVehicleTypeWidget::getVehicleConfigWidget(QString frameCategory)
{
- if (index) {
- m_aircraft->fwElevator2ChannelBox->setEnabled(true);
- m_aircraft->fwElevator2Label->setEnabled(true);
- } else {
- m_aircraft->fwElevator2ChannelBox->setEnabled(false);
- m_aircraft->fwElevator2Label->setEnabled(false);
+ VehicleConfig *vehiculeConfig;
+ if (!vehicleIndexMap.contains(frameCategory)) {
+ // create config widget
+ vehiculeConfig = createVehicleConfigWidget(frameCategory);
+ // bind config widget "field" to this ConfigTaskWodget
+ // this is necessary to get "dirty" state management
+ vehiculeConfig->registerWidgets(*this);
+ // add config widget to UI
+ int index = m_aircraft->airframesWidget->insertWidget(m_aircraft->airframesWidget->count(), vehiculeConfig);
+ vehicleIndexMap[frameCategory] = index;
}
+ int index = vehicleIndexMap.value(frameCategory);
+ vehiculeConfig = (VehicleConfig *) m_aircraft->airframesWidget->widget(index);
+ return vehiculeConfig;
}
-void ConfigVehicleTypeWidget::toggleRudder2(int index)
+VehicleConfig *ConfigVehicleTypeWidget::createVehicleConfigWidget(QString frameCategory)
{
- if (index) {
- m_aircraft->fwRudder2ChannelBox->setEnabled(true);
- m_aircraft->fwRudder2Label->setEnabled(true);
- } else {
- m_aircraft->fwRudder2ChannelBox->setEnabled(false);
- m_aircraft->fwRudder2Label->setEnabled(false);
+ qDebug() << "ConfigVehicleTypeWidget::createVehicleConfigWidget - creating" << frameCategory;
+ if (frameCategory == "Fixed Wing") {
+ return new ConfigFixedWingWidget();
+ } else if (frameCategory == "Multirotor") {
+ return new ConfigMultiRotorWidget();
+ } else if (frameCategory == "Helicopter") {
+ return new ConfigCcpmWidget();
+ } else if (frameCategory == "Ground") {
+ return new ConfigGroundVehicleWidget();
+ } else if (frameCategory == "Custom") {
+ return new ConfigCustomWidget();
}
+ return NULL;
}
-/////////////////////////////////////////////////////////
-/// Feed Forward Testing
-/////////////////////////////////////////////////////////
/**
Enables and runs feed forward testing
*/
@@ -414,13 +324,12 @@ void ConfigVehicleTypeWidget::enableFFTest()
// - Check if all three checkboxes are checked
// - Every other timer event: toggle engine from 45% to 55%
// - Every other time event: send FF settings to flight FW
- if (m_aircraft->ffTestBox1->isChecked() &&
- m_aircraft->ffTestBox2->isChecked() &&
- m_aircraft->ffTestBox3->isChecked()) {
- if (!ffTuningInProgress)
- {
+ if (m_aircraft->ffTestBox1->isChecked() && m_aircraft->ffTestBox2->isChecked()
+ && m_aircraft->ffTestBox3->isChecked()) {
+ if (!ffTuningInProgress) {
// Initiate tuning:
- UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand")));
+ UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(
+ QString("ManualControlCommand")));
UAVObject::Metadata mdata = obj->getMetadata();
accInitialData = mdata;
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY);
@@ -440,9 +349,10 @@ void ConfigVehicleTypeWidget::enableFFTest()
vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value());
vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value());
mixer->updated();
- } else {
+ } else {
// Toggle motor state
- UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand")));
+ UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(
+ QString("ManualControlCommand")));
double value = obj->getField("Throttle")->getDouble();
double target = (value < 0.5) ? 0.55 : 0.45;
obj->getField("Throttle")->setValue(target);
@@ -456,7 +366,8 @@ void ConfigVehicleTypeWidget::enableFFTest()
// Disarm!
if (ffTuningInProgress) {
ffTuningInProgress = false;
- UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand")));
+ UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject(
+ QString("ManualControlCommand")));
UAVObject::Metadata mdata = obj->getMetadata();
mdata = accInitialData; // Restore metadata
obj->setMetadata(mdata);
@@ -464,310 +375,23 @@ void ConfigVehicleTypeWidget::enableFFTest()
}
}
-/**************************
- * Aircraft settings
- **************************/
-/**
- Refreshes the current value of the SystemSettings which holds the aircraft type
- */
-void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o)
-{
- Q_UNUSED(o);
-
- if(!allObjectsUpdated())
- return;
-
- bool dirty=isDirty();
-
- // Get the Airframe type from the system settings:
- 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();
- 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);
-
- // is at least one of the curve values != 0?
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- // yes, use the curve we just read from mixersettings
- m_aircraft->multiThrottleCurve->initCurve(&curveValues);
- m_aircraft->fixedWingThrottle->initCurve(&curveValues);
- m_aircraft->groundVehicleThrottle1->initCurve(&curveValues);
- }
- else {
- // no, init a straight curve
- m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9);
- m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0);
- m_aircraft->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);
-
- if (vconfig->isValidThrottleCurve(&curveValues)) {
- m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
- }
- else {
- m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
- }
-
- // Load the Settings for fixed wing frames:
- if (frameType.startsWith("FixedWing")) {
-
- // Retrieve fixed wing settings
- 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 == "HeliCP") {
- setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter"));
- m_heli->refreshWidgetsValues(frameType);
-
- } else if (frameType.startsWith("GroundVehicle")) {
-
- // Retrieve ground vehicle settings
- m_groundvehicle->refreshWidgetsValues(frameType);
-
- } else if (frameType == "Custom") {
- setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom"));
- }
-
- updateCustomAirframeUI();
- setDirty(dirty);
-}
-
-/**
- \brief Sets up the mixer depending on Airframe type. Accepts either system settings or
- combo box entry from airframe type, as those do not overlap.
- */
-void ConfigVehicleTypeWidget::setupAirframeUI(QString 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") {
- m_heli->setupUI(frameType);
- }
- else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" ||
- frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" ||
- frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
- m_groundvehicle->setupUI(frameType);
- }
-
- //SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST???
- m_aircraft->quadShape->setSceneRect(quad->boundingRect());
- m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
-
- setDirty(dirty);
-}
-
-
-/**
- Reset the contents of a field
- */
-void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
-{
- for (unsigned int i=0;igetNumElements();i++) {
- field->setValue(0,i);
- }
-}
-
/**
Updates the custom airframe settings based on the current airframe.
Note: does NOT ask for an object refresh itself!
*/
-void ConfigVehicleTypeWidget::updateCustomAirframeUI()
-{
- 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)) {
- 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
- vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
-
- if (vconfig->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(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1)));
- m_aircraft->customMixerTable->item(2,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2)));
- m_aircraft->customMixerTable->item(3,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)));
- m_aircraft->customMixerTable->item(4,channel)->setText(
- QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)));
- m_aircraft->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);
- m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer,"AccelTime"));
- m_aircraft->decelTime->setValue(vconfig->getMixerValue(mixer,"DecelTime"));
- m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer,"MaxAccel"));
-}
-
-
-/**
- Sends the config to the board (airframe type)
-
- We do all the tasks common to all airframes, or family of airframes, and
- we call additional methods for specific frames, so that we do not have a code
- that is too heavy.
-*/
-void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
+void ConfigVehicleTypeWidget::updateFeedForwardUI()
{
- UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
+ UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings")));
Q_ASSERT(mixer);
QPointer vconfig = new VehicleConfig();
// Update feed forward settings
- vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0);
- vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value());
- 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"
- if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
- airframeType = m_fixedwing->updateConfigObjectsFromWidgets();
- }
- else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
- airframeType = m_multirotor->updateConfigObjectsFromWidgets();
- }
- else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
- airframeType = m_heli->updateConfigObjectsFromWidgets();
- }
- else if (m_aircraft->aircraftType->currentText() == "Ground") {
- airframeType = m_groundvehicle->updateConfigObjectsFromWidgets();
- }
- else {
- vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve());
- vconfig->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")
- 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_aircraft->customMixerTable->item(1,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2,
- m_aircraft->customMixerTable->item(2,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL,
- m_aircraft->customMixerTable->item(3,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH,
- m_aircraft->customMixerTable->item(4,channel)->text().toDouble());
- vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW,
- m_aircraft->customMixerTable->item(5,channel)->text().toDouble());
- }
- }
-
- // set the airframe type
- UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings")));
- Q_ASSERT(system);
-
- QPointer field = system->getField(QString("AirframeType"));
- if (field)
- field->setValue(airframeType);
-
- updateCustomAirframeUI();
+ m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer, "FeedForward") * 100);
+ m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer, "AccelTime"));
+ m_aircraft->decelTime->setValue(vconfig->getMixerValue(mixer, "DecelTime"));
+ m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer, "MaxAccel"));
}
/**
@@ -775,7 +399,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
*/
void ConfigVehicleTypeWidget::openHelp()
{
-
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/44Cf", QUrl::StrictMode) );
}
@@ -786,88 +409,7 @@ 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_aircraft->multirotorFrameType->currentText();
- m_multirotor->drawAirframe(frameType);
-}
-
-
-/**
- WHAT DOES THIS DO???
- */
-void ConfigVehicleTypeWidget::addToDirtyMonitor()
-{
- addWidget(m_aircraft->customMixerTable);
- addWidget(m_aircraft->customThrottle1Curve->getCurveWidget());
- addWidget(m_aircraft->customThrottle2Curve->getCurveWidget());
- addWidget(m_aircraft->multiThrottleCurve->getCurveWidget());
- addWidget(m_aircraft->fixedWingThrottle->getCurveWidget());
- addWidget(m_aircraft->fixedWingType);
- addWidget(m_aircraft->groundVehicleThrottle1->getCurveWidget());
- addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget());
- addWidget(m_aircraft->groundVehicleType);
- addWidget(m_aircraft->feedForwardSlider);
- addWidget(m_aircraft->accelTime);
- addWidget(m_aircraft->decelTime);
- addWidget(m_aircraft->maxAccelSlider);
- addWidget(m_aircraft->multirotorFrameType);
- addWidget(m_aircraft->multiMotorChannelBox1);
- addWidget(m_aircraft->multiMotorChannelBox2);
- addWidget(m_aircraft->multiMotorChannelBox3);
- addWidget(m_aircraft->multiMotorChannelBox4);
- addWidget(m_aircraft->multiMotorChannelBox5);
- addWidget(m_aircraft->multiMotorChannelBox6);
- addWidget(m_aircraft->multiMotorChannelBox7);
- addWidget(m_aircraft->multiMotorChannelBox8);
- addWidget(m_aircraft->mrPitchMixLevel);
- addWidget(m_aircraft->mrRollMixLevel);
- addWidget(m_aircraft->mrYawMixLevel);
- addWidget(m_aircraft->triYawChannelBox);
- addWidget(m_aircraft->aircraftType);
- addWidget(m_aircraft->fwEngineChannelBox);
- addWidget(m_aircraft->fwAileron1ChannelBox);
- addWidget(m_aircraft->fwAileron2ChannelBox);
- addWidget(m_aircraft->fwElevator1ChannelBox);
- addWidget(m_aircraft->fwElevator2ChannelBox);
- addWidget(m_aircraft->fwRudder1ChannelBox);
- addWidget(m_aircraft->fwRudder2ChannelBox);
- addWidget(m_aircraft->elevonSlider1);
- addWidget(m_aircraft->elevonSlider2);
- addWidget(m_heli->m_ccpm->ccpmType);
- addWidget(m_heli->m_ccpm->ccpmTailChannel);
- addWidget(m_heli->m_ccpm->ccpmEngineChannel);
- addWidget(m_heli->m_ccpm->ccpmServoWChannel);
- addWidget(m_heli->m_ccpm->ccpmServoXChannel);
- addWidget(m_heli->m_ccpm->ccpmServoYChannel);
- addWidget(m_heli->m_ccpm->ccpmSingleServo);
- addWidget(m_heli->m_ccpm->ccpmServoZChannel);
- addWidget(m_heli->m_ccpm->ccpmAngleW);
- addWidget(m_heli->m_ccpm->ccpmAngleX);
- addWidget(m_heli->m_ccpm->ccpmCorrectionAngle);
- addWidget(m_heli->m_ccpm->ccpmAngleZ);
- addWidget(m_heli->m_ccpm->ccpmAngleY);
- addWidget(m_heli->m_ccpm->ccpmCollectivePassthrough);
- addWidget(m_heli->m_ccpm->ccpmLinkRoll);
- addWidget(m_heli->m_ccpm->ccpmLinkCyclic);
- addWidget(m_heli->m_ccpm->ccpmRevoSlider);
- addWidget(m_heli->m_ccpm->ccpmREVOspinBox);
- addWidget(m_heli->m_ccpm->ccpmCollectiveSlider);
- addWidget(m_heli->m_ccpm->ccpmCollectivespinBox);
- addWidget(m_heli->m_ccpm->ccpmCollectiveScale);
- addWidget(m_heli->m_ccpm->ccpmCollectiveScaleBox);
- addWidget(m_heli->m_ccpm->ccpmCyclicScale);
- addWidget(m_heli->m_ccpm->ccpmPitchScale);
- addWidget(m_heli->m_ccpm->ccpmPitchScaleBox);
- addWidget(m_heli->m_ccpm->ccpmRollScale);
- addWidget(m_heli->m_ccpm->ccpmRollScaleBox);
- addWidget(m_heli->m_ccpm->SwashLvlPositionSlider);
- addWidget(m_heli->m_ccpm->SwashLvlPositionSpinBox);
- addWidget(m_heli->m_ccpm->ThrottleCurve->getCurveWidget());
- addWidget(m_heli->m_ccpm->PitchCurve->getCurveWidget());
- addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable);
-}
-
diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
index e4cea4cc2..6184fd6fb 100644
--- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
+++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h
@@ -28,98 +28,69 @@
#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/configccpmwidget.h"
-#include "cfg_vehicletypes/configfixedwingwidget.h"
-#include "cfg_vehicletypes/configmultirotorwidget.h"
-#include "cfg_vehicletypes/configgroundvehiclewidget.h"
#include "cfg_vehicletypes/vehicleconfig.h"
+#include "uavobject.h"
+#include "../uavobjectwidgetutils/configtaskwidget.h"
-#include
-#include
-#include
-
-class Ui_Widget;
+#include
+#include
+#include
+#include
+#include
+/*
+ * This class derives from ConfigTaskWidget and overrides its default "binding" mechanism.
+ * This widget bypasses automatic synchronization of UAVObjects and UI by providing its own implementations of
+ * virtual void refreshWidgetsValues(UAVObject *obj = NULL);
+ * virtual void updateObjectsFromWidgets();
+ *
+ * It does use the "dirty" state management and registers its relevant widgets with ConfigTaskWidget to do so.
+ *
+ * This class also manages child ConfigTaskWidget : see VehicleConfig class and its derived classes.
+ * Note: for "dirty" state management it is important to register the fields of child widgets with the parent
+ * ConfigVehicleTypeWidget class.
+ *
+ * TODO consider to call "super" to benefit from default logic...
+ * TODO improve handling of relationship with VehicleConfig derived classes (i.e. ConfigTaskWidget within ConfigTaskWidget)
+ */
class ConfigVehicleTypeWidget: public ConfigTaskWidget
{
Q_OBJECT
public:
+ static QStringList getChannelDescriptions();
+ static void setComboCurrentIndex(QComboBox *box, int index);
+
ConfigVehicleTypeWidget(QWidget *parent = 0);
~ConfigVehicleTypeWidget();
- static QStringList getChannelDescriptions();
+protected slots:
+ virtual void refreshWidgetsValues(UAVObject *o = NULL);
+ virtual void updateObjectsFromWidgets();
private:
Ui_AircraftWidget *m_aircraft;
- ConfigCcpmWidget *m_heli;
- ConfigFixedWingWidget *m_fixedwing;
- ConfigMultiRotorWidget *m_multirotor;
- ConfigGroundVehicleWidget *m_groundvehicle;
+ // Maps a frame category to its index in the m_aircraft->airframesWidget QStackedWidget
+ QMap vehicleIndexMap;
- void updateCustomAirframeUI();
- void addToDirtyMonitor();
- void resetField(UAVObjectField * field);
+ QString frameCategory(QString frameType);
- //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector);
+ VehicleConfig *getVehicleConfigWidget(QString frameCategory);
+ VehicleConfig *createVehicleConfigWidget(QString frameCategory);
- QStringList channelNames;
- QStringList mixerTypes;
- QStringList mixerVectors;
+ // Feed Forward
+ void updateFeedForwardUI();
- QGraphicsSvgItem *quad;
bool ffTuningInProgress;
bool ffTuningPhase;
UAVObject::Metadata accInitialData;
private slots:
-
- virtual void refreshWidgetsValues(UAVObject * o=NULL);
- virtual void updateObjectsFromWidgets();
-
- void setComboCurrentIndex(QComboBox* box, int index);
-
- void setupAirframeUI(QString type);
-
- void toggleAileron2(int index);
- void toggleElevator2(int index);
- void toggleRudder2(int index);
void switchAirframeType(int index);
-
- void enableFFTest();
void openHelp();
- void reverseMultirotorMotor();
+ void enableFFTest();
-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
diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml
index 1f2706079..98ccf4ef3 100644
--- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml
+++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml
@@ -39,74 +39,74 @@
****************************************************************************/
import QtQuick 1.1
+ import QtWebKit 1.0
// This is a tabbed pane element. Add a nested Rectangle to add a tab.
TabWidget {
- // Define AuthorsModel as type
- property AuthorsModel authors: AuthorsModel {}
-
- id: tabs
- width: 640; height: 480
- // This tab is for the GCS version information
- Rectangle {
- property string title: "OpenPilot GCS"
- anchors.fill: parent
- color: "#e3e3e3"
-
- Rectangle {
- anchors.fill: parent; anchors.margins: 20
- color: "#e3e3e3"
- Image {
- source: "../images/openpilot_logo_128.png"
- x: 0; y: 0; z: 100
- fillMode: Image.PreserveAspectFit
- }
- Flickable {
- anchors.fill: parent
- anchors.centerIn: parent
- Text {
- id: versionLabel
- x: 156; y: 0
- width: 430; height: 379
- horizontalAlignment: Qt.AlignLeft
- font.pixelSize: 12
- wrapMode: Text.WordWrap
- // @var version exposed in authorsdialog.cpp
- text: version
- }
- }
- }
- }
-
- // This tab is for the authors/contributors/credits
- Rectangle {
- property string title: "Authors"
- anchors.fill: parent; color: "#e3e3e3"
- Rectangle {
- anchors.fill: parent; anchors.margins: 20
- color: "#e3e3e3"
- Text {
- id: description
- text: "These people have been key contributors to the OpenPilot project. Without the work of the people in this list, OpenPilot would not be what it is today.
This list is sorted alphabetically by name
"
- width: 600
- wrapMode: Text.WordWrap
-
- }
- ListView {
- id: authorsView
- y: description.y + description.height + 20
- width: parent.width; height: parent.height - description.height - 20
- spacing: 3
- model: authors
- delegate: Text {
- text: name
+ // Define AuthorsModel as type
+ property AuthorsModel authors: AuthorsModel {}
+
+ id: tabs
+ width: 640; height: 480
+ // This tab is for the GCS version information
+ Rectangle {
+ property string title: "OpenPilot GCS"
+ anchors.fill: parent
+ color: "#e3e3e3"
+
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#e3e3e3"
+ Image {
+ source: "../images/openpilot_logo_128.png"
+ x: 0; y: 0; z: 100
+ fillMode: Image.PreserveAspectFit
+ }
+ Flickable {
+ anchors.fill: parent
+ anchors.centerIn: parent
+ Text {
+ id: versionLabel
+ x: 156; y: 0
+ width: 430; height: 379
+ horizontalAlignment: Qt.AlignLeft
+ font.pixelSize: 12
+ wrapMode: Text.WordWrap
+ // @var version exposed in authorsdialog.cpp
+ text: version
+ }
}
- clip: true
- }
- ScrollDecorator {
- flickableItem: authorsView
}
}
- }
+ // This tab is for the authors/contributors/credits
+ Rectangle {
+ property string title: "Authors"
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors.fill: parent; anchors.margins: 20
+ color: "#e3e3e3"
+ Text {
+ id: description
+ text: "These people have been key contributors to the OpenPilot project. Without the work of the people in this list, OpenPilot would not be what it is today.
This list is sorted alphabetically by name
"
+ width: 600
+ wrapMode: Text.WordWrap
+
+ }
+ ListView {
+ id: authorsView
+ y: description.y + description.height + 20
+ width: parent.width; height: parent.height - description.height - 20
+ spacing: 3
+ model: authors
+ delegate: Text {
+ text: name
+ }
+ clip: true
+ }
+ ScrollDecorator {
+ flickableItem: authorsView
+ }
+ }
+ }
}
diff --git a/ground/openpilotgcs/src/plugins/config/images/curve-bg.svg b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg
similarity index 81%
rename from ground/openpilotgcs/src/plugins/config/images/curve-bg.svg
rename to ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg
index d8194ec7a..492db9174 100644
--- a/ground/openpilotgcs/src/plugins/config/images/curve-bg.svg
+++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg
@@ -14,7 +14,7 @@
height="253"
id="svg2"
version="1.1"
- inkscape:version="0.48.2 r9819"
+ inkscape:version="0.48.4 r9939"
sodipodi:docname="curve-bg.svg">
@@ -55,15 +55,15 @@
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.9966906"
- inkscape:cx="181.06787"
+ inkscape:cx="102.93859"
inkscape:cy="89.329853"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1440"
inkscape:window-height="878"
- inkscape:window-x="1695"
- inkscape:window-y="97"
+ inkscape:window-x="148"
+ inkscape:window-y="40"
inkscape:window-maximized="0" />
@@ -101,49 +101,49 @@
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" />
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" />
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020;marker-start:none" />
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.28888890000000000;stroke-miterlimit:5.30000019;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" />
+ style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.28888890000000000;stroke-miterlimit:5.30000019;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" />
diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp
index 63e388a28..4c52d1afb 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp
+++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp
@@ -64,7 +64,7 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent)
QGraphicsScene *scene = new QGraphicsScene(this);
QSvgRenderer *renderer = new QSvgRenderer();
plot = new QGraphicsSvgItem();
- renderer->load(QString(":/configgadget/images/curve-bg.svg"));
+ renderer->load(QString(":/uavobjectwidgetutils/images/curve-bg.svg"));
plot->setSharedRenderer(renderer);
//plot->setElementId("map");
scene->addItem(plot);
diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro
index cedaed7c3..b75b019ce 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro
+++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro
@@ -2,16 +2,19 @@ TEMPLATE = lib
TARGET = UAVObjectWidgetUtils
DEFINES += UAVOBJECTWIDGETUTILS_LIBRARY
QT += svg
+
include(../../openpilotgcsplugin.pri)
include(uavobjectwidgetutils_dependencies.pri)
+
HEADERS += uavobjectwidgetutils_global.h \
uavobjectwidgetutilsplugin.h \
configtaskwidget.h \
mixercurvewidget.h \
mixercurvepoint.h \
mixercurveline.h \
- smartsavebutton.h \
+ smartsavebutton.h \
popupwidget.h
+
SOURCES += uavobjectwidgetutilsplugin.cpp \
configtaskwidget.cpp \
mixercurvewidget.cpp \
@@ -20,6 +23,7 @@ SOURCES += uavobjectwidgetutilsplugin.cpp \
smartsavebutton.cpp \
popupwidget.cpp
+RESOURCES += uavobjectwidgetutils.qrc
OTHER_FILES += UAVObjectWidgetUtils.pluginspec
diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc
new file mode 100644
index 000000000..9cbc86131
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc
@@ -0,0 +1,5 @@
+
+
+ images/curve-bg.svg
+
+