From 92c19f2d7479a4fd15f4603c7924762485a3e6ce Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 24 Nov 2013 17:29:38 -0500 Subject: [PATCH 01/14] Changed the element id's in one of the SVG files that I incorrectly edited. This prevents the error: Could not resolve property : SVGID_1_ Error comes from qsvghandler.cpp or qsvgstyle.cpp in the QT libraries Qt5.2.0//5.2.0-beta1/Src/qtsvg/src/svg/ The fixedwing-shapes.svg and flyingwing-shapes.svg files need modified to prevent the errors caused by qsvgtinydocument.cpp in the QT libraries. Couldn't find node aileron. Skipping rendering. Couldn't find node vtail. Skipping rendering. These errors come from the case statement that was added to updateImageAnd Description() for FixedWingPage + switch (type) { + case SetupWizard::FIXED_WING_AILERON: + elementId = "aileron"; + break; + case SetupWizard::FIXED_WING_VTAIL: + elementId = "vtail"; + break; + default: + elementId = ""; + break; + } A similar error needs to be resolved in connectiondiagram.cpp + switch (m_configSource->getVehicleSubType()) { + case VehicleConfigurationSource::FIXED_WING_AILERON: + elementsToShow << "aileron"; + break; + case VehicleConfigurationSource::FIXED_WING_VTAIL: + elementsToShow << "vtail"; + break; + default: + break; + } Likewise outputcalibrationpage.cpp will need to reverence the elements inside the SVG file properly. + m_vehicleElementIds << "fixed-aileron" << "aileron"; + m_vehicleHighlightElementIndexes << 0 << 1; ... + m_vehicleElementIds << "fixed-vtail" << "vtail"; + m_vehicleHighlightElementIndexes << 0 << 1; Until these elements are fixed in the SVG files the wizard will not render properly and allow the user to click *next*. --- .../src/plugins/config/configgadget.qrc | 3 + .../config/images/fixedwing-shapes.svg | 4 +- .../plugins/setupwizard/connectiondiagram.cpp | 10 ++ .../setupwizard/pages/fixedwingpage.cpp | 83 ++++++++- .../plugins/setupwizard/pages/fixedwingpage.h | 17 ++ .../setupwizard/pages/fixedwingpage.ui | 155 +++++++++++++++-- .../pages/outputcalibrationpage.cpp | 17 ++ .../plugins/setupwizard/pages/vehiclepage.ui | 2 +- .../src/plugins/setupwizard/setupwizard.cpp | 17 +- .../vehicleconfigurationhelper.cpp | 157 ++++++++++++++++++ .../setupwizard/vehicleconfigurationhelper.h | 3 + .../plugins/setupwizard/wizardResources.qrc | 3 + 12 files changed, 451 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index adffc9568..c2e2ab810 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -4,6 +4,9 @@ images/ahrs-calib.svg images/paper-plane.svg images/multirotor-shapes.svg + + images/fixedwing-shapes.svg + images/flyingwing-shapes.svg images/ccpm_setup.svg images/PipXtreme.png images/help.png diff --git a/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg b/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg index 63421dc38..cc85dab08 100644 --- a/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg +++ b/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg @@ -1,7 +1,7 @@ - - + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp index 4a19eb4cf..e69bf039b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp @@ -118,6 +118,16 @@ void ConnectionDiagram::setupGraphicsScene() } break; case VehicleConfigurationSource::VEHICLE_FIXEDWING: + switch (m_configSource->getVehicleSubType()) { + case VehicleConfigurationSource::FIXED_WING_AILERON: + elementsToShow << "aileron"; + break; + case VehicleConfigurationSource::FIXED_WING_VTAIL: + elementsToShow << "vtail"; + break; + default: + break; + } case VehicleConfigurationSource::VEHICLE_HELI: case VehicleConfigurationSource::VEHICLE_SURFACE: default: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp index 7295cc8a3..4c1db8e67 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp @@ -27,16 +27,97 @@ #include "fixedwingpage.h" #include "ui_fixedwingpage.h" +#include "setupwizard.h" FixedWingPage::FixedWingPage(SetupWizard *wizard, QWidget *parent) : AbstractWizardPage(wizard, parent), ui(new Ui::FixedWingPage) { ui->setupUi(this); - setFinalPage(true); + QSvgRenderer *renderer = new QSvgRenderer(); +// What do we do about v-tail here? + renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); + m_fixedwingPic = new QGraphicsSvgItem(); + m_fixedwingPic->setSharedRenderer(renderer); + QGraphicsScene *scene = new QGraphicsScene(this); + scene->addItem(m_fixedwingPic); + ui->typeGraphicsView->setScene(scene); + + setupFixedWingTypesCombo(); + + // Default to Aileron setup + ui->typeCombo->setCurrentIndex(0); + connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImageAndDescription())); + ui->typeGraphicsView->setSceneRect(m_fixedwingPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_fixedwingPic, Qt::KeepAspectRatio); + } FixedWingPage::~FixedWingPage() { delete ui; } + +void FixedWingPage::initializePage() +{ + updateAvailableTypes(); + updateImageAndDescription(); +} + +bool FixedWingPage::validatePage() +{ + SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); + + getWizard()->setVehicleSubType(type); + return true; +} + +void FixedWingPage::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + if (m_fixedwingPic) { + ui->typeGraphicsView->setSceneRect(m_fixedwingPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_fixedwingPic, Qt::KeepAspectRatio); + } +} + +void FixedWingPage::setupFixedWingTypesCombo() +{ + ui->typeCombo->addItem(tr("Aileron, Elevator, Rudder"), SetupWizard::FIXED_WING_AILERON); + m_descriptions << tr("A description for aileron driven fixed wing stuff goes here... "); + + ui->typeCombo->addItem(tr("V-Tail, or Elevon"), SetupWizard::FIXED_WING_VTAIL); + m_descriptions << tr("A description for vtail driven fixed wing stuff goes here... "); +} + +void FixedWingPage::updateAvailableTypes() +{ +} + +void FixedWingPage::updateImageAndDescription() +{ + + + SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); + QString elementId = ""; + QString description = m_descriptions.at(ui->typeCombo->currentIndex()); + + switch (type) { + case SetupWizard::FIXED_WING_AILERON: + elementId = "aileron"; + break; + case SetupWizard::FIXED_WING_VTAIL: + elementId = "vtail"; + break; + default: + elementId = ""; + break; + } + m_fixedwingPic->setElementId(elementId); + ui->typeGraphicsView->setSceneRect(m_fixedwingPic->boundingRect()); + ui->typeGraphicsView->fitInView(m_fixedwingPic, Qt::KeepAspectRatio); + + ui->typeDescription->setText(description); + +} + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h index 6a99ef2fe..593be37bb 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.h @@ -28,6 +28,10 @@ #ifndef FIXEDWINGPAGE_H #define FIXEDWINGPAGE_H +#include +#include +#include + #include "abstractwizardpage.h" namespace Ui { @@ -41,8 +45,21 @@ public: explicit FixedWingPage(SetupWizard *wizard, QWidget *parent = 0); ~FixedWingPage(); + void initializePage(); + bool validatePage(); + +protected: + void resizeEvent(QResizeEvent *event); + private: Ui::FixedWingPage *ui; + void setupFixedWingTypesCombo(); + QGraphicsSvgItem *m_fixedwingPic; + void updateAvailableTypes(); + QList m_descriptions; + +private slots: + void updateImageAndDescription(); }; #endif // FIXEDWINGPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui index 8b478be7d..ad47e2685 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui @@ -15,22 +15,147 @@ - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">The Fixed Wing section of the OpenPilot Setup Wizard is not yet implemented</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p></body></html> + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot fixedwing configuration</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">This part of the wizard will set up the OpenPilot controller for use with a flying platform utilizing multiple rotors. The wizard supports the most common types of fixedwings. Other variants of fixedwings can be configured by using custom configuration options in the Configuration plugin in the GCS.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Please select the type of fixedwing you want to create a configuration for below:</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + 4 - - Qt::AlignCenter - - - true - - + + + + + + 4 + + + + + + 125 + 36 + + + + + 10 + 50 + false + + + + Multirotor type: + + + + + + + + 125 + 20 + + + + + + + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + 0 + 0 + + + + + 200 + 200 + + + + true + + + QFrame::NoFrame + + + 0 + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + false + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index c1eebfa1d..f43304352 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -104,6 +104,23 @@ void OutputCalibrationPage::setupVehicle() m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; break; +// KF hack + case SetupWizard::FIXED_WING_AILERON: + qDebug() << "no clue what a wizard index is!"; + m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_vehicleElementIds << "fixed-aileron" << "aileron"; + m_vehicleHighlightElementIndexes << 0 << 1; + m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + getWizard()->setActuatorSettings(m_actuatorSettings); + break; + case SetupWizard::FIXED_WING_VTAIL: + qDebug() << "no clue what a wizard index is!"; + m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_vehicleElementIds << "fixed-vtail" << "vtail"; + m_vehicleHighlightElementIndexes << 0 << 1; + m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + getWizard()->setActuatorSettings(m_actuatorSettings); + break; default: break; } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui index a6e0e9354..34d9531fe 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.ui @@ -146,7 +146,7 @@ p, li { white-space: pre-wrap; } - false + true diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index de3b20063..03073cc6d 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -225,7 +225,22 @@ QString SetupWizard::getSummaryText() break; case VEHICLE_FIXEDWING: - summary.append(tr("Fixed wing")); + summary.append(tr("Fixed wing")); + + summary.append("
"); + summary.append("").append(tr("Vehicle sub type: ")).append(""); + switch (getVehicleSubType()) { + case SetupWizard::FIXED_WING_AILERON: + summary.append(tr("Aileron")); + break; + case SetupWizard::FIXED_WING_VTAIL: + summary.append(tr("Vtail")); + break; + default: + summary.append(tr("Unknown")); + break; + } + break; case VEHICLE_HELI: summary.append(tr("Helicopter")); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 6d8e0fd7d..e07a614d9 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -214,6 +214,22 @@ void VehicleConfigurationHelper::applyVehicleConfiguration() break; } case VehicleConfigurationSource::VEHICLE_FIXEDWING: + { + switch (m_configSource->getVehicleSubType()) { + case VehicleConfigurationSource::FIXED_WING_AILERON: + setupAileron(); + break; +/* case VehicleConfigurationSource::FIXED_WING_ELEVON: + setupElevon(); + break; */ + case VehicleConfigurationSource::FIXED_WING_VTAIL: + setupVtail(); + break; + default: + break; + } + break; + } case VehicleConfigurationSource::VEHICLE_HELI: case VehicleConfigurationSource::VEHICLE_SURFACE: // TODO: Implement settings for other vehicle types? @@ -1287,3 +1303,144 @@ void VehicleConfigurationHelper::setupOctoCopter() applyMixerConfiguration(channels); applyMultiGUISettings(frame, guiSettings); } + +// This is all wrong... I just copied the Tricopter stuff +void VehicleConfigurationHelper::setupVtail() +{ + + mixerChannelSettings channels[10]; + GUIConfigDataUnion guiSettings = getGUIConfigData(); + + channels[0].type = MIXER_TYPE_MOTOR; + channels[0].throttle1 = 100; + channels[0].throttle2 = 0; + channels[0].roll = 100; + channels[0].pitch = 50; + channels[0].yaw = 0; + + channels[1].type = MIXER_TYPE_MOTOR; + channels[1].throttle1 = 100; + channels[1].throttle2 = 0; + channels[1].roll = -100; + channels[1].pitch = 50; + channels[1].yaw = 0; + + channels[2].type = MIXER_TYPE_MOTOR; + channels[2].throttle1 = 100; + channels[2].throttle2 = 0; + channels[2].roll = 0; + channels[2].pitch = -100; + channels[2].yaw = 0; + + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 0; + channels[3].yaw = 100; + + guiSettings.multi.VTOLMotorNW = 1; + guiSettings.multi.VTOLMotorNE = 2; + guiSettings.multi.VTOLMotorS = 3; + guiSettings.multi.TRIYaw = 4; + + applyMixerConfiguration(channels); + applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings); +} + +// This is all wrong... I just copied the Tricopter stuff +void VehicleConfigurationHelper::setupAileron() +{ + // Typical vehicle setup + // 1. Setup mixer data + // 2. Setup GUI data + // 3. Apply changes + + mixerChannelSettings channels[10]; + GUIConfigDataUnion guiSettings = getGUIConfigData(); + + channels[0].type = MIXER_TYPE_MOTOR; + channels[0].throttle1 = 100; + channels[0].throttle2 = 0; + channels[0].roll = 100; + channels[0].pitch = 50; + channels[0].yaw = 0; + + channels[1].type = MIXER_TYPE_MOTOR; + channels[1].throttle1 = 100; + channels[1].throttle2 = 0; + channels[1].roll = -100; + channels[1].pitch = 50; + channels[1].yaw = 0; + + channels[2].type = MIXER_TYPE_MOTOR; + channels[2].throttle1 = 100; + channels[2].throttle2 = 0; + channels[2].roll = 0; + channels[2].pitch = -100; + channels[2].yaw = 0; + + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 0; + channels[3].yaw = 100; + + guiSettings.multi.VTOLMotorNW = 1; + guiSettings.multi.VTOLMotorNE = 2; + guiSettings.multi.VTOLMotorS = 3; + guiSettings.multi.TRIYaw = 4; + + applyMixerConfiguration(channels); + applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings); +} + +// This is all wrong... I just copied the Tricopter stuff +void VehicleConfigurationHelper::setupElevon() +{ + // Typical vehicle setup + // 1. Setup mixer data + // 2. Setup GUI data + // 3. Apply changes + + mixerChannelSettings channels[10]; + GUIConfigDataUnion guiSettings = getGUIConfigData(); + + channels[0].type = MIXER_TYPE_MOTOR; + channels[0].throttle1 = 100; + channels[0].throttle2 = 0; + channels[0].roll = 100; + channels[0].pitch = 50; + channels[0].yaw = 0; + + channels[1].type = MIXER_TYPE_MOTOR; + channels[1].throttle1 = 100; + channels[1].throttle2 = 0; + channels[1].roll = -100; + channels[1].pitch = 50; + channels[1].yaw = 0; + + channels[2].type = MIXER_TYPE_MOTOR; + channels[2].throttle1 = 100; + channels[2].throttle2 = 0; + channels[2].roll = 0; + channels[2].pitch = -100; + channels[2].yaw = 0; + + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 0; + channels[3].yaw = 100; + + guiSettings.multi.VTOLMotorNW = 1; + guiSettings.multi.VTOLMotorNE = 2; + guiSettings.multi.VTOLMotorS = 3; + guiSettings.multi.TRIYaw = 4; + + applyMixerConfiguration(channels); + applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON, guiSettings); +} + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h index 1ed1aa576..197f1a435 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h @@ -103,6 +103,9 @@ private: void setupQuadCopter(); void setupHexaCopter(); void setupOctoCopter(); + void setupVtail(); + void setupAileron(); + void setupElevon(); private slots: void uAVOTransactionCompleted(UAVObject *object, bool success); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc index 1ee031d0e..2c1c13e3c 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc +++ b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc @@ -30,6 +30,9 @@ resources/bttn-turbo-down.png resources/bttn-turbo-up.png resources/multirotor-shapes.svg + + resources/fixedwing-shapes.svg + resources/flyingwing-shapes.svg resources/bttn-illustration-down.png resources/bttn-illustration-up.png resources/bttn-save-down.png From 0d5e91ee266bf3f75ebae4b501fe1ce5d488c8b4 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Mon, 25 Nov 2013 01:06:07 -0500 Subject: [PATCH 02/14] I fixed the first screen, now the vtail and aileron models show when slected. For some reason I am unable to move beyond the first wizard screen. --- .../src/plugins/config/configgadget.qrc | 1 - .../config/images/fixedwing-shapes.svg | 3625 +++++++++++++---- .../config/images/flyingwing-shapes.svg | 544 --- .../setupwizard/pages/fixedwingpage.cpp | 1 - .../setupwizard/pages/fixedwingpage.ui | 2 +- .../pages/outputcalibrationpage.cpp | 7 +- .../resources/fixedwing-shapes.svg | 3625 +++++++++++++---- .../resources/flyingwing-shapes.svg | 544 --- .../plugins/setupwizard/wizardResources.qrc | 1 - 9 files changed, 5584 insertions(+), 2766 deletions(-) delete mode 100644 ground/openpilotgcs/src/plugins/config/images/flyingwing-shapes.svg delete mode 100644 ground/openpilotgcs/src/plugins/setupwizard/resources/flyingwing-shapes.svg diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index c2e2ab810..f58ce7203 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -6,7 +6,6 @@ images/multirotor-shapes.svg images/fixedwing-shapes.svg - images/flyingwing-shapes.svg images/ccpm_setup.svg images/PipXtreme.png images/help.png diff --git a/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg b/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg index cc85dab08..e99a33c65 100644 --- a/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg +++ b/ground/openpilotgcs/src/plugins/config/images/fixedwing-shapes.svg @@ -1,836 +1,2789 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/images/flyingwing-shapes.svg b/ground/openpilotgcs/src/plugins/config/images/flyingwing-shapes.svg deleted file mode 100644 index 62ecd3aaf..000000000 --- a/ground/openpilotgcs/src/plugins/config/images/flyingwing-shapes.svg +++ /dev/null @@ -1,544 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp index 4c1db8e67..543da261e 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp @@ -35,7 +35,6 @@ FixedWingPage::FixedWingPage(SetupWizard *wizard, QWidget *parent) : { ui->setupUi(this); QSvgRenderer *renderer = new QSvgRenderer(); -// What do we do about v-tail here? renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); m_fixedwingPic = new QGraphicsSvgItem(); m_fixedwingPic->setSharedRenderer(renderer); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui index ad47e2685..b1c5f253f 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.ui @@ -63,7 +63,7 @@ - Multirotor type: + FixedWing type: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index f43304352..a6e5d74f9 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -36,6 +36,7 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren { ui->setupUi(this); + qDebug() << "calling output calibration page"; m_vehicleRenderer = new QSvgRenderer(); if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && @@ -107,7 +108,8 @@ void OutputCalibrationPage::setupVehicle() // KF hack case SetupWizard::FIXED_WING_AILERON: qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; +// m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; m_vehicleElementIds << "fixed-aileron" << "aileron"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; @@ -115,7 +117,8 @@ void OutputCalibrationPage::setupVehicle() break; case SetupWizard::FIXED_WING_VTAIL: qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; +// m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes.svg index 63421dc38..e99a33c65 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes.svg +++ b/ground/openpilotgcs/src/plugins/setupwizard/resources/fixedwing-shapes.svg @@ -1,836 +1,2789 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/flyingwing-shapes.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/flyingwing-shapes.svg deleted file mode 100644 index 62ecd3aaf..000000000 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/flyingwing-shapes.svg +++ /dev/null @@ -1,544 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc index 2c1c13e3c..507b4c877 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc +++ b/ground/openpilotgcs/src/plugins/setupwizard/wizardResources.qrc @@ -32,7 +32,6 @@ resources/multirotor-shapes.svg resources/fixedwing-shapes.svg - resources/flyingwing-shapes.svg resources/bttn-illustration-down.png resources/bttn-illustration-up.png resources/bttn-save-down.png From 2b585a861878ef034c236966d6605f55b08836cf Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sat, 14 Dec 2013 16:46:26 -0500 Subject: [PATCH 03/14] added a case statement for PAGE_FIXEDWING to trigger PAGE_OUTPUT --- ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 03073cc6d..449296f5b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -112,6 +112,9 @@ int SetupWizard::nextId() const case PAGE_MULTI: return PAGE_OUTPUT; + case PAGE_FIXEDWING: + return PAGE_OUTPUT; + case PAGE_INPUT: if (isRestartNeeded()) { saveHardwareSettings(); From a042ffd843338d69270b698482132b16b6f80784 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 15 Dec 2013 03:38:12 -0500 Subject: [PATCH 04/14] just trying to cleanup a bad push from last night. I stomped on some things I should not have. --- .../openpilotgcs/src/plugins/config/airframe_fixedwing.ui | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui index 1b42f042d..176b5daca 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui @@ -37,6 +37,14 @@ Airplane type: + + + + 0 + 0 + + + From 632ffed7079e9528aaa435069ac5cb504b996449 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Sun, 15 Dec 2013 21:37:19 -0500 Subject: [PATCH 05/14] Add the fixed wing plane art to the channel config screen (in progress) Begin adding plane art to Output config screen in wizard. --- .../configfixedwingwidget.cpp | 99 +++++++++++++++++-- .../cfg_vehicletypes/configfixedwingwidget.h | 15 ++- .../pages/outputcalibrationpage.cpp | 3 + 3 files changed, 104 insertions(+), 13 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 1a667fa5e..57a204a10 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -40,6 +40,8 @@ #include #include +const QString ConfigFixedWingWidget::CHANNELBOXNAME = QString("fixedWingChannelBox"); + QStringList ConfigFixedWingWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults @@ -83,6 +85,32 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : populateChannelComboBoxes(); + QSvgRenderer *renderer = new QSvgRenderer(); + renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); + plane = new QGraphicsSvgItem(); + plane->setSharedRenderer(renderer); + + QString type = "aileron"; // This needs fixed. Need to be able to obtain the aircraft type. + + // not sure why m_aircraft->fixedWingType->currentText() is not working here! fix it + if (type == "vtail") + { + plane->setElementId("vtail"); + } + else if (type == "aileron") + { + plane->setElementId("aileron"); + } + else + { + plane->setElementId("unknown"); + } + + QGraphicsScene *scene = new QGraphicsScene(); + scene->addItem(plane); + scene->setSceneRect(plane->boundingRect()); + m_aircraft->planeShape->setScene(scene); + QStringList fixedWingTypes; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; m_aircraft->fixedWingType->addItems(fixedWingTypes); @@ -90,6 +118,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : // Set default model to "Elevator aileron rudder" connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); + setupUI(m_aircraft->fixedWingType->currentText()); } @@ -158,6 +187,26 @@ void ConfigFixedWingWidget::setupUI(QString frameType) } } +void ConfigFixedWingWidget::setupEnabledControls(QString frameType) +{ + + // disable all motor channel boxes + for (int i = 1; i <= 8; i++) { + // do it manually so we can turn off any error decorations + QComboBox *combobox = this->findChild("fixedWingChannelBox" + QString::number(i)); + if (combobox) { + combobox->setEnabled(false); + combobox->setItemData(0, 0, Qt::DecorationRole); + } + } + + if (frameType == "Vtail" || frameType == "Elevon") { + enableComboBoxes(this, CHANNELBOXNAME, 3, true); + } else if (frameType == "aileron" || frameType == "Elevator aileron rudder") { + enableComboBoxes(this, CHANNELBOXNAME, 4, true); + } +} + void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent) { parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget()); @@ -278,6 +327,16 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() return airframeType; } +void ConfigFixedWingWidget::updateAirframe(QString frameType) +{ + qDebug() << "ConfigFixedWingWidget::updateAirframe - frame type" << frameType; + + // this is not doing anything right now + + m_aircraft->planeShape->setSceneRect(plane->boundingRect()); + m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio); +} + /** Setup Elevator/Aileron/Rudder airframe. @@ -502,15 +561,6 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) return true; } -void ConfigFixedWingWidget::enableControls(bool enable) -{ - ConfigTaskWidget::enableControls(enable); - - if (enable) { - setupUI(m_aircraft->fixedWingType->currentText()); - } -} - /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ @@ -600,3 +650,34 @@ bool ConfigFixedWingWidget::throwConfigError(QString airframeType) return error; } + +/** + WHAT DOES THIS DO??? + */ +void ConfigFixedWingWidget::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->planeShape->fitInView(plane, Qt::KeepAspectRatio); +} + +/** + Resize the GUI contents when the user changes the window size + */ +void ConfigFixedWingWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio); +} + +void ConfigFixedWingWidget::enableControls(bool enable) +{ + ConfigTaskWidget::enableControls(enable); + + if (enable) { + setupEnabledControls(m_aircraft->fixedWingType->currentText()); + } +} + diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 65c03c86e..da8ef3839 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -34,8 +34,9 @@ #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" + +#include #include -#include #include class Ui_Widget; @@ -44,6 +45,7 @@ class ConfigFixedWingWidget : public VehicleConfig { Q_OBJECT public: + static const QString CHANNELBOXNAME; static QStringList getChannelDescriptions(); ConfigFixedWingWidget(QWidget *parent = 0); @@ -52,8 +54,14 @@ public: virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); + void enableControls(bool enable); + private: Ui_FixedWingConfigWidget *m_aircraft; + QGraphicsSvgItem *plane; virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); @@ -62,9 +70,8 @@ private: bool setupFrameElevon(QString airframeType); bool setupFrameVtail(QString airframeType); -protected: - void enableControls(bool enable); - + void updateAirframe(QString multiRotorType); + void setupEnabledControls(QString airframeType); private slots: virtual void setupUI(QString airframeType); virtual bool throwConfigError(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index a6e5d74f9..2741e1b7b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -38,6 +38,9 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren qDebug() << "calling output calibration page"; m_vehicleRenderer = new QSvgRenderer(); + +// need to determine multi rotor or fixed wing. and pick the right svg + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && m_vehicleRenderer->isValid()) { From 82e2c5cf924613c654a97579bfd3f483d956df37 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Mon, 16 Dec 2013 14:29:04 -0500 Subject: [PATCH 06/14] Move some code around to accomidate multiple svg images in the output calibration screen. Need to fix the SVG to allow for zooming in on specific channel components as we do with the multi rotor screen. This has some sloppy comments in if for my own debugging purposes. --- .../configfixedwingwidget.cpp | 1 + .../pages/outputcalibrationpage.cpp | 55 ++++++++++++++++--- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 57a204a10..af76c818d 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -92,6 +92,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : QString type = "aileron"; // This needs fixed. Need to be able to obtain the aircraft type. + qDebug() << "Current Aircraft type: " << m_aircraft->fixedWingType->currentText(); // not sure why m_aircraft->fixedWingType->currentText() is not working here! fix it if (type == "vtail") { diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index 2741e1b7b..1bbd4b4cc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -39,14 +39,10 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren qDebug() << "calling output calibration page"; m_vehicleRenderer = new QSvgRenderer(); -// need to determine multi rotor or fixed wing. and pick the right svg + // move the code that was here to setupVehicle() so we can determine which image to use. + m_vehicleScene = new QGraphicsScene(this); + ui->vehicleView->setScene(m_vehicleScene); - if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && - m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && - m_vehicleRenderer->isValid()) { - m_vehicleScene = new QGraphicsScene(this); - ui->vehicleView->setScene(m_vehicleScene); - } } OutputCalibrationPage::~OutputCalibrationPage() @@ -67,8 +63,18 @@ void OutputCalibrationPage::setupVehicle() m_channelIndex.clear(); m_currentWizardIndex = 0; m_vehicleScene->clear(); + +// KF moved code from OutputCalibrationPage() here so it can be used to detect the current vehicle +// needs to be slimmed down and not repeated. + switch (getWizard()->getVehicleSubType()) { case SetupWizard::MULTI_ROTOR_TRI_Y: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } + m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; m_vehicleElementIds << "tri" << "tri-frame" << "tri-m1" << "tri-m2" << "tri-m3" << "tri-s1"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 4 << 4; @@ -79,30 +85,55 @@ void OutputCalibrationPage::setupVehicle() getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::MULTI_ROTOR_QUAD_X: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1; m_vehicleElementIds << "quad-x" << "quad-x-frame" << "quad-x-m1" << "quad-x-m2" << "quad-x-m3" << "quad-x-m4"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4; m_channelIndex << 0 << 0 << 1 << 2 << 3; break; case SetupWizard::MULTI_ROTOR_QUAD_PLUS: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1; m_vehicleElementIds << "quad-p" << "quad-p-frame" << "quad-p-m1" << "quad-p-m2" << "quad-p-m3" << "quad-p-m4"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4; m_channelIndex << 0 << 0 << 1 << 2 << 3; break; case SetupWizard::MULTI_ROTOR_HEXA: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4" << "hexa-m5" << "hexa-m6"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; break; case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa-y6" << "hexa-y6-frame" << "hexa-y6-m2" << "hexa-y6-m1" << "hexa-y6-m4" << "hexa-y6-m3" << "hexa-y6-m6" << "hexa-y6-m5"; m_vehicleHighlightElementIndexes << 0 << 2 << 1 << 4 << 3 << 6 << 5; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; break; case SetupWizard::MULTI_ROTOR_HEXA_H: + if (QFile::exists(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/multirotor-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa-h" << "hexa-h-frame" << "hexa-h-m1" << "hexa-h-m2" << "hexa-h-m3" << "hexa-h-m4" << "hexa-h-m5" << "hexa-h-m6"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; @@ -110,6 +141,11 @@ void OutputCalibrationPage::setupVehicle() break; // KF hack case SetupWizard::FIXED_WING_AILERON: + if (QFile::exists(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } qDebug() << "no clue what a wizard index is!"; // m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; @@ -119,6 +155,11 @@ void OutputCalibrationPage::setupVehicle() getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::FIXED_WING_VTAIL: + if (QFile::exists(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->load(QString(":/setupwizard/resources/fixedwing-shapes.svg")) && + m_vehicleRenderer->isValid()) { + ui->vehicleView->setScene(m_vehicleScene); + } qDebug() << "no clue what a wizard index is!"; // m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; From a960fd5c852dc84eafeebe5d8cc8bd1036263c06 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Mon, 16 Dec 2013 15:18:43 -0500 Subject: [PATCH 07/14] Fix the Configuration screen to show the new fixed wing artwork by Zen_ --- .../configfixedwingwidget.cpp | 45 ++++++++----------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index af76c818d..1c26cc512 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -85,33 +85,6 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : populateChannelComboBoxes(); - QSvgRenderer *renderer = new QSvgRenderer(); - renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); - plane = new QGraphicsSvgItem(); - plane->setSharedRenderer(renderer); - - QString type = "aileron"; // This needs fixed. Need to be able to obtain the aircraft type. - - qDebug() << "Current Aircraft type: " << m_aircraft->fixedWingType->currentText(); - // not sure why m_aircraft->fixedWingType->currentText() is not working here! fix it - if (type == "vtail") - { - plane->setElementId("vtail"); - } - else if (type == "aileron") - { - plane->setElementId("aileron"); - } - else - { - plane->setElementId("unknown"); - } - - QGraphicsScene *scene = new QGraphicsScene(); - scene->addItem(plane); - scene->setSceneRect(plane->boundingRect()); - m_aircraft->planeShape->setScene(scene); - QStringList fixedWingTypes; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; m_aircraft->fixedWingType->addItems(fixedWingTypes); @@ -135,7 +108,17 @@ void ConfigFixedWingWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); + // This had to be moved from ConfigFixedWingWidget() here since m_aircraft->fixedWingType->currentText() + // did not seem to work properly to choose alternate .svg files. + QSvgRenderer *renderer = new QSvgRenderer(); + renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); + plane = new QGraphicsSvgItem(); + plane->setSharedRenderer(renderer); + + qDebug() << "Current Aircraft type: \n" << m_aircraft->fixedWingType->currentText(); + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") { + plane->setElementId("aileron"); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fwRudder1ChannelBox->setEnabled(true); m_aircraft->fwRudder2ChannelBox->setEnabled(true); @@ -152,6 +135,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonSlider1->setEnabled(false); m_aircraft->elevonSlider2->setEnabled(false); } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { + plane->setElementId("aileron"); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); m_aircraft->fwAileron1Label->setText("Elevon 1"); m_aircraft->fwAileron2Label->setText("Elevon 2"); @@ -168,6 +152,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonSlider1->setEnabled(true); m_aircraft->elevonSlider2->setEnabled(true); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { + plane->setElementId("vtail"); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail")); m_aircraft->fwRudder1ChannelBox->setEnabled(false); m_aircraft->fwRudder2ChannelBox->setEnabled(false); @@ -186,6 +171,12 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonSlider1->setEnabled(true); m_aircraft->elevonSlider2->setEnabled(true); } + + QGraphicsScene *scene = new QGraphicsScene(); + scene->addItem(plane); + scene->setSceneRect(plane->boundingRect()); + m_aircraft->planeShape->setScene(scene); + } void ConfigFixedWingWidget::setupEnabledControls(QString frameType) From 6e5e7e4dd374c5fbe6d5e8e4242f3f5c0bea6d80 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Mon, 16 Dec 2013 20:51:43 -0500 Subject: [PATCH 08/14] Work around for a problem caused by lack of elements in the fixed wing SVG for use in the output window. --- .../config/cfg_vehicletypes/configfixedwingwidget.cpp | 2 +- .../plugins/setupwizard/pages/outputcalibrationpage.cpp | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 1c26cc512..f7df0289e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -135,7 +135,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonSlider1->setEnabled(false); m_aircraft->elevonSlider2->setEnabled(false); } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { - plane->setElementId("aileron"); + plane->setElementId("vtail"); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); m_aircraft->fwAileron1Label->setText("Elevon 1"); m_aircraft->fwAileron2Label->setText("Elevon 2"); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index 1bbd4b4cc..a2963dfac 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -147,8 +147,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; -// m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; - m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; + m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "fixed-aileron" << "aileron"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; @@ -161,8 +160,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; -// m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; - m_wizardIndexes << 0 << 1 << 1 << 1 << 2 << 3 << 4; + m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; @@ -255,7 +253,7 @@ void OutputCalibrationPage::setWizardPage() ui->servoMaxAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMax); } } - setupVehicleHighlightedPart(); + // setupVehicleHighlightedPart(); // turn this off for now, need to fix fixedwing image elements } void OutputCalibrationPage::initializePage() From 9e417f5ee5909e0b9616cd1c138912543a695a63 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 18 Dec 2013 12:57:35 -0500 Subject: [PATCH 09/14] Remove some redundant "elevon" stuff for now. Will come back later when proper "elevon + rudder" artwork exists. Currently no different from vtail anyway... Enabled proper channel mixing settings inside the FixedWing wizard Output configuration screen. Attempt to set GUIConfigDataUnion to fixedwing --- .../configfixedwingwidget.cpp | 130 +----------------- .../cfg_vehicletypes/configfixedwingwidget.h | 1 - .../config/configvehicletypewidget.cpp | 7 +- .../setupwizard/pages/fixedwingpage.cpp | 6 +- .../pages/outputcalibrationpage.cpp | 37 ++++- .../vehicleconfigurationhelper.cpp | 120 +++++----------- .../setupwizard/vehicleconfigurationhelper.h | 1 - 7 files changed, 78 insertions(+), 224 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index f7df0289e..71861c2c4 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -86,7 +86,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : populateChannelComboBoxes(); QStringList fixedWingTypes; - fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; + fixedWingTypes << "Elevator aileron rudder" << "Vtail"; m_aircraft->fixedWingType->addItems(fixedWingTypes); // Set default model to "Elevator aileron rudder" @@ -134,23 +134,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonSlider1->setEnabled(false); m_aircraft->elevonSlider2->setEnabled(false); - } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { - plane->setElementId("vtail"); - setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); - m_aircraft->fwAileron1Label->setText("Elevon 1"); - m_aircraft->fwAileron2Label->setText("Elevon 2"); - m_aircraft->fwElevator1ChannelBox->setEnabled(false); - m_aircraft->fwElevator2ChannelBox->setEnabled(false); - m_aircraft->fwRudder1ChannelBox->setEnabled(true); - m_aircraft->fwRudder2ChannelBox->setEnabled(true); - - m_aircraft->fwElevator1Label->setText("Elevator 1"); - m_aircraft->fwElevator2Label->setText("Elevator 2"); - m_aircraft->elevonLabel1->setText("Roll"); - m_aircraft->elevonLabel2->setText("Pitch"); - - m_aircraft->elevonSlider1->setEnabled(true); - m_aircraft->elevonSlider2->setEnabled(true); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { plane->setElementId("vtail"); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail")); @@ -192,7 +175,7 @@ void ConfigFixedWingWidget::setupEnabledControls(QString frameType) } } - if (frameType == "Vtail" || frameType == "Elevon") { + if (frameType == "Vtail" || frameType == "vtail") { enableComboBoxes(this, CHANNELBOXNAME, 3, true); } else if (frameType == "aileron" || frameType == "Elevator aileron rudder") { enableComboBoxes(this, CHANNELBOXNAME, 4, true); @@ -263,18 +246,9 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1); setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2); - if (frameType == "FixedWingElevon") { - // If the airframe is elevon, restore the slider setting + if (frameType == "FixedWingVtail") { + // If the airframe is vtail, 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. @@ -308,10 +282,7 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder") { airframeType = "FixedWing"; setupFrameFixedWing(airframeType); - } else if (m_aircraft->fixedWingType->currentText() == "Elevon") { - airframeType = "FixedWingElevon"; - setupFrameElevon(airframeType); - } else { // "Vtail" + } else if (m_aircraft->fixedWingType->currentText() == "vtail") { airframeType = "FixedWingVtail"; setupFrameVtail(airframeType); } @@ -404,76 +375,6 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) return true; } -/** - Setup Elevon - */ -bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) -{ - // Check coherence: - // Show any config errors in GUI - if (throwConfigError(airframeType)) { - return false; - } - - GUIConfigDataUnion config = getConfigData(); - resetActuators(&config); - - config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); - config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); - config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); - config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); - config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - - setConfigData(config); - - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - resetMotorAndServoMixers(mixer); - - // Save the curve: - // ... and compute the matrix: - // In order to make code a bit nicer, we assume: - // - Channel dropdowns start with 'None', then 0 to 7 - - // 1. Assign the servo/motor/none for each channel - - double value; - - // 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); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - - channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1; - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - - // ailerons - channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; - if (channel > -1) { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); - value = (double)(m_aircraft->elevonSlider2->value() * 1.27); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); - value = (double)(m_aircraft->elevonSlider1->value() * 1.27); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, value); - - channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1; - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); - value = (double)(m_aircraft->elevonSlider2->value() * 1.27); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); - value = (double)(m_aircraft->elevonSlider1->value() * 1.27); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value); - } - - m_aircraft->fwStatusLabel->setText("Mixer generated"); - return true; -} - /** Setup VTail */ @@ -592,27 +493,6 @@ bool ConfigFixedWingWidget::throwConfigError(QString airframeType) 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 diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index da8ef3839..28126fc26 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -67,7 +67,6 @@ private: virtual void resetActuators(GUIConfigDataUnion *configData); bool setupFrameFixedWing(QString airframeType); - bool setupFrameElevon(QString airframeType); bool setupFrameVtail(QString airframeType); void updateAirframe(QString multiRotorType); diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 0d6d4ee05..2abcc7d4c 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -68,9 +68,11 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() QStringList channelDesc; switch (systemSettingsData.AirframeType) { case SystemSettings::AIRFRAMETYPE_FIXEDWING: + channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); + break; case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + // do nothing for elevon support for the time being. case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: - // fixed wing channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); break; case SystemSettings::AIRFRAMETYPE_HELICP: @@ -268,8 +270,7 @@ QString ConfigVehicleTypeWidget::frameCategory(QString frameType) { QString category; - if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" - || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || 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" diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp index 543da261e..9dd9b9638 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/fixedwingpage.cpp @@ -83,10 +83,10 @@ void FixedWingPage::resizeEvent(QResizeEvent *event) void FixedWingPage::setupFixedWingTypesCombo() { ui->typeCombo->addItem(tr("Aileron, Elevator, Rudder"), SetupWizard::FIXED_WING_AILERON); - m_descriptions << tr("A description for aileron driven fixed wing stuff goes here... "); + m_descriptions << tr("This setup currently expects a traditional 4 channel setup including two ailerons (not connected by Y adapter), an elevator and a rudder. "); - ui->typeCombo->addItem(tr("V-Tail, or Elevon"), SetupWizard::FIXED_WING_VTAIL); - m_descriptions << tr("A description for vtail driven fixed wing stuff goes here... "); + ui->typeCombo->addItem(tr("V-Tail"), SetupWizard::FIXED_WING_VTAIL); + m_descriptions << tr("This setup currently expects a flying-wing setup, an elevon plus rudder setup is not yet supported. Setup should include only two elevons, and should explicitly not include a rudder."); } void FixedWingPage::updateAvailableTypes() diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index a2963dfac..f39db1abe 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -147,10 +147,29 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "fixed-aileron" << "aileron"; m_vehicleHighlightElementIndexes << 0 << 1; - m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4; + + // see Servo city for an example. 1500 usec is center on MS85mg for example. - http://www.servocity.com/html/hs-85mg__mighty_micro.html + // make sure Aileron servo one does not go to an extreme value + m_actuatorSettings[1].channelMin = 1500; + m_actuatorSettings[1].channelNeutral = 1500; + m_actuatorSettings[1].channelMax = 1500; + // make sure Aileron servo two does not go to an extreme value + m_actuatorSettings[2].channelMin = 1500; + m_actuatorSettings[2].channelNeutral = 1500; + m_actuatorSettings[2].channelMax = 1500; + // make sure Elevator servo one does not go to an extreme value + m_actuatorSettings[3].channelMin = 1500; + m_actuatorSettings[4].channelNeutral = 1500; + m_actuatorSettings[3].channelMax = 1500; + // make sure Rudder servo one does not go to an extreme value + m_actuatorSettings[4].channelMin = 1500; + m_actuatorSettings[4].channelNeutral = 1500; + m_actuatorSettings[4].channelMax = 1500; + getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::FIXED_WING_VTAIL: @@ -160,10 +179,20 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; + m_wizardIndexes << 0 << 1 << 1 << 1; m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; - m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + m_channelIndex << 0 << 0 << 1 << 2; + + // make sure elevon servo one does not go to an extreme value + m_actuatorSettings[1].channelMin = 1500; + m_actuatorSettings[1].channelNeutral = 1500; + m_actuatorSettings[1].channelMax = 1500; + // make sure elevon servo two does not go to an extreme value + m_actuatorSettings[2].channelMin = 1500; + m_actuatorSettings[2].channelNeutral = 1500; + m_actuatorSettings[2].channelMax = 1500; + getWizard()->setActuatorSettings(m_actuatorSettings); break; default: diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index e07a614d9..d32d0146a 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -219,9 +219,6 @@ void VehicleConfigurationHelper::applyVehicleConfiguration() case VehicleConfigurationSource::FIXED_WING_AILERON: setupAileron(); break; -/* case VehicleConfigurationSource::FIXED_WING_ELEVON: - setupElevon(); - break; */ case VehicleConfigurationSource::FIXED_WING_VTAIL: setupVtail(); break; @@ -1304,7 +1301,6 @@ void VehicleConfigurationHelper::setupOctoCopter() applyMultiGUISettings(frame, guiSettings); } -// This is all wrong... I just copied the Tricopter stuff void VehicleConfigurationHelper::setupVtail() { @@ -1314,41 +1310,32 @@ void VehicleConfigurationHelper::setupVtail() channels[0].type = MIXER_TYPE_MOTOR; channels[0].throttle1 = 100; channels[0].throttle2 = 0; - channels[0].roll = 100; - channels[0].pitch = 50; + channels[0].roll = 0; + channels[0].pitch = 0; channels[0].yaw = 0; - channels[1].type = MIXER_TYPE_MOTOR; - channels[1].throttle1 = 100; + channels[1].type = MIXER_TYPE_SERVO; + channels[1].throttle1 = 0; channels[1].throttle2 = 0; channels[1].roll = -100; channels[1].pitch = 50; channels[1].yaw = 0; - channels[2].type = MIXER_TYPE_MOTOR; - channels[2].throttle1 = 100; + channels[2].type = MIXER_TYPE_SERVO; + channels[2].throttle1 = 0; channels[2].throttle2 = 0; - channels[2].roll = 0; - channels[2].pitch = -100; + channels[2].roll = 100; + channels[2].pitch = -50; channels[2].yaw = 0; - channels[3].type = MIXER_TYPE_SERVO; - channels[3].throttle1 = 0; - channels[3].throttle2 = 0; - channels[3].roll = 0; - channels[3].pitch = 0; - channels[3].yaw = 100; - - guiSettings.multi.VTOLMotorNW = 1; - guiSettings.multi.VTOLMotorNE = 2; - guiSettings.multi.VTOLMotorS = 3; - guiSettings.multi.TRIYaw = 4; + guiSettings.fixedwing.FixedWingThrottle = 1; + guiSettings.fixedwing.FixedWingRoll1 = 2; + guiSettings.fixedwing.FixedWingRoll2 = 3; applyMixerConfiguration(channels); applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings); } -// This is all wrong... I just copied the Tricopter stuff void VehicleConfigurationHelper::setupAileron() { // Typical vehicle setup @@ -1362,24 +1349,31 @@ void VehicleConfigurationHelper::setupAileron() channels[0].type = MIXER_TYPE_MOTOR; channels[0].throttle1 = 100; channels[0].throttle2 = 0; - channels[0].roll = 100; - channels[0].pitch = 50; + channels[0].roll = 0; + channels[0].pitch = 0; channels[0].yaw = 0; - channels[1].type = MIXER_TYPE_MOTOR; - channels[1].throttle1 = 100; + channels[1].type = MIXER_TYPE_SERVO; + channels[1].throttle1 = 0; channels[1].throttle2 = 0; channels[1].roll = -100; - channels[1].pitch = 50; + channels[1].pitch = 0; channels[1].yaw = 0; - channels[2].type = MIXER_TYPE_MOTOR; - channels[2].throttle1 = 100; + channels[2].type = MIXER_TYPE_SERVO; + channels[2].throttle1 = 0; channels[2].throttle2 = 0; - channels[2].roll = 0; - channels[2].pitch = -100; + channels[2].roll = 100; + channels[2].pitch = 0; channels[2].yaw = 0; + channels[3].type = MIXER_TYPE_SERVO; + channels[3].throttle1 = 0; + channels[3].throttle2 = 0; + channels[3].roll = 0; + channels[3].pitch = 100; + channels[3].yaw = 0; + channels[3].type = MIXER_TYPE_SERVO; channels[3].throttle1 = 0; channels[3].throttle2 = 0; @@ -1387,60 +1381,12 @@ void VehicleConfigurationHelper::setupAileron() channels[3].pitch = 0; channels[3].yaw = 100; - guiSettings.multi.VTOLMotorNW = 1; - guiSettings.multi.VTOLMotorNE = 2; - guiSettings.multi.VTOLMotorS = 3; - guiSettings.multi.TRIYaw = 4; + guiSettings.fixedwing.FixedWingThrottle = 1; + guiSettings.fixedwing.FixedWingRoll1 = 2; + guiSettings.fixedwing.FixedWingRoll2 = 3; + guiSettings.fixedwing.FixedWingPitch1 = 4; + guiSettings.fixedwing.FixedWingYaw1 = 5; applyMixerConfiguration(channels); - applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL, guiSettings); + applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGAILERON, guiSettings); } - -// This is all wrong... I just copied the Tricopter stuff -void VehicleConfigurationHelper::setupElevon() -{ - // Typical vehicle setup - // 1. Setup mixer data - // 2. Setup GUI data - // 3. Apply changes - - mixerChannelSettings channels[10]; - GUIConfigDataUnion guiSettings = getGUIConfigData(); - - channels[0].type = MIXER_TYPE_MOTOR; - channels[0].throttle1 = 100; - channels[0].throttle2 = 0; - channels[0].roll = 100; - channels[0].pitch = 50; - channels[0].yaw = 0; - - channels[1].type = MIXER_TYPE_MOTOR; - channels[1].throttle1 = 100; - channels[1].throttle2 = 0; - channels[1].roll = -100; - channels[1].pitch = 50; - channels[1].yaw = 0; - - channels[2].type = MIXER_TYPE_MOTOR; - channels[2].throttle1 = 100; - channels[2].throttle2 = 0; - channels[2].roll = 0; - channels[2].pitch = -100; - channels[2].yaw = 0; - - channels[3].type = MIXER_TYPE_SERVO; - channels[3].throttle1 = 0; - channels[3].throttle2 = 0; - channels[3].roll = 0; - channels[3].pitch = 0; - channels[3].yaw = 100; - - guiSettings.multi.VTOLMotorNW = 1; - guiSettings.multi.VTOLMotorNE = 2; - guiSettings.multi.VTOLMotorS = 3; - guiSettings.multi.TRIYaw = 4; - - applyMixerConfiguration(channels); - applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON, guiSettings); -} - diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h index 197f1a435..d3ef88df4 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.h @@ -105,7 +105,6 @@ private: void setupOctoCopter(); void setupVtail(); void setupAileron(); - void setupElevon(); private slots: void uAVOTransactionCompleted(UAVObject *object, bool success); From b6f0e5e3058e65f937f9f89f8e4dade428f76f4a Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 18 Dec 2013 15:14:56 -0500 Subject: [PATCH 10/14] Sort out issues with servo vs. motor sliders... finally figure out what wizardIndexes are! per OutputCalibrationPage::setWizardPage() --- .../pages/outputcalibrationpage.cpp | 4 ++-- .../setupwizard/vehicleconfigurationhelper.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index f39db1abe..d720f6118 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -147,7 +147,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1; + m_wizardIndexes << 0 << 1 << 2 << 2 << 2 << 2; // These come from OutputCalibrationPage::setWizardPage() m_vehicleElementIds << "fixed-aileron" << "aileron"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4; @@ -179,7 +179,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 1 << 1; + m_wizardIndexes << 0 << 2 << 2 << 2; // These come from OutputCalibrationPage::setWizardPage() m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index d32d0146a..5de6ae900 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -306,7 +306,23 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() addModifiedObject(actSettings, tr("Writing actuator settings")); break; } +/* case VehicleConfigurationSource::VEHICLE_FIXEDWING: + { + ActuatorSettings::DataFields data = actSettings->getData(); + + qDebug() << "Override center pulse for fixed wing servos\n"; + // move all but first chan to 1500 center pluse + QList actuatorSettings = m_configSource->getActuatorSettings(); + for (quint16 i = 1; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) { + data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM; + data.ChannelAddr[i] = i; + data.ChannelMin[i] = 1500; + data.ChannelNeutral[i] = 1500; + data.ChannelMax[i] = 1500; + } + } +*/ case VehicleConfigurationSource::VEHICLE_HELI: case VehicleConfigurationSource::VEHICLE_SURFACE: // TODO: Implement settings for other vehicle types? @@ -1388,5 +1404,5 @@ void VehicleConfigurationHelper::setupAileron() guiSettings.fixedwing.FixedWingYaw1 = 5; applyMixerConfiguration(channels); - applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWINGAILERON, guiSettings); + applyMultiGUISettings(SystemSettings::AIRFRAMETYPE_FIXEDWING, guiSettings); } From 33d963d24e42964e83a93a651f291869296c1bc5 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 18 Dec 2013 16:41:38 -0500 Subject: [PATCH 11/14] prepping to fix refreshWidgetsValues() so that Output & Vehicle screens populate properly after wizard is run. --- .../configfixedwingwidget.cpp | 29 ++++++++++--------- .../pages/outputcalibrationpage.cpp | 4 +-- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 71861c2c4..72eaf436c 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -53,27 +53,28 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions() // get the gui config data GUIConfigDataUnion configData = getConfigData(); + fixedGUISettingsStruct fixed = configData.fixedwing; - if (configData.fixedwing.FixedWingPitch1 > 0) { - channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); + if (fixed.FixedWingThrottle > 0 && fixed.FixedWingThrottle <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingThrottle - 1] = QString("fixed.WingThrottle"); } - if (configData.fixedwing.FixedWingPitch2 > 0) { - channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2"); + if (fixed.FixedWingPitch1 > 0 && fixed.FixedWingPitch1 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); } - if (configData.fixedwing.FixedWingRoll1 > 0) { - channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1"); + if (fixed.FixedWingPitch2 > 0 && fixed.FixedWingPitch2 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingPitch2 - 1] = QString("FixedWingPitch2"); } - if (configData.fixedwing.FixedWingRoll2 > 0) { - channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2"); + if (fixed.FixedWingRoll1 > 0 && fixed.FixedWingRoll1 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingRoll1 - 1] = QString("FixedWingRoll1"); } - if (configData.fixedwing.FixedWingYaw1 > 0) { - channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1"); + if (fixed.FixedWingRoll2 > 0 && fixed.FixedWingRoll2 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingRoll2 - 1] = QString("FixedWingRoll2"); } - if (configData.fixedwing.FixedWingYaw2 > 0) { - channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2"); + if (fixed.FixedWingYaw1 > 0 && fixed.FixedWingYaw1 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingYaw1 - 1] = QString("FixedWingYaw1"); } - if (configData.fixedwing.FixedWingThrottle > 0) { - channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle"); + if (fixed.FixedWingYaw2 > 0 && fixed.FixedWingYaw2 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { + channelDesc[fixed.FixedWingYaw2 - 1] = QString("FixedWingYaw2"); } return channelDesc; } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index d720f6118..edb4419c9 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -147,7 +147,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 1 << 2 << 2 << 2 << 2; // These come from OutputCalibrationPage::setWizardPage() + m_wizardIndexes << 0 << 1 << 3 << 3 << 3 << 3; // These come from OutputCalibrationPage::setWizardPage() m_vehicleElementIds << "fixed-aileron" << "aileron"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4; @@ -179,7 +179,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 2 << 2 << 2; // These come from OutputCalibrationPage::setWizardPage() + m_wizardIndexes << 0 << 0 << 3 << 3; // These come from OutputCalibrationPage::setWizardPage() m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2; From de9a30e4242e7656bdc23b48adb66eddd32987b2 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 18 Dec 2013 17:16:12 -0500 Subject: [PATCH 12/14] prepping to fix refreshWidgetValues(0 all the setComboCurrentIndex() calls are missing. --- .../cfg_vehicletypes/configfixedwingwidget.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 72eaf436c..24f93339a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -56,7 +56,7 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions() fixedGUISettingsStruct fixed = configData.fixedwing; if (fixed.FixedWingThrottle > 0 && fixed.FixedWingThrottle <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { - channelDesc[fixed.FixedWingThrottle - 1] = QString("fixed.WingThrottle"); + channelDesc[fixed.FixedWingThrottle - 1] = QString("WingThrottle"); } if (fixed.FixedWingPitch1 > 0 && fixed.FixedWingPitch1 <= ConfigFixedWingWidget::CHANNEL_NUMELEM) { channelDesc[fixed.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); @@ -91,10 +91,13 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : m_aircraft->fixedWingType->addItems(fixedWingTypes); // Set default model to "Elevator aileron rudder" - connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); - setupUI(m_aircraft->fixedWingType->currentText()); + // setupUI(m_aircraft->fixedWingType->currentText()); + + connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); + + updateEnableControls(); } ConfigFixedWingWidget::~ConfigFixedWingWidget() @@ -108,9 +111,12 @@ ConfigFixedWingWidget::~ConfigFixedWingWidget() void ConfigFixedWingWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); + Q_ASSERT(plane); // This had to be moved from ConfigFixedWingWidget() here since m_aircraft->fixedWingType->currentText() // did not seem to work properly to choose alternate .svg files. + m_aircraft->planeShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_aircraft->planeShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); plane = new QGraphicsSvgItem(); @@ -161,6 +167,9 @@ void ConfigFixedWingWidget::setupUI(QString frameType) scene->setSceneRect(plane->boundingRect()); m_aircraft->planeShape->setScene(scene); + setupEnabledControls(frameType); + // Draw the appropriate airframe + updateAirframe(frameType); } void ConfigFixedWingWidget::setupEnabledControls(QString frameType) From 6ee5baa1467452f5980b2defb11b27dc6b41e283 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Wed, 18 Dec 2013 17:28:25 -0500 Subject: [PATCH 13/14] I was aparantly missing a call to updateAirframe(frameType); --- .../cfg_vehicletypes/configfixedwingwidget.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 24f93339a..a621d1d8a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -268,6 +268,8 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); } } + + updateAirframe(frameType); } /** @@ -275,20 +277,15 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) */ 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" + QString airframeType; + if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder") { airframeType = "FixedWing"; setupFrameFixedWing(airframeType); @@ -296,6 +293,9 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() airframeType = "FixedWingVtail"; setupFrameVtail(airframeType); } + + // Remove Feed Forward, it is pointless on a plane: + setMixerValue(mixer, "FeedForward", 0.0); return airframeType; } From 3862c9cfaa04849479fd3cca250a062694a0fe40 Mon Sep 17 00:00:00 2001 From: Kevin Finisterre Date: Fri, 20 Dec 2013 02:08:08 -0500 Subject: [PATCH 14/14] settings still not saving to the board... trying to sort it out. Making sure all necessary codepaths exist in the FixedWing clone of the MultiRotor code for the Wizard. --- .../configfixedwingwidget.cpp | 114 ++++++++++++++++-- .../cfg_vehicletypes/configfixedwingwidget.h | 2 + .../pages/outputcalibrationpage.cpp | 2 +- 3 files changed, 110 insertions(+), 8 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index a621d1d8a..07ba0a4ba 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,6 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : // setupUI(m_aircraft->fixedWingType->currentText()); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); - updateEnableControls(); } @@ -105,9 +105,6 @@ ConfigFixedWingWidget::~ConfigFixedWingWidget() delete m_aircraft; } -/** - Virtual function to setup the UI - */ void ConfigFixedWingWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); @@ -273,7 +270,7 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) } /** - Virtual function to update the UI widget objects + Helper function to update the UI widget objects */ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() { @@ -281,17 +278,51 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() Q_ASSERT(mixer); - // Set the throttle curve + // Curve is also common to all quads: setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve()); QString airframeType; + QList motor_servo_List; if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder") { airframeType = "FixedWing"; setupFrameFixedWing(airframeType); - } else if (m_aircraft->fixedWingType->currentText() == "vtail") { + + motor_servo_List << "FixedWingThrottle" << "FixedWingPitch1" << "FixedWingPitch2" << "FixedWingRoll1" << "FixedWingRoll2" << "FixedWingYaw1" << "FixedWingYaw2"; + setupMotors(motor_servo_List); + + GUIConfigDataUnion config = getConfigData(); + setConfigData(config); + + m_aircraft->fwStatusLabel->setText(tr("Configuration OK")); + + } + else if (m_aircraft->fixedWingType->currentText() == "vtail") { airframeType = "FixedWingVtail"; setupFrameVtail(airframeType); + + motor_servo_List << "FixedWingThrottle" << "FixedWingRoll1" << "FixedWingRoll2"; + setupMotors(motor_servo_List); + + GUIConfigDataUnion config = getConfigData(); + setConfigData(config); + + // Vtail Layout: + // pitch roll yaw + double mixerMatrix[8][3] = { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } + }; + setupFixedWingMixer(mixerMatrix); + + m_aircraft->fwStatusLabel->setText(tr("Configuration OK")); + } // Remove Feed Forward, it is pointless on a plane: @@ -300,6 +331,39 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() return airframeType; } +void ConfigFixedWingWidget::setupMotors(QList motorList) +{ + QList mmList; + mmList << m_aircraft->fwEngineChannelBox << m_aircraft->fwAileron1ChannelBox + << m_aircraft->fwAileron2ChannelBox << m_aircraft->fwElevator1ChannelBox + << m_aircraft->fwElevator2ChannelBox << m_aircraft->fwRudder1ChannelBox + << m_aircraft->fwRudder2ChannelBox; + + GUIConfigDataUnion configData = getConfigData(); + resetActuators(&configData); + + foreach(QString motor, motorList) { + int index = mmList.takeFirst()->currentIndex(); + + if (motor == QString("FixedWingThrottle")) { + configData.fixedwing.FixedWingThrottle = index; + } else if (motor == QString("FixedWingPitch1")) { + configData.fixedwing.FixedWingPitch1 = index; + } else if (motor == QString("FixedWingPitch2")) { + configData.fixedwing.FixedWingPitch2 = index; + } else if (motor == QString("FixedWingRoll1")) { + configData.fixedwing.FixedWingRoll1 = index; + } else if (motor == QString("FixedWingRoll2")) { + configData.fixedwing.FixedWingRoll2 = index; + } else if (motor == QString("FixedWingYaw1")) { + configData.fixedwing.FixedWingYaw1 = index; + } else if (motor == QString("FixedWingYaw2")) { + configData.fixedwing.FixedWingYaw1 = index; + } + } + setConfigData(configData); +} + void ConfigFixedWingWidget::updateAirframe(QString frameType) { qDebug() << "ConfigFixedWingWidget::updateAirframe - frame type" << frameType; @@ -334,6 +398,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); + config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); setConfigData(config); @@ -464,6 +529,41 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) return true; } +/** + This function sets up the vtail fixed wing mixer values. + */ +bool ConfigFixedWingWidget::setupFixedWingMixer(double mixerFactors[8][3]) +{ + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + + Q_ASSERT(mixer); + resetMotorAndServoMixers(mixer); + + // and enable only the relevant channels: +// double pFactor = (double)m_aircraft->fwPitchMixLevel->value() / 100.0; +// double rFactor = (double)m_aircraft->fwRollMixLevel->value() / 100.0; + //invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked(); +// double yFactor = (double)m_aircraft->fwYawMixLevel->value() / 100.0; + + QList mmList; + mmList << m_aircraft->fwEngineChannelBox << m_aircraft->fwAileron1ChannelBox + << m_aircraft->fwAileron2ChannelBox << m_aircraft->fwElevator1ChannelBox + << m_aircraft->fwElevator2ChannelBox << m_aircraft->fwRudder1ChannelBox + << m_aircraft->fwRudder2ChannelBox; + + for (int i = 0; i < 8; i++) { + if (mmList.at(i)->isEnabled()) { + int channel = mmList.at(i)->currentIndex() - 1; + if (channel > -1) { + qDebug() << "code needs to be written here!"; +// 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. */ diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 28126fc26..6c6bc7bab 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -68,6 +68,8 @@ private: bool setupFrameFixedWing(QString airframeType); bool setupFrameVtail(QString airframeType); + bool setupFixedWingMixer(double mixerFactors[8][3]); + void setupMotors(QList motorList); void updateAirframe(QString multiRotorType); void setupEnabledControls(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index edb4419c9..c469fa2cc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -179,7 +179,7 @@ void OutputCalibrationPage::setupVehicle() ui->vehicleView->setScene(m_vehicleScene); } qDebug() << "no clue what a wizard index is!"; - m_wizardIndexes << 0 << 0 << 3 << 3; // These come from OutputCalibrationPage::setWizardPage() + m_wizardIndexes << 0 << 1 << 3 << 3; // These come from OutputCalibrationPage::setWizardPage() m_vehicleElementIds << "fixed-vtail" << "vtail"; m_vehicleHighlightElementIndexes << 0 << 1; m_channelIndex << 0 << 0 << 1 << 2;