From 53547239286128e92e17f3c6e31356098601d949 Mon Sep 17 00:00:00 2001 From: m_thread Date: Mon, 18 Aug 2014 01:20:31 +0200 Subject: [PATCH] OP-1222 Renamed some files. Fixed Wing wizard made only available on Revo Moved motor for fixed wing to channel 3 since channel 3 got its own timer. Fixed a crash in config plugin when selecting Fixed Wing. Added code in outputcalibration in Fixed Wing setup to set min and max values as well as neutral for servos. Added Controller type Nano. --- .../configfixedwingwidget.cpp | 60 +++++---- ...wing.cpp => airframestabfixedwingpage.cpp} | 14 +- ...ixedwing.h => airframestabfixedwingpage.h} | 20 +-- ...edwing.ui => airframestabfixedwingpage.ui} | 8 +- .../pages/outputcalibrationpage.cpp | 122 +++++++----------- .../setupwizard/pages/outputcalibrationpage.h | 1 + .../pages/outputcalibrationpage.ui | 44 +++---- ...efixedwing.cpp => outputfixedwingpage.cpp} | 15 +-- ...tpagefixedwing.h => outputfixedwingpage.h} | 18 +-- ...agefixedwing.ui => outputfixedwingpage.ui} | 4 +- .../plugins/setupwizard/pages/vehiclepage.cpp | 6 + .../plugins/setupwizard/pages/vehiclepage.h | 1 + .../src/plugins/setupwizard/setupwizard.cpp | 8 +- .../src/plugins/setupwizard/setupwizard.pro | 12 +- .../vehicleconfigurationhelper.cpp | 55 ++++---- .../setupwizard/vehicleconfigurationsource.h | 2 +- 16 files changed, 180 insertions(+), 210 deletions(-) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{airframestabfixedwing.cpp => airframestabfixedwingpage.cpp} (75%) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{airframestabfixedwing.h => airframestabfixedwingpage.h} (71%) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{airframestabfixedwing.ui => airframestabfixedwingpage.ui} (93%) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{outputpagefixedwing.cpp => outputfixedwingpage.cpp} (82%) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{outputpagefixedwing.h => outputfixedwingpage.h} (77%) rename ground/openpilotgcs/src/plugins/setupwizard/pages/{outputpagefixedwing.ui => outputfixedwingpage.ui} (98%) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 2fc27cd51..47b8d050a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -43,6 +43,33 @@ const QString ConfigFixedWingWidget::CHANNELBOXNAME = QString("fixedWingChannelBox"); +ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget()), + plane(NULL) +{ + m_aircraft->setupUi(this); + + plane = new QGraphicsSvgItem(); + populateChannelComboBoxes(); + + QStringList fixedWingTypes; + fixedWingTypes << "Elevator aileron rudder" << "Elevon"; + m_aircraft->fixedWingType->addItems(fixedWingTypes); + + // Set default model to "Elevator aileron rudder" + m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); + + setupUI(m_aircraft->fixedWingType->currentText()); + + connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); + updateEnableControls(); +} + +ConfigFixedWingWidget::~ConfigFixedWingWidget() +{ + delete m_aircraft; +} + QStringList ConfigFixedWingWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults @@ -80,31 +107,6 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions() return channelDesc; } -ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : - VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget()) -{ - m_aircraft->setupUi(this); - - populateChannelComboBoxes(); - - QStringList fixedWingTypes; - fixedWingTypes << "Elevator aileron rudder" << "Elevon"; - m_aircraft->fixedWingType->addItems(fixedWingTypes); - - // Set default model to "Elevator aileron rudder" - m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); - - //setupUI(m_aircraft->fixedWingType->currentText()); - - connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); - updateEnableControls(); -} - -ConfigFixedWingWidget::~ConfigFixedWingWidget() -{ - delete m_aircraft; -} - void ConfigFixedWingWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); @@ -633,15 +635,10 @@ 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. + Q_ASSERT(plane); m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio); } @@ -651,6 +648,7 @@ void ConfigFixedWingWidget::showEvent(QShowEvent *event) void ConfigFixedWingWidget::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); + Q_ASSERT(plane); m_aircraft->planeShape->fitInView(plane, Qt::KeepAspectRatio); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.cpp similarity index 75% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.cpp rename to ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.cpp index ae78d9254..c2d5eebaf 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.cpp @@ -1,11 +1,11 @@ /** ****************************************************************************** * - * @file notyetimplementedpage.cpp + * @file airframestabfixedwingpage.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup * @{ - * @addtogroup NotYetImplementedPage + * @addtogroup AirframeStabFixedwingPage * @{ * @brief *****************************************************************************/ @@ -25,18 +25,18 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "airframestabfixedwing.h" -#include "ui_airframestabfixedwing.h" +#include "airframestabfixedwingpage.h" +#include "ui_airframestabfixedwingpage.h" -AirframeStabFixedwing::AirframeStabFixedwing(SetupWizard *wizard, QWidget *parent) : +AirframeStabFixedwingPage::AirframeStabFixedwingPage(SetupWizard *wizard, QWidget *parent) : AbstractWizardPage(wizard, parent), - ui(new Ui::AirframeStabFixedwing) + ui(new Ui::AirframeStabFixedwingPage) { ui->setupUi(this); setFinalPage(true); } -AirframeStabFixedwing::~AirframeStabFixedwing() +AirframeStabFixedwingPage::~AirframeStabFixedwingPage() { delete ui; } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.h similarity index 71% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.h rename to ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.h index 641927b7d..4a6dae8dc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.h @@ -1,11 +1,11 @@ /** ****************************************************************************** * - * @file notyetimplementedpage.h + * @file airframestabfixedwingpage.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup * @{ - * @addtogroup NotYetImplementedPage + * @addtogroup AirframeStabFixedwingPage * @{ * @brief *****************************************************************************/ @@ -25,24 +25,24 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef AIRFRAMESTABFIXEDWING_H -#define AIRFRAMESTABFIXEDWING_H +#ifndef AIRFRAMESTABFIXEDWINGPAGE_H +#define AIRFRAMESTABFIXEDWINGPAGE_H #include "abstractwizardpage.h" namespace Ui { -class AirframeStabFixedwing; +class AirframeStabFixedwingPage; } -class AirframeStabFixedwing : public AbstractWizardPage { +class AirframeStabFixedwingPage : public AbstractWizardPage { Q_OBJECT public: - explicit AirframeStabFixedwing(SetupWizard *wizard, QWidget *parent = 0); - ~AirframeStabFixedwing(); + explicit AirframeStabFixedwingPage(SetupWizard *wizard, QWidget *parent = 0); + ~AirframeStabFixedwingPage(); private: - Ui::AirframeStabFixedwing *ui; + Ui::AirframeStabFixedwingPage *ui; }; -#endif // AIRFRAMESTABFIXEDWING_H +#endif // AIRFRAMESTABFIXEDWINGPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.ui similarity index 93% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.ui rename to ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.ui index 582c76ef4..31e672b1f 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwing.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/airframestabfixedwingpage.ui @@ -1,7 +1,7 @@ - AirframeStabFixedwing - + AirframeStabFixedwingPage + 0 @@ -17,9 +17,9 @@ 20 - 170 + 130 551 - 51 + 191 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index d724f6076..4d9c74930 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -64,6 +64,33 @@ void OutputCalibrationPage::loadSVGFile(QString file) } } +void OutputCalibrationPage::setupActuatorMinMaxAndNeutral(int motorChannelStart, int motorChannelEnd, int totalUsedChannels) +{ + // Default values for the actuator settings, extra important for + // servos since a value out of range can actually destroy the + // vehicle if unlucky. + // Motors are not that important. REMOVE propellers always!! + + for (int servoid = 0; servoid < 12; servoid++) { + if (servoid >= motorChannelStart && servoid <= motorChannelEnd) { + // Set to motor safe values + m_actuatorSettings[servoid].channelMin = 1000; + m_actuatorSettings[servoid].channelNeutral = 1000; + m_actuatorSettings[servoid].channelMax = 2000; + } else if (servoid < totalUsedChannels) { + // Set to servo safe values + m_actuatorSettings[servoid].channelMin = 1500; + m_actuatorSettings[servoid].channelNeutral = 1500; + m_actuatorSettings[servoid].channelMax = 1500; + } else { + // "Disable" these channels + m_actuatorSettings[servoid].channelMin = 1000; + m_actuatorSettings[servoid].channelNeutral = 1000; + m_actuatorSettings[servoid].channelMax = 1000; + } + } +} + void OutputCalibrationPage::setupVehicle() { m_actuatorSettings = getWizard()->getActuatorSettings(); @@ -93,13 +120,8 @@ void OutputCalibrationPage::setupVehicle() // The channel number to configure for each step. m_channelIndex << 0 << 0 << 1 << 2 << 3 << 3 << 3; - // Default values for the actuator settings, extra important for - // servos since a value out of range can actually destroy the - // vehicle if unlucky. - // Motors are not that important. REMOVE propellers always!! - m_actuatorSettings[3].channelMin = 1500; - m_actuatorSettings[3].channelNeutral = 1500; - m_actuatorSettings[3].channelMax = 1500; + setupActuatorMinMaxAndNeutral(0, 1, 3); + getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::MULTI_ROTOR_QUAD_X: @@ -108,6 +130,7 @@ void OutputCalibrationPage::setupVehicle() 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; + setupActuatorMinMaxAndNeutral(0, 3, 4); break; case SetupWizard::MULTI_ROTOR_QUAD_PLUS: loadSVGFile(MULTI_SVG_FILE); @@ -115,6 +138,7 @@ void OutputCalibrationPage::setupVehicle() 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; + setupActuatorMinMaxAndNeutral(0, 3, 4); break; case SetupWizard::MULTI_ROTOR_HEXA: loadSVGFile(MULTI_SVG_FILE); @@ -122,6 +146,7 @@ void OutputCalibrationPage::setupVehicle() 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; + setupActuatorMinMaxAndNeutral(0, 5, 6); break; case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: loadSVGFile(MULTI_SVG_FILE); @@ -129,6 +154,7 @@ void OutputCalibrationPage::setupVehicle() 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; + setupActuatorMinMaxAndNeutral(0, 5, 6); break; case SetupWizard::MULTI_ROTOR_HEXA_H: loadSVGFile(MULTI_SVG_FILE); @@ -136,92 +162,35 @@ void OutputCalibrationPage::setupVehicle() 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; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + setupActuatorMinMaxAndNeutral(0, 5, 6); break; case SetupWizard::MULTI_ROTOR_HEXA_X: m_wizardIndexes << 0 << 1 << 1 << 1 << 1 << 1 << 1; m_vehicleElementIds << "hexa-x" << "hexa-x-frame" << "hexa-x-m1" << "hexa-x-m2" << "hexa-x-m3" << "hexa-x-m4" << "hexa-x-m5" << "hexa-x-m6"; m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5 << 6; m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4 << 5; + setupActuatorMinMaxAndNeutral(0, 5, 6); break; // Fixed Wing case SetupWizard::FIXED_WING_AILERON: loadSVGFile(FIXEDWING_SVG_FILE); - m_wizardIndexes << 0 << 1 << 2 << 2 << 2 << 2; //2 for servoCenterSlider! + m_wizardIndexes << 0 << 1 << 2 << 3 << 4 << 2 << 3 << 4 << 2 << 3 << 4 << 2 << 3 << 4; m_vehicleElementIds << "aileron" << "aileron-frame" << "aileron-motor" << "aileron-ail-left" << "aileron-ail-right" << "aileron-rudder" << "aileron-elevator"; - m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3 << 4 << 5; - m_channelIndex << 0 << 0 << 1 << 2 << 3 << 4; + m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 2 << 2 << 3 << 3 << 3 << 4 << 4 << 4 << 5 << 5 << 5; + m_channelIndex << 0 << 3 << 0 << 0 << 0 << 1 << 1 << 1 << 2 << 2 << 2 << 4 << 4 << 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 - // would also be nice to make these all default to 50hz so we don't shred servos. - - m_actuatorSettings[1].channelNeutral = 1500; - // make sure Aileron servo two does not go to an extreme value - m_actuatorSettings[2].channelNeutral = 1500; - // make sure Elevator servo one does not go to an extreme value - m_actuatorSettings[3].channelNeutral = 1500; - // make sure Rudder servo one does not go to an extreme value - m_actuatorSettings[4].channelNeutral = 1500; - m_actuatorSettings[4].channelNeutral = 1500; - m_actuatorSettings[5].channelNeutral = 1500; - m_actuatorSettings[6].channelNeutral = 1500; - m_actuatorSettings[7].channelNeutral = 1500; - - // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach, - // 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU - // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg - m_actuatorSettings[1].channelMin = 554; - m_actuatorSettings[1].channelMax = 2400; - m_actuatorSettings[2].channelMin = 554; - m_actuatorSettings[2].channelMax = 2400; - m_actuatorSettings[3].channelMin = 554; - m_actuatorSettings[3].channelMax = 2400; - m_actuatorSettings[4].channelMin = 554; - m_actuatorSettings[4].channelMax = 2400; - m_actuatorSettings[5].channelMin = 554; - m_actuatorSettings[5].channelMax = 2400; - m_actuatorSettings[6].channelMin = 554; - m_actuatorSettings[6].channelMax = 2400; - m_actuatorSettings[7].channelMin = 554; - m_actuatorSettings[7].channelMax = 2400; + setupActuatorMinMaxAndNeutral(3, 3, 5); getWizard()->setActuatorSettings(m_actuatorSettings); break; case SetupWizard::FIXED_WING_ELEVON: loadSVGFile(FIXEDWING_SVG_FILE); - m_wizardIndexes << 0 << 1 << 2 << 2; //2 for servoCenterSlider! + m_wizardIndexes << 0 << 1 << 2 << 3 << 4 << 2 << 3 << 4; m_vehicleElementIds << "elevon" << "elevon-frame" << "elevon-motor" << "elevon-left" << "elevon-right"; - m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 3; - m_channelIndex << 0 << 0 << 1 << 2; + m_vehicleHighlightElementIndexes << 0 << 1 << 2 << 2 << 2 << 3 << 3 << 3; + m_channelIndex << 0 << 3 << 0 << 0 << 0 << 1 << 1 << 1; - // make sure elevon servo one does not go to an extreme value - m_actuatorSettings[1].channelNeutral = 1500; - // make sure elevon servo two does not go to an extreme value - m_actuatorSettings[2].channelNeutral = 1500; - m_actuatorSettings[3].channelNeutral = 1500; - m_actuatorSettings[4].channelNeutral = 1500; - m_actuatorSettings[5].channelNeutral = 1500; - m_actuatorSettings[6].channelNeutral = 1500; - m_actuatorSettings[7].channelNeutral = 1500; - - // Arduino library defaults to 554 http://arduino.cc/en/Reference/ServoAttach, - // 600 is for HS85mg - http://www.servocity.com/html/hs-85mg__mighty_micro.html#.U4JEWhapKBU - // Same rules as above from the Arduino *generic* library and the servo city info for the 85mg - m_actuatorSettings[1].channelMin = 554; - m_actuatorSettings[1].channelMax = 2400; - m_actuatorSettings[2].channelMin = 554; - m_actuatorSettings[2].channelMax = 2400; - m_actuatorSettings[3].channelMin = 554; - m_actuatorSettings[3].channelMax = 2400; - m_actuatorSettings[4].channelMin = 554; - m_actuatorSettings[4].channelMax = 2400; - m_actuatorSettings[5].channelMin = 554; - m_actuatorSettings[5].channelMax = 2400; - m_actuatorSettings[6].channelMin = 554; - m_actuatorSettings[6].channelMax = 2400; - m_actuatorSettings[7].channelMin = 554; - m_actuatorSettings[7].channelMax = 2400; + setupActuatorMinMaxAndNeutral(3, 3, 3); getWizard()->setActuatorSettings(m_actuatorSettings); break; @@ -298,7 +267,7 @@ void OutputCalibrationPage::setWizardPage() ui->calibrationStack->setCurrentIndex(currentPageIndex); int currentChannel = getCurrentChannel(); - qDebug() << "Current channel: " << currentChannel+1; + qDebug() << "Current channel: " << currentChannel + 1; if (currentChannel >= 0) { if (currentPageIndex == 1) { ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral); @@ -381,7 +350,8 @@ void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked) { ui->motorNeutralButton->setText(checked ? tr("Stop") : tr("Start")); quint16 channel = getCurrentChannel(); - onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, 1000, ui->motorNeutralSlider); + quint16 safeValue = m_actuatorSettings[channel].channelNeutral; + onStartButtonToggle(ui->motorNeutralButton, channel, m_actuatorSettings[channel].channelNeutral, safeValue, ui->motorNeutralSlider); } void OutputCalibrationPage::onStartButtonToggle(QAbstractButton *button, quint16 channel, quint16 value, quint16 safeValue, QSlider *slider) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h index 0ad5f428f..d851fa639 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h @@ -53,6 +53,7 @@ public: } void loadSVGFile(QString file); + void setupActuatorMinMaxAndNeutral(int motorChannelStart, int motorChannelEnd, int totalUsedChannels); protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui index f80cab6de..e69c67666 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui @@ -34,7 +34,7 @@ - 1 + 4 @@ -72,7 +72,7 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br/>Please pay attention to the details and in particular the motors position and its rotation direction. Ensure the motors are spinning in the correct direction as shown in the diagram. Swap any 2 motor wires to change the direction of a motor. </p><p>To find the neutral rate for this engine, press the Start button below and slide the slider to the right until the engine just starts to spin stable. <br/><br/>When done press button again to stop.</p></body></html> + <html><head/><body><p>In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br/>Please pay attention to the details and in particular the motors position and its rotation direction. Ensure the motors are spinning in the correct direction as shown in the diagram. Swap any 2 motor wires to change the direction of a motor. </p><p>To find <span style=" font-weight:600;">the neutral rate for this engine</span>, press the Start button below and slide the slider to the right until the engine just starts to spin stable. <br/><br/>When done press button again to stop.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -91,13 +91,13 @@ p, li { white-space: pre-wrap; } 1000 - 1300 + 1500 - 10 + 1 - 20 + 10 Qt::Horizontal @@ -133,7 +133,7 @@ p, li { white-space: pre-wrap; } - <html><head/><body><p>This step calibrates the center position of the servo. To set the center position for this servo, press the Start button below and slide the slider to center the servo. </p><p>When done press button again to stop.</p></body></html> + <html><head/><body><p>This step calibrates<span style=" font-weight:600;"> the center position of the servo</span>. To set the center position for this servo, press the Start button below and slide the slider to center the servo. </p><p>When done press button again to stop.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -149,16 +149,16 @@ p, li { white-space: pre-wrap; } false - 1000 + 600 - 2000 + 2400 - 10 + 1 - 20 + 10 1500 @@ -198,12 +198,12 @@ p, li { white-space: pre-wrap; } - + - <html><head/><body><p>To save the servo and other hardware from damage we have to set the max and min angles for the servo. </p><p>To set the minimum angle for the servo, press the Start button below and select the top slider and slide it to the left until min angle is reached.</p><p>When done press button again to stop.</p></body></html> + <html><head/><body><p>To save the servo and other hardware from damage we have to set the max and min angles for the servo. </p><p>To set <span style=" font-weight:600;">the minimum angle for the servo</span>, press the Start button below and select the top slider and slide it to the left until min angle is reached.</p><p>When done press button again to stop.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -219,16 +219,16 @@ p, li { white-space: pre-wrap; } false - 1000 + 600 - 1500 + 2400 - 10 + 1 - 20 + 10 1500 @@ -268,12 +268,12 @@ p, li { white-space: pre-wrap; } - + - <html><head/><body><p>To set the maximum angle for the servo, press the Start button below and select the top slider and slide it to the right until max angle is reached.</p><p>When done press button again to stop.</p></body></html> + <html><head/><body><p>To set <span style=" font-weight:600;">the maximum angle for the servo</span>, press the Start button below and select the top slider and slide it to the right until max angle is reached.</p><p>When done press button again to stop.</p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -289,16 +289,16 @@ p, li { white-space: pre-wrap; } false - 1500 + 600 - 2000 + 2400 - 10 + 1 - 20 + 10 1500 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.cpp similarity index 82% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.cpp rename to ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.cpp index 6999877a7..2977e9606 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.cpp @@ -1,7 +1,7 @@ /** ****************************************************************************** * - * @file outputpage.cpp + * @file outputfixedwingpage.cpp * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup * @{ @@ -25,24 +25,23 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "outputpagefixedwing.h" -#include "ui_outputpagefixedwing.h" +#include "outputfixedwingpage.h" +#include "ui_outputfixedwingpage.h" #include "setupwizard.h" -OutputPageFixedwing::OutputPageFixedwing(SetupWizard *wizard, QWidget *parent) : +OutputFixedwingPage::OutputFixedwingPage(SetupWizard *wizard, QWidget *parent) : AbstractWizardPage(wizard, parent), - - ui(new Ui::OutputPageFixedwing) + ui(new Ui::OutputFixedwingPage) { ui->setupUi(this); } -OutputPageFixedwing::~OutputPageFixedwing() +OutputFixedwingPage::~OutputFixedwingPage() { delete ui; } -bool OutputPageFixedwing::validatePage() +bool OutputFixedwingPage::validatePage() { if (ui->ServoTypeButton->isChecked()) { getWizard()->setActuatorType(SetupWizard::SERVO_DIGITAL); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.h similarity index 77% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.h rename to ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.h index f3494b85b..b68dd4fbc 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.h @@ -1,7 +1,7 @@ /** ****************************************************************************** * - * @file outputpage.h + * @file outputfixedwingpage.h * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. * @addtogroup * @{ @@ -25,25 +25,25 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef OUTPUTPAGEFIXEDWING_H -#define OUTPUTPAGEFIXEDWING_H +#ifndef OUTPUTFIXEDWINGPAGE_H +#define OUTPUTFIXEDWINGPAGE_H #include "abstractwizardpage.h" namespace Ui { -class OutputPageFixedwing; +class OutputFixedwingPage; } -class OutputPageFixedwing : public AbstractWizardPage { +class OutputFixedwingPage : public AbstractWizardPage { Q_OBJECT public: - explicit OutputPageFixedwing(SetupWizard *wizard, QWidget *parent = 0); - ~OutputPageFixedwing(); + explicit OutputFixedwingPage(SetupWizard *wizard, QWidget *parent = 0); + ~OutputFixedwingPage(); bool validatePage(); private: - Ui::OutputPageFixedwing *ui; + Ui::OutputFixedwingPage *ui; }; -#endif // OUTPUTPAGEFIXEDWING_H +#endif // OUTPUTFIXEDWINGPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.ui similarity index 98% rename from ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.ui rename to ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.ui index fb8150ddf..ace236fce 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputpagefixedwing.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputfixedwingpage.ui @@ -1,7 +1,7 @@ - OutputPageFixedwing - + OutputFixedwingPage + 0 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp index b7de92bc9..a8b1780a9 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.cpp @@ -55,3 +55,9 @@ bool VehiclePage::validatePage() } return true; } + +void VehiclePage::initializePage() +{ + ui->fixedwingButton->setEnabled(getWizard()->getControllerType() == SetupWizard::CONTROLLER_REVO || + getWizard()->getControllerType() == SetupWizard::CONTROLLER_NANO); +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h index 737f1fc25..659ac74cd 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/vehiclepage.h @@ -41,6 +41,7 @@ public: explicit VehiclePage(SetupWizard *wizard, QWidget *parent = 0); ~VehiclePage(); bool validatePage(); + void initializePage(); private: Ui::VehiclePage *ui; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp index ec0903ed7..65e12f2ff 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.cpp @@ -36,7 +36,7 @@ #include "pages/surfacepage.h" #include "pages/inputpage.h" #include "pages/outputpage.h" -#include "pages/outputpagefixedwing.h" +#include "pages/outputfixedwingpage.h" #include "pages/biascalibrationpage.h" #include "pages/summarypage.h" #include "pages/savepage.h" @@ -44,7 +44,7 @@ #include "pages/rebootpage.h" #include "pages/outputcalibrationpage.h" #include "pages/revocalibrationpage.h" -#include "pages/airframestabfixedwing.h" +#include "pages/airframestabfixedwingpage.h" #include "extensionsystem/pluginmanager.h" #include "vehicleconfigurationhelper.h" #include "actuatorsettings.h" @@ -345,7 +345,7 @@ void SetupWizard::createPages() setPage(PAGE_SURFACE, new SurfacePage(this)); setPage(PAGE_INPUT, new InputPage(this)); setPage(PAGE_OUTPUT, new OutputPage(this)); - setPage(PAGE_OUTPUT_FIXEDWING, new OutputPageFixedwing(this)); + setPage(PAGE_OUTPUT_FIXEDWING, new OutputFixedwingPage(this)); setPage(PAGE_BIAS_CALIBRATION, new BiasCalibrationPage(this)); // setPage(PAGE_REVO_CALIBRATION, new RevoCalibrationPage(this)); setPage(PAGE_OUTPUT_CALIBRATION, new OutputCalibrationPage(this)); @@ -353,7 +353,7 @@ void SetupWizard::createPages() setPage(PAGE_SAVE, new SavePage(this)); setPage(PAGE_REBOOT, new RebootPage(this)); setPage(PAGE_NOTYETIMPLEMENTED, new NotYetImplementedPage(this)); - setPage(PAGE_AIRFRAMESTAB_FIXEDWING, new AirframeStabFixedwing(this)); + setPage(PAGE_AIRFRAMESTAB_FIXEDWING, new AirframeStabFixedwingPage(this)); setPage(PAGE_END, new OPEndPage(this)); setStartId(PAGE_START); diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index 9296cd5a7..e6b32a913 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -23,7 +23,6 @@ HEADERS += setupwizardplugin.h \ pages/surfacepage.h \ pages/abstractwizardpage.h \ pages/outputpage.h \ - pages/outputpagefixedwing.h \ pages/inputpage.h \ pages/summarypage.h \ vehicleconfigurationsource.h \ @@ -37,7 +36,8 @@ HEADERS += setupwizardplugin.h \ pages/revocalibrationpage.h \ biascalibrationutil.h \ pages/biascalibrationpage.h \ - pages/airframestabfixedwing.h + pages/outputfixedwingpage.h \ + pages/airframestabfixedwingpage.h SOURCES += setupwizardplugin.cpp \ setupwizard.cpp \ @@ -52,7 +52,6 @@ SOURCES += setupwizardplugin.cpp \ pages/surfacepage.cpp \ pages/abstractwizardpage.cpp \ pages/outputpage.cpp \ - pages/outputpagefixedwing.cpp \ pages/inputpage.cpp \ pages/summarypage.cpp \ vehicleconfigurationsource.cpp \ @@ -66,7 +65,8 @@ SOURCES += setupwizardplugin.cpp \ pages/revocalibrationpage.cpp \ biascalibrationutil.cpp \ pages/biascalibrationpage.cpp \ - pages/airframestabfixedwing.cpp + pages/outputfixedwingpage.cpp \ + pages/airframestabfixedwingpage.cpp OTHER_FILES += SetupWizard.pluginspec @@ -81,7 +81,6 @@ FORMS += \ pages/helipage.ui \ pages/surfacepage.ui \ pages/outputpage.ui \ - pages/outputpagefixedwing.ui \ pages/inputpage.ui \ pages/summarypage.ui \ connectiondiagram.ui \ @@ -91,7 +90,8 @@ FORMS += \ pages/autoupdatepage.ui \ pages/revocalibrationpage.ui \ pages/biascalibrationpage.ui \ - pages/airframestabfixedwing.ui + pages/outputfixedwingpage.ui \ + pages/airframestabfixedwingpage.ui RESOURCES += \ wizardResources.qrc diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp index 489397736..9bd98c1df 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationhelper.cpp @@ -231,7 +231,7 @@ void VehicleConfigurationHelper::applyVehicleConfiguration() setupElevon(); break; case VehicleConfigurationSource::FIXED_WING_VTAIL: -// setupVtail(); + // TODO: Implement settings for VTail fixed wings break; default: break; @@ -327,7 +327,7 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() ActuatorSettings::DataFields data = actSettings->getData(); QList actuatorSettings = m_configSource->getActuatorSettings(); - for (quint16 i = 1; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) { + for (quint16 i = 0; i < ActuatorSettings::CHANNELMAX_NUMELEM; i++) { data.ChannelType[i] = ActuatorSettings::CHANNELTYPE_PWM; data.ChannelAddr[i] = i; data.ChannelMin[i] = actuatorSettings[i].channelMin; @@ -335,10 +335,6 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() data.ChannelMax[i] = actuatorSettings[i].channelMax; } - for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) { - data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE; - } - qint16 updateFrequence = ANALOG_SERVO_FREQUENCE; switch (m_configSource->getActuatorType()) { case VehicleConfigurationSource::SERVO_ANALOG: @@ -351,6 +347,19 @@ void VehicleConfigurationHelper::applyActuatorConfiguration() break; } + for (quint16 i = 0; i < ActuatorSettings::CHANNELUPDATEFREQ_NUMELEM; i++) { + if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_REVO) { + if (i == 1) { + data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE; + } + } else if (m_configSource->getControllerType() == VehicleConfigurationSource::CONTROLLER_NANO) { + if (i == 2) { + data.ChannelUpdateFreq[i] = ANALOG_SERVO_FREQUENCE; + } + } + data.ChannelUpdateFreq[i] = updateFrequence; + } + actSettings->setData(data); addModifiedObject(actSettings, tr("Writing actuator settings")); @@ -1549,31 +1558,17 @@ void VehicleConfigurationHelper::setupElevon() channels[1].type = MIXER_TYPE_SERVO; channels[1].throttle1 = 0; channels[1].throttle2 = 0; - channels[1].roll = -127; - channels[1].pitch = 127; + channels[1].roll = -100; + channels[1].pitch = 100; channels[1].yaw = 0; channels[2].type = MIXER_TYPE_SERVO; channels[2].throttle1 = 0; channels[2].throttle2 = 0; - channels[2].roll = 127; - channels[2].pitch = -127; + channels[2].roll = 100; + 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 = 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 = 0; - guiSettings.fixedwing.FixedWingThrottle = 1; guiSettings.fixedwing.FixedWingRoll1 = 2; guiSettings.fixedwing.FixedWingRoll2 = 3; @@ -1620,12 +1615,12 @@ void VehicleConfigurationHelper::setupAileron() channels[3].pitch = 100; channels[3].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; + channels[4].type = MIXER_TYPE_SERVO; + channels[4].throttle1 = 0; + channels[4].throttle2 = 0; + channels[4].roll = 0; + channels[4].pitch = 0; + channels[4].yaw = 100; guiSettings.fixedwing.FixedWingThrottle = 1; guiSettings.fixedwing.FixedWingRoll1 = 2; diff --git a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h index 375423b5b..d03a75356 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/vehicleconfigurationsource.h @@ -55,7 +55,7 @@ class VehicleConfigurationSource { public: VehicleConfigurationSource(); - enum CONTROLLER_TYPE { CONTROLLER_UNKNOWN, CONTROLLER_CC, CONTROLLER_CC3D, CONTROLLER_REVO, CONTROLLER_OPLINK }; + enum CONTROLLER_TYPE { CONTROLLER_UNKNOWN, CONTROLLER_CC, CONTROLLER_CC3D, CONTROLLER_REVO, CONTROLLER_NANO, CONTROLLER_OPLINK }; enum VEHICLE_TYPE { VEHICLE_UNKNOWN, VEHICLE_MULTI, VEHICLE_FIXEDWING, VEHICLE_HELI, VEHICLE_SURFACE }; enum VEHICLE_SUB_TYPE { MULTI_ROTOR_UNKNOWN, MULTI_ROTOR_TRI_Y, MULTI_ROTOR_QUAD_X, MULTI_ROTOR_QUAD_PLUS, MULTI_ROTOR_HEXA, MULTI_ROTOR_HEXA_H, MULTI_ROTOR_HEXA_X, MULTI_ROTOR_HEXA_COAX_Y, MULTI_ROTOR_OCTO,