From a44ea92df78da8fd7add71574937f0ece2d903c8 Mon Sep 17 00:00:00 2001 From: Fredrik Arvidsson Date: Mon, 3 Sep 2012 01:01:57 +0200 Subject: [PATCH] OP-39 Output calibration functionality. Connection diagram updates. --- .../plugins/setupwizard/connectiondiagram.cpp | 31 +- .../plugins/setupwizard/connectiondiagram.ui | 4 +- .../setupwizard/outputcalibrationutil.cpp | 92 + .../setupwizard/outputcalibrationutil.h | 57 + .../plugins/setupwizard/pages/flashpage.cpp | 4 +- .../setupwizard/pages/levellingpage.cpp | 4 +- .../pages/outputcalibrationpage.cpp | 203 +- .../setupwizard/pages/outputcalibrationpage.h | 43 + .../pages/outputcalibrationpage.ui | 647 +- .../plugins/setupwizard/pages/startpage.ui | 2 +- .../plugins/setupwizard/pages/summarypage.ui | 18 +- .../resources/connection-diagrams.svg | 18121 +++++++--------- .../resources/multirotor-shapes.svg | 6788 ++++++ .../src/plugins/setupwizard/setupwizard.cpp | 19 +- .../src/plugins/setupwizard/setupwizard.h | 2 +- .../src/plugins/setupwizard/setupwizard.pro | 6 +- .../plugins/setupwizard/wizardResources.qrc | 1 + 17 files changed, 15636 insertions(+), 10406 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h create mode 100644 ground/openpilotgcs/src/plugins/setupwizard/resources/multirotor-shapes.svg diff --git a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp index 05158a656..6ded9bda6 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.cpp @@ -57,20 +57,20 @@ void ConnectionDiagram::showEvent(QShowEvent * event) void ConnectionDiagram::setupGraphicsScene() { - QGraphicsScene *scene = new QGraphicsScene(this); - ui->connectionDiagram->setScene(scene); - ui->connectionDiagram->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); m_renderer = new QSvgRenderer(); if (QFile::exists(QString(":/setupwizard/resources/connection-diagrams.svg")) && m_renderer->load(QString(":/setupwizard/resources/connection-diagrams.svg")) && m_renderer->isValid()) { - scene->clear(); + QGraphicsScene *scene = new QGraphicsScene(this); + ui->connectionDiagram->setScene(scene); + //ui->connectionDiagram->setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + m_background = new QGraphicsSvgItem(); m_background->setSharedRenderer(m_renderer); m_background->setElementId("background"); - m_background->setVisible(true); - m_background->setFlags(QGraphicsItem::ItemClipsToShape); + m_background->setOpacity(0); + //m_background->setFlags(QGraphicsItem::ItemClipsToShape); m_background->setZValue(-1); scene->addItem(m_background); @@ -124,10 +124,10 @@ void ConnectionDiagram::setupGraphicsScene() switch (m_configSource->getInputType()) { case VehicleConfigurationSource::INPUT_PWM: - elementsToShow << "receiver" << "pwm" ; + elementsToShow << "pwm" ; break; case VehicleConfigurationSource::INPUT_PPM: - elementsToShow << "receiver" << "ppm"; + elementsToShow << "ppm"; break; case VehicleConfigurationSource::INPUT_SBUS: elementsToShow << "sbus"; @@ -151,23 +151,28 @@ void ConnectionDiagram::setupGraphicsScene() void ConnectionDiagram::setupGraphicsSceneItems(QGraphicsScene *scene, QList elementsToShow) { qreal z = 0; + QRectF backgBounds = m_renderer->boundsOnElement("background"); + foreach(QString elementId, elementsToShow) { if(m_renderer->elementExists(elementId)) { QGraphicsSvgItem* element = new QGraphicsSvgItem(); element->setSharedRenderer(m_renderer); element->setElementId(elementId); - element->setVisible(true); element->setZValue(z++); - scene->addItem(element); + element->setOpacity(1.0); QMatrix matrix = m_renderer->matrixForElement(elementId); QRectF orig = matrix.mapRect(m_renderer->boundsOnElement(elementId)); element->setPos(orig.x(),orig.y()); + + //QRectF orig = m_renderer->boundsOnElement(elementId); + //element->setPos(orig.x() - backgBounds.x(), orig.y() - backgBounds.y()); + + scene->addItem(element); qDebug() << "Adding " << elementId << " to scene at " << element->pos(); } - else - { - qDebug() << "Element " << elementId << " not found in renderer!"; + else { + qDebug() << "Element with id: " << elementId << " not found."; } } } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.ui b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.ui index 27221c4c7..690364a6d 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/connectiondiagram.ui @@ -6,8 +6,8 @@ 0 0 - 600 - 400 + 800 + 440 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp new file mode 100644 index 000000000..0c2e10746 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.cpp @@ -0,0 +1,92 @@ +/** + ****************************************************************************** + * + * @file outputcalibrationutil.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup OutputCalibrationUtil + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "outputcalibrationutil.h" +#include "actuatorcommand.h" +#include "extensionsystem/pluginmanager.h" + +OutputCalibrationUtil::OutputCalibrationUtil(QObject *parent) : + QObject(parent), m_outputChannel(0) +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + m_uavObjectManager = pm->getObject(); + Q_ASSERT(m_uavObjectManager); +} + +void OutputCalibrationUtil::startChannelOutput(quint16 channel) +{ + if(m_outputChannel == 0 && channel > 0 && channel <= ActuatorCommand::CHANNEL_NUMELEM) + { + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(m_uavObjectManager); + Q_ASSERT(actuatorCommand); + UAVObject::Metadata metaData = actuatorCommand->getMetadata(); + + m_savedActuatorMetadata = metaData; + UAVObject::SetFlightAccess(metaData, UAVObject::ACCESS_READONLY); + UAVObject::SetFlightTelemetryUpdateMode(metaData, UAVObject::UPDATEMODE_ONCHANGE); + UAVObject::SetGcsTelemetryAcked(metaData, false); + UAVObject::SetGcsTelemetryUpdateMode(metaData, UAVObject::UPDATEMODE_ONCHANGE); + metaData.gcsTelemetryUpdatePeriod = 100; + + actuatorCommand->setMetadata(metaData); + actuatorCommand->updated(); + + //Start output... + m_outputChannel = channel; + } +} + +void OutputCalibrationUtil::stopChannelOutput() +{ + if(m_outputChannel > 0) + { + //Stop output... + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(m_uavObjectManager); + Q_ASSERT(actuatorCommand); + UAVObject::Metadata metaData = actuatorCommand->getMetadata(); + + // Restore metadata to what it was before + metaData = m_savedActuatorMetadata; + actuatorCommand->setMetadata(metaData); + actuatorCommand->updated(); + + m_outputChannel = 0; + } +} + +void OutputCalibrationUtil::setChannelOutputValue(quint16 value) +{ + if(m_outputChannel > 0) + { + //Set output value + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(m_uavObjectManager); + Q_ASSERT(actuatorCommand); + ActuatorCommand::DataFields data = actuatorCommand->getData(); + data.Channel[m_outputChannel - 1] = value; + actuatorCommand->setData(data); + } +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h new file mode 100644 index 000000000..82149a22d --- /dev/null +++ b/ground/openpilotgcs/src/plugins/setupwizard/outputcalibrationutil.h @@ -0,0 +1,57 @@ +/** + ****************************************************************************** + * + * @file outputcalibrationutil.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup + * @{ + * @addtogroup OutputCalibrationUtil + * @{ + * @brief + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef OUTPUTCALIBRATIONUTIL_H +#define OUTPUTCALIBRATIONUTIL_H + +#include +#include "uavobject.h" +#include "uavobjectmanager.h" + + +class OutputCalibrationUtil : public QObject +{ + Q_OBJECT +public: + explicit OutputCalibrationUtil(QObject *parent = 0); + +signals: + +public slots: + void startChannelOutput(quint16 channel); + void stopChannelOutput(); + + void setChannelOutputValue(quint16 value); + +private: + quint16 m_outputChannel; + UAVObject::Metadata m_savedActuatorMetadata; + UAVObjectManager *m_uavObjectManager; + +}; + +#endif // OUTPUTCALIBRATIONUTIL_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/flashpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/flashpage.cpp index 79014eaf5..988312bef 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/flashpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/flashpage.cpp @@ -68,7 +68,7 @@ void FlashPage::writeToController() ui->saveButton->setEnabled(false); getWizard()->button(QWizard::CancelButton)->setEnabled(false); - getWizard()->button(QWizard::BackButton)->setEnabled(false); + setCommitPage(true); VehicleConfigurationHelper helper(getWizard()); connect(&helper, SIGNAL(saveProgress(int, int, QString)),this, SLOT(saveProgress(int, int, QString))); m_successfulWrite = helper.setupVehicle(); @@ -76,7 +76,7 @@ void FlashPage::writeToController() ui->saveProgressLabel->setText(QString("%2").arg(m_successfulWrite ? "green" : "red", ui->saveProgressLabel->text())); ui->saveButton->setEnabled(true); getWizard()->button(QWizard::CancelButton)->setEnabled(true); - getWizard()->button(QWizard::BackButton)->setEnabled(true); + setCommitPage(false); emit completeChanged(); } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp index 992e7dd50..d806a3ffd 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/levellingpage.cpp @@ -71,7 +71,6 @@ void LevellingPage::performLevelling() } getWizard()->button(QWizard::CancelButton)->setEnabled(false); - getWizard()->button(QWizard::BackButton)->setEnabled(false); ui->levelButton->setEnabled(false); if(!m_levellingUtil) @@ -122,8 +121,7 @@ void LevellingPage::stopLevelling() disconnect(m_levellingUtil, SIGNAL(progress(long,long)), this, SLOT(levellingProgress(long,long))); disconnect(m_levellingUtil, SIGNAL(done(accelGyroBias)), this, SLOT(levellingDone(accelGyroBias))); disconnect(m_levellingUtil, SIGNAL(timeout(QString)), this, SLOT(levellingTimeout(QString))); - ui->levelButton->setEnabled(true); getWizard()->button(QWizard::CancelButton)->setEnabled(true); - getWizard()->button(QWizard::BackButton)->setEnabled(true); + ui->levelButton->setEnabled(true); } } diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp index 80c119116..b4aaed7cb 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.cpp @@ -29,12 +29,213 @@ #include "ui_outputcalibrationpage.h" OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *parent) : - AbstractWizardPage(wizard, parent), ui(new Ui::OutputCalibrationPage) + AbstractWizardPage(wizard, parent), ui(new Ui::OutputCalibrationPage), m_vehicleBoundsItem(0), + m_currentWizardIndex(0), m_calibrationUtil(0) { ui->setupUi(this); + + m_calibrationUtil = new OutputCalibrationUtil(); + + m_vehicleRenderer = new QSvgRenderer(); + 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() { + if(m_calibrationUtil) { + delete m_calibrationUtil; + } delete ui; } + +void OutputCalibrationPage::setupVehicle() +{ + m_wizardIndexes.clear(); + m_vehicleElementIds.clear(); + m_vehicleHighlightElementIndexes.clear(); + m_currentWizardIndex = 0; + m_vehicleScene->clear(); + switch(getWizard()->getVehicleSubType()) + { + case SetupWizard::MULTI_ROTOR_TRI_Y: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 3 << 4; + m_vehicleElementIds << "tri" << "tri-frame" << "tri-m1" << "tri-m2" << "tri-m3" << "tri-s1"; + m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4; + break; + case SetupWizard::MULTI_ROTOR_QUAD_X: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2; + m_vehicleElementIds << "quad-x" << "quad-x-frame" << "quad-x-m1" << "quad-x-m2" << "quad-x-m3" << "quad-x-m4"; + m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4; + break; + case SetupWizard::MULTI_ROTOR_QUAD_PLUS: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2; + m_vehicleElementIds << "quad-p" << "quad-p-frame" << "quad-p-m1" << "quad-p-m2" << "quad-p-m3" << "quad-p-m4"; + m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4; + break; + case SetupWizard::MULTI_ROTOR_HEXA: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2; + m_vehicleElementIds << "hexa" << "hexa-frame" << "hexa-m1" << "hexa-m2" << "hexa-m3" << "hexa-m4" << "hexa-m5" << "hexa-m6"; + m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6; + break; + case SetupWizard::MULTI_ROTOR_HEXA_COAX_Y: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2; + m_vehicleElementIds << "hexa-y6" << "hexa-y6-frame" << "hexa-y6-m1" << "hexa-y6-m2" << "hexa-y6-m3" << "hexa-y6-m4" << "hexa-y6-m5" << "hexa-y6-m6"; + m_vehicleHighlightElementIndexes << 0 << 1 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6; + break; + case SetupWizard::MULTI_ROTOR_HEXA_H: + m_wizardIndexes << 0 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 2; + 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 << 1 << 2 << 2 << 3 << 3 << 4 << 4 << 5 << 5 << 6 << 6; + break; + default: + break; + } + setupVehicleItems(); +} + +void OutputCalibrationPage::setupVehicleItems() +{ + m_vehicleItems.clear(); + m_vehicleBoundsItem = new QGraphicsSvgItem(); + m_vehicleBoundsItem->setSharedRenderer(m_vehicleRenderer); + m_vehicleBoundsItem->setElementId(m_vehicleElementIds[0]); + m_vehicleBoundsItem->setZValue(-1); + m_vehicleBoundsItem->setOpacity(0); + m_vehicleScene->addItem(m_vehicleBoundsItem); + + QRectF parentBounds = m_vehicleRenderer->boundsOnElement(m_vehicleElementIds[0]); + + for(int i = 1; i < m_vehicleElementIds.size(); i++) + { + QGraphicsSvgItem *item = new QGraphicsSvgItem(); + item->setSharedRenderer(m_vehicleRenderer); + item->setElementId(m_vehicleElementIds[i]); + item->setZValue(i); + item->setOpacity(1.0); + QRectF itemBounds = m_vehicleRenderer->boundsOnElement(m_vehicleElementIds[i]); + item->setPos(itemBounds.x() - parentBounds.x(), itemBounds.y() - parentBounds.y()); + + m_vehicleScene->addItem(item); + m_vehicleItems << item; + } +} + +void OutputCalibrationPage::startWizard() +{ + ui->calibrationStack->setCurrentIndex(m_wizardIndexes[0]); + setupVehicleHighlightedPart(); +} + +void OutputCalibrationPage::setupVehicleHighlightedPart() +{ + qreal dimOpaque = m_currentWizardIndex == 0 ? 1.0 : 0.3; + qreal highlightOpaque = 1.0; + int highlightedIndex = m_vehicleHighlightElementIndexes[m_currentWizardIndex]; + for(int i = 0; i < m_vehicleItems.size(); i++) { + QGraphicsSvgItem* item = m_vehicleItems[i]; + item->setOpacity((highlightedIndex == i) ? highlightOpaque : dimOpaque); + } +} + +void OutputCalibrationPage::setWizardPage() +{ + m_calibrationUtil->stopChannelOutput(); + ui->backPageButton->setEnabled(m_currentWizardIndex > 0); + ui->nextPageButton->setEnabled(m_currentWizardIndex < (m_wizardIndexes.size() - 1)); + ui->calibrationStack->setCurrentIndex(m_wizardIndexes.at(m_currentWizardIndex)); + setupVehicleHighlightedPart(); +} + +void OutputCalibrationPage::initializePage() +{ + if(m_vehicleScene) { + setupVehicle(); + startWizard(); + } +} + +void OutputCalibrationPage::showEvent(QShowEvent *event) +{ + Q_UNUSED(event); + if(m_vehicleBoundsItem) { + ui->vehicleView->setSceneRect(m_vehicleBoundsItem->boundingRect()); + ui->vehicleView->fitInView(m_vehicleBoundsItem, Qt::KeepAspectRatio); + } +} + +void OutputCalibrationPage::on_nextPageButton_clicked() +{ + if(m_currentWizardIndex < m_wizardIndexes.size()) { + m_currentWizardIndex++; + setWizardPage(); + } +} + +void OutputCalibrationPage::on_backPageButton_clicked() +{ + if(m_currentWizardIndex > 0) { + m_currentWizardIndex--; + setWizardPage(); + } +} + +void OutputCalibrationPage::on_motorNeutralButton_toggled(bool checked) +{ + if(checked) { + m_calibrationUtil->startChannelOutput(m_vehicleHighlightElementIndexes[m_currentWizardIndex]); + m_calibrationUtil->setChannelOutputValue(ui->motorNeutralSlider->value()); + } + else { + m_calibrationUtil->setChannelOutputValue(ui->motorNeutralSlider->minimum()); + m_calibrationUtil->stopChannelOutput(); + } +} + +void OutputCalibrationPage::on_motorNeutralSlider_valueChanged(int value) +{ + if(ui->motorNeutralButton->isChecked()) + { + m_calibrationUtil->setChannelOutputValue(ui->motorNeutralSlider->value()); + } +} + +void OutputCalibrationPage::on_motorMaxButton_toggled(bool checked) +{ + +} + +void OutputCalibrationPage::on_motorMaxSlider_valueChanged(int position) +{ + +} + +void OutputCalibrationPage::on_servoCenterButton_toggled(bool checked) +{ + +} + +void OutputCalibrationPage::on_servoAngleButton_toggled(bool checked) +{ + +} + +void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position) +{ + +} + +void OutputCalibrationPage::on_servoMinAngleSlider_valueChanged(int position) +{ + +} + +void OutputCalibrationPage::on_servoCenterSlider_valueChanged(int position) +{ + +} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h index 681c5f652..ecbdcca15 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.h @@ -28,7 +28,10 @@ #ifndef OUTPUTCALIBRATIONPAGE_H #define OUTPUTCALIBRATIONPAGE_H +#include #include "abstractwizardpage.h" +#include "setupwizard.h" +#include "outputcalibrationutil.h" namespace Ui { class OutputCalibrationPage; @@ -41,9 +44,49 @@ class OutputCalibrationPage : public AbstractWizardPage public: explicit OutputCalibrationPage(SetupWizard *wizard, QWidget *parent = 0); ~OutputCalibrationPage(); + void initializePage(); + +protected: + void showEvent(QShowEvent *event); +private slots: + void on_nextPageButton_clicked(); + void on_backPageButton_clicked(); + + void on_motorNeutralButton_toggled(bool checked); + void on_motorNeutralSlider_valueChanged(int value); + + void on_motorMaxButton_toggled(bool checked); + void on_motorMaxSlider_valueChanged(int position); + + void on_servoCenterButton_toggled(bool checked); + void on_servoCenterSlider_valueChanged(int position); + + void on_servoAngleButton_toggled(bool checked); + void on_servoMaxAngleSlider_valueChanged(int position); + void on_servoMinAngleSlider_valueChanged(int position); + private: + void setupVehicle(); + void startWizard(); + void setupVehicleItems(); + void setupVehicleHighlightedPart(); + void setWizardPage(); + Ui::OutputCalibrationPage *ui; + QSvgRenderer *m_vehicleRenderer; + QGraphicsScene *m_vehicleScene; + QGraphicsSvgItem *m_vehicleBoundsItem; + + quint16 m_currentWizardIndex; + + QList m_vehicleElementIds; + QList m_vehicleItems; + QList m_vehicleHighlightElementIndexes; + QList m_wizardIndexes; + + OutputCalibrationUtil *m_calibrationUtil; + }; #endif // OUTPUTCALIBRATIONPAGE_H diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui index a36237de2..401c80269 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/outputcalibrationpage.ui @@ -13,104 +13,617 @@ WizardPage - + - 310 + 300 40 - 250 - 250 + 270 + 270 QFrame::NoFrame - + - 110 - 341 - 380 - 20 + 20 + 40 + 270 + 291 - - Qt::Horizontal - - - QSlider::TicksBelow - - - 10 + + 1 + + + + + 0 + 10 + 261 + 281 + + + + <html><head/><body><p><span style=" font-size:10pt;">It is now time to calibrate the output levels for the signal controlling your vehichle. </span></p><p><span style=" font-size:10pt;">Depending on what vehichle you have selected, both motors controlled by ESC and servos controlled directly by the OpenPilot controller may have to be calibrated. <br/>The following steps will guide you safely through this process.<br/></span></p><p align="center"><span style=" font-size:14pt; font-weight:600; color:#ff0000;">VERY IMPORTANT!</span></p><p align="center"><br/><span style=" font-size:12pt; font-weight:600; color:#ff0000;">REMOVE ALL PROPELLERS FROM THE VEHICHLE BEFORE PROCEEDING!</span></p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + 0 + 10 + 261 + 141 + + + + <html><head/><body><p>In this step we will set the neutral rate for the motor highlighted in the illustration to the right. <br/>Plase pay attention to the details and in particular the motors position and its rotation direction.</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 stably. <br/><br/>When done press button again to stop.</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + false + + + + 10 + 200 + 241 + 19 + + + + 1000 + + + 1400 + + + 10 + + + 20 + + + Qt::Horizontal + + + false + + + QSlider::TicksBelow + + + 20 + + + + + + 90 + 240 + 75 + 23 + + + + Start + + + true + + + false + + + + + + + + 90 + 240 + 75 + 23 + + + + Start + + + true + + + false + + + + + + 0 + 10 + 261 + 171 + + + + <html><head/><body><p>Now it is time to find out the maximum rate for the motor highlighted in the illustration to the right. </p><p>To find the maximum rate for this engine, press the Start button below and slide the slider to the left until the engine just starts to slow down.</p><p>Running a brushless motor for a long time without proper cooling can in theory damage it. Therefore do not leave the motor running at full rate longer than neccesary.<br/><br/>When done press button again to stop.</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + false + + + + 10 + 200 + 241 + 19 + + + + 1600 + + + 2000 + + + 10 + + + 20 + + + 2000 + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksBelow + + + 20 + + + + + + + + 0 + 10 + 261 + 141 + + + + <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> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + false + + + + 10 + 200 + 241 + 19 + + + + 1000 + + + 2000 + + + 10 + + + 20 + + + 1500 + + + false + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksBelow + + + 40 + + + + + + 90 + 240 + 75 + 23 + + + + Start + + + true + + + false + + + + + + + + 90 + 240 + 75 + 23 + + + + Start + + + true + + + false + + + + + + 0 + 10 + 261 + 151 + + + + <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 extreme angles for the servo, press the Start button below and select the top slider and slide it to the right until max angle is reached. Then select the lower slider and slide it left until the minimum angle is set.</p><p>When done press button again to stop.</p></body></html> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 0 + 160 + 261 + 80 + + + + + + 10 + 40 + 16 + 17 + + + + + + + + + + 10 + 0 + 16 + 17 + + + + + + + true + + + + + + 39 + 0 + 211 + 20 + + + + 1500 + + + 2000 + + + 10 + + + 20 + + + 1500 + + + false + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksBelow + + + 40 + + + + + false + + + + 39 + 40 + 211 + 20 + + + + 1000 + + + 1500 + + + 10 + + + 20 + + + 1500 + + + false + + + Qt::Horizontal + + + false + + + false + + + QSlider::TicksBelow + + + 40 + + + + - + - 40 - 340 - 50 - 22 + 20 + 20 + 531 + 16 - - Qt::LeftToRight + + + 12 + 75 + true + + + + Output calibration - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + + + + + 148 + 340 + 75 + 23 + + + + > + + + + false - - QAbstractSpinBox::UpDownArrows - - - - - - - - - 2500 - - - 1000 - - - - 510 + 68 340 - 50 - 22 + 75 + 23 - - Qt::LeftToRight - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - QAbstractSpinBox::UpDownArrows - - - - - - - - - 2500 - - - 2000 + + < - + + + servoMaxAngleSliderRB + toggled(bool) + servoMaxAngleSlider + setEnabled(bool) + + + 37 + 208 + + + 164 + 209 + + + + + servoMinAngleSliderRB + toggled(bool) + servoMinAngleSlider + setEnabled(bool) + + + 37 + 248 + + + 164 + 249 + + + + + motorNeutralButton + toggled(bool) + motorNeutralSlider + setEnabled(bool) + + + 147 + 291 + + + 150 + 249 + + + + + motorMaxButton + toggled(bool) + motorMaxSlider + setEnabled(bool) + + + 147 + 291 + + + 150 + 249 + + + + + servoCenterButton + toggled(bool) + servoCenterSlider + setEnabled(bool) + + + 147 + 291 + + + 150 + 249 + + + + + servoAngleButton + toggled(bool) + sliderWidget + setEnabled(bool) + + + 147 + 291 + + + 150 + 239 + + + + diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui index 75ab147d7..f6b649191 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/startpage.ui @@ -45,7 +45,7 @@ p, li { white-space: pre-wrap; } <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; color:#ff0000;">REMOVE ALL PROPELLERS FROM THE VEHICHLE </span></p> <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; color:#ff0000;">BEFORE PROCEEDING!</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;">Ignoring the above request will put you in a</span><span style=" font-size:10pt; font-weight:600; color:#ff0000;"> risk of serious injury</span><span style=" font-size:10pt;">!</span></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;">Ignoring the above request will put you in a</span><span style=" font-size:10pt; font-weight:600; color:#000000;"> risk of serious injury</span><span style=" font-size:10pt;">!</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;">Ok, lets start the configuration by clicking on the 'Next'/'Continue' button below.</span></p></body></html> diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/summarypage.ui b/ground/openpilotgcs/src/plugins/setupwizard/pages/summarypage.ui index 85b332d21..47cc2dbeb 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/summarypage.ui +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/summarypage.ui @@ -26,13 +26,15 @@ <!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;"> +</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 configuration summary</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;"></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;">The first part of this wizard is now complete. The information required to create a basic OpenPilot controller configuration has been collected and a configuration can be created and saved.</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;">The first part of this wizard is now complete. All information required to create a basic OpenPilot controller configuration for a specific vehichle has been collected.</span></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;">Below is a summary of the configuration and a button that links to a diagram illustrating how to connect required hardware and the OpenPilotController with the current 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:10pt;"></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;">To complete the wizard and write the configuration directly to the OpenPilot controller please continue to the next and last step of this wizard.</span></p></body></html> +<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;">To continue the wizard and go through some basic configuration steps please continue to the next step of this wizard.</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;"><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;">The following steps requires that your OpenPilot controller is set up according to the diagram and that the vehicle is </span><span style=" font-size:10pt; font-weight:600;">powered by a battery</span><span style=" font-size:10pt;"> as well as </span><span style=" font-size:10pt; font-weight:600;">connected to the computer</span><span style=" font-size:10pt;">.</span></p></body></html> Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -45,7 +47,7 @@ p, li { white-space: pre-wrap; } 460 - 250 + 260 100 100 @@ -75,9 +77,9 @@ Illustration 40 - 230 + 249 400 - 140 + 121 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/resources/connection-diagrams.svg b/ground/openpilotgcs/src/plugins/setupwizard/resources/connection-diagrams.svg index 4e0fe2994..1f2219f3f 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/resources/connection-diagrams.svg +++ b/ground/openpilotgcs/src/plugins/setupwizard/resources/connection-diagrams.svg @@ -10,3735 +10,13 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - id="svg4183" + id="svg12651" + height="519.51434" + width="1078.6002" version="1.1" inkscape:version="0.48.2 r9819" - width="1100" - height="550" - xml:space="preserve" - sodipodi:docname="connection-diagrams.svg">image/svg+xml +