diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp index 3c7834e2d..4bc0db2b8 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.cpp @@ -26,109 +26,44 @@ */ #include "airspeedpage.h" -#include "ui_airspeed.h" #include "setupwizard.h" AirSpeedPage::AirSpeedPage(SetupWizard *wizard, QWidget *parent) : - AbstractWizardPage(wizard, parent), - ui(new Ui::AirSpeedPage) -{ - ui->setupUi(this); - QSvgRenderer *renderer = new QSvgRenderer(); - renderer->load(QString(":/configgadget/images/fixedwing-shapes.svg")); - m_airspeedPic = new QGraphicsSvgItem(); - m_airspeedPic->setSharedRenderer(renderer); - QGraphicsScene *scene = new QGraphicsScene(this); - scene->addItem(m_airspeedPic); - ui->typeGraphicsView->setScene(scene); - - setupAirSpeedPageTypesCombo(); - - // Default to Software Estimation - connect(ui->typeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImageAndDescription())); - ui->typeCombo->setCurrentIndex(0); -} + SelectionPage(wizard, QString(":/setupwizard/resources/fixedwing-shapes-wizard-no-numbers.svg"), parent) +{} AirSpeedPage::~AirSpeedPage() -{ - delete ui; -} +{} -void AirSpeedPage::initializePage() +bool AirSpeedPage::validatePage(SelectionItem *seletedItem) { - updateAvailableTypes(); - updateImageAndDescription(); -} - -// TODO -bool AirSpeedPage::validatePage() -{ - SetupWizard::VEHICLE_SUB_TYPE type = (SetupWizard::VEHICLE_SUB_TYPE)ui->typeCombo->itemData(ui->typeCombo->currentIndex()).toInt(); - - getWizard()->setVehicleSubType(type); + getWizard()->setAirspeedType((SetupWizard::AIRSPEED_TYPE)seletedItem->id()); return true; } -void AirSpeedPage::fitInView() +void AirSpeedPage::setupSelection(Selection *selection) { - if (m_airspeedPic) { - ui->typeGraphicsView->setSceneRect(m_airspeedPic->boundingRect()); - ui->typeGraphicsView->fitInView(m_airspeedPic, Qt::KeepAspectRatio); - } -} - -void AirSpeedPage::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - fitInView(); -} - -void AirSpeedPage::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - fitInView(); -} - -// TODO -void AirSpeedPage::setupAirSpeedPageTypesCombo() -{ - ui->typeCombo->addItem(tr("Aileron Dual Servos"), SetupWizard::FIXED_WING_DUAL_AILERON); - m_descriptions << tr("This setup expects a traditional airframe using two independent aileron servos on their own channel (not connected by Y adapter) plus an elevator and a rudder. "); - - ui->typeCombo->addItem(tr("Aileron Single Servo"), SetupWizard::FIXED_WING_AILERON); - m_descriptions << tr("This setup expects a traditional airframe using a single alieron servo or two servos connected by a Y adapter plus an elevator and a rudder. "); - - ui->typeCombo->addItem(tr("Elevon"), SetupWizard::FIXED_WING_ELEVON); - 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 AirSpeedPage::updateAvailableTypes() -{} - -// TODO -void AirSpeedPage::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_DUAL_AILERON: - elementId = "aileron"; - break; - case SetupWizard::FIXED_WING_AILERON: - elementId = "aileron-single"; - break; - case SetupWizard::FIXED_WING_ELEVON: - elementId = "elevon"; - break; - default: - elementId = ""; - break; - } - m_airspeedPic->setElementId(elementId); - ui->typeGraphicsView->setSceneRect(m_airspeedPic->boundingRect()); - ui->typeGraphicsView->fitInView(m_airspeedPic, Qt::KeepAspectRatio); - - ui->typeDescription->setText(description); + selection->setTitle(tr("OpenPilot Airspeed Sensor Selection")); + selection->setText(tr("This part of the wizard will help you select and configure " + "flying aircraft utilizing servos. The wizard supports the most common types of fixed-wing " + "aircraft, other variants of fixed-wing aircraft can be configured by using custom " + "configuration options in the Configuration plugin in the GCS.\n\n" + "Please select the type of fixed-wing you want to create a configuration for below:")); + selection->addItem(tr("Estimated"), + tr("This setup expects a traditional airframe using two independent aileron servos " + "on their own channel (not connected by Y adapter) plus an elevator and a rudder."), + "aileron", + SetupWizard::ESTIMATE); + + selection->addItem(tr("EagleTree"), + tr("This setup expects a traditional airframe using a single alieron servo or two servos " + "connected by a Y adapter plus an elevator and a rudder."), + "aileron-single", + SetupWizard::EAGLETREE); + + selection->addItem(tr("MS4525 Based"), + 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."), + "elevon", + SetupWizard::MS4525); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.h index 0e3940c67..9b72c967b 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.h @@ -28,40 +28,18 @@ #ifndef AIRSPEEDPAGE_H #define AIRSPEEDPAGE_H -#include -#include -#include +#include "selectionpage.h" -#include "abstractwizardpage.h" - -namespace Ui { -class AirSpeedPage; -} - -class AirSpeedPage : public AbstractWizardPage { +class AirSpeedPage : public SelectionPage { Q_OBJECT public: explicit AirSpeedPage(SetupWizard *wizard, QWidget *parent = 0); ~AirSpeedPage(); - void initializePage(); - bool validatePage(); - - void fitInView(); -protected: - void resizeEvent(QResizeEvent *event); - void showEvent(QShowEvent *event); - -private: - Ui::AirSpeedPage *ui; - void setupAirSpeedPageTypesCombo(); - QGraphicsSvgItem *m_fixedwingPic; - void updateAvailableTypes(); - QList m_descriptions; - -private slots: - void updateImageAndDescription(); +public: + bool validatePage(SelectionItem *seletedItem); + void setupSelection(Selection *selection); }; #endif // AIRSPEEDPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.ui deleted file mode 100644 index 824124bf3..000000000 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airspeedpage.ui +++ /dev/null @@ -1,164 +0,0 @@ - - - FixedWingPage - - - - 0 - 0 - 600 - 400 - - - - WizardPage - - - - - - <!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 align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">OpenPilot Airspeed Sensor 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 an airspeed sensor also commonly called a Pitot tube. The OpenPilot Platform supports multiple types of hardware airspeed sensors as well as an advanced software based wind speed estimation algorthym which requires no additional hardware although this is slightly less accurate than using a dedicated hardware sensor. </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 airspeed sensor you wish to use below:</span></p></body></html> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - 4 - - - - - - - 4 - - - - - - 125 - 36 - - - - - 10 - 50 - false - - - - Airspeed 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/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index 4598f02f9..408f923fe 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -32,6 +32,7 @@ #include "pages/vehiclepage.h" #include "pages/multipage.h" #include "pages/fixedwingpage.h" +#include "pages/airspeedpage.h" #include "pages/helipage.h" #include "pages/surfacepage.h" #include "pages/inputpage.h" @@ -147,7 +148,7 @@ int SetupWizard::nextId() const { switch (getVehicleType()) { case VEHICLE_FIXEDWING: - return PAGE_AIRFRAMESTAB_FIXEDWING; + return PAGE_AIRSPEED; // TODO: Pages for Multi and heli case VEHICLE_MULTI: @@ -158,6 +159,9 @@ int SetupWizard::nextId() const } } + case PAGE_AIRSPEED: + return PAGE_AIRFRAMESTAB_FIXEDWING; + case PAGE_AIRFRAMESTAB_FIXEDWING: return PAGE_SAVE; @@ -355,6 +359,7 @@ void SetupWizard::createPages() setPage(PAGE_VEHICLES, new VehiclePage(this)); setPage(PAGE_MULTI, new MultiPage(this)); setPage(PAGE_FIXEDWING, new FixedWingPage(this)); + setPage(PAGE_AIRSPEED, new AirSpeedPage(this)); setPage(PAGE_HELI, new HeliPage(this)); setPage(PAGE_SURFACE, new SurfacePage(this)); setPage(PAGE_INPUT, new InputPage(this)); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h index b19323559..3ef48ee5f 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.h @@ -96,6 +96,16 @@ public: return m_servoType; } + void setAirspeedType(SetupWizard::AIRSPEED_TYPE setting) + { + m_airspeedType = setting; + } + SetupWizard::AIRSPEED_TYPE getAirspeedType() const + { + return m_airspeedType; + } + + void setGPSSetting(SetupWizard::GPS_SETTING setting) { m_gpsSetting = setting; @@ -165,7 +175,7 @@ private slots: void pageChanged(int currId); private: enum { PAGE_START, PAGE_CONTROLLER, PAGE_VEHICLES, PAGE_MULTI, PAGE_FIXEDWING, - PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_ESC, PAGE_SERVO, + PAGE_AIRSPEED, PAGE_HELI, PAGE_SURFACE, PAGE_INPUT, PAGE_ESC, PAGE_SERVO, PAGE_BIAS_CALIBRATION, PAGE_REVO_CALIBRATION, PAGE_OUTPUT_CALIBRATION, PAGE_SAVE, PAGE_SUMMARY, PAGE_NOTYETIMPLEMENTED, PAGE_AIRFRAMESTAB_FIXEDWING, PAGE_REBOOT, PAGE_END, PAGE_UPDATE }; @@ -179,7 +189,7 @@ private: INPUT_TYPE m_inputType; ESC_TYPE m_escType; SERVO_TYPE m_servoType; - + AIRSPEED_TYPE m_airspeedType; GPS_SETTING m_gpsSetting; RADIO_SETTING m_radioSetting; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index cc307a868..ae895118a 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -19,6 +19,7 @@ HEADERS += setupwizardplugin.h \ pages/notyetimplementedpage.h \ pages/multipage.h \ pages/fixedwingpage.h \ + pages/airspeedpage.h \ pages/helipage.h \ pages/surfacepage.h \ pages/abstractwizardpage.h \ @@ -49,6 +50,7 @@ SOURCES += setupwizardplugin.cpp \ pages/notyetimplementedpage.cpp \ pages/multipage.cpp \ pages/fixedwingpage.cpp \ + pages/airspeedpage.cpp \ pages/helipage.cpp \ pages/surfacepage.cpp \ pages/abstractwizardpage.cpp \ diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h index f666a1d35..c42fbe6a8 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -64,8 +64,8 @@ public: enum ESC_TYPE { ESC_RAPID, ESC_STANDARD, ESC_UNKNOWN }; enum SERVO_TYPE { SERVO_ANALOG, SERVO_DIGITAL, SERVO_UNKNOWN }; enum INPUT_TYPE { INPUT_PWM, INPUT_PPM, INPUT_SBUS, INPUT_DSMX10, INPUT_DSMX11, INPUT_DSM2, INPUT_UNKNOWN }; - - enum GPS_SETTING { GPS_UBX, GPS_NMEA, GPS_DISABLED }; + enum AIRSPEED_TYPE { ESTIMATE, EAGLETREE, MS4525 }; + enum GPS_SETTING { GPS_PLAT, GPS_UBX, GPS_NMEA, GPS_DISABLED }; enum RADIO_SETTING { RADIO_TELEMETRY, RADIO_DISABLED }; virtual VehicleConfigurationSource::CONTROLLER_TYPE getControllerType() const = 0; @@ -74,7 +74,7 @@ public: virtual VehicleConfigurationSource::INPUT_TYPE getInputType() const = 0; virtual VehicleConfigurationSource::ESC_TYPE getEscType() const = 0; virtual VehicleConfigurationSource::SERVO_TYPE getServoType() const = 0; - + virtual VehicleConfigurationSource::AIRSPEED_TYPE getAirspeedType() const = 0; virtual VehicleConfigurationSource::GPS_SETTING getGPSSetting() const = 0; virtual VehicleConfigurationSource::RADIO_SETTING getRadioSetting() const = 0;