2011-02-22 22:03:32 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2013-05-01 12:59:07 +02:00
|
|
|
* @file configstabilizationwidget.cpp
|
2011-02-22 22:03:32 +00:00
|
|
|
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
|
|
|
* @brief The Configuration Gadget used to update settings in the firmware
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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 "configstabilizationwidget.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QStringList>
|
2013-09-15 23:06:25 +02:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
2011-05-31 00:16:01 -07:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
2012-02-02 16:22:40 +00:00
|
|
|
#include <QList>
|
2014-01-07 23:04:32 +01:00
|
|
|
#include <QTabBar>
|
2014-01-09 09:39:47 +01:00
|
|
|
#include <QMessageBox>
|
2011-02-22 22:03:32 +00:00
|
|
|
|
2012-07-21 10:58:05 -07:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
#include <coreplugin/generalsettings.h>
|
2013-06-25 12:21:16 +02:00
|
|
|
#include "altitudeholdsettings.h"
|
2014-01-09 13:02:03 +01:00
|
|
|
#include "stabilizationsettings.h"
|
2012-07-21 10:58:05 -07:00
|
|
|
|
2013-06-25 12:21:16 +02:00
|
|
|
ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent),
|
2014-01-09 13:02:03 +01:00
|
|
|
boardModel(0), m_pidBankCount(0), m_currentPIDBank(0)
|
2011-02-22 22:03:32 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui = new Ui_StabilizationWidget();
|
|
|
|
ui->setupUi(this);
|
2012-05-15 16:24:49 -05:00
|
|
|
|
2014-01-09 19:52:56 +01:00
|
|
|
StabilizationSettings *stabSettings = qobject_cast<StabilizationSettings *>(getObject("StabilizationSettings"));
|
2014-01-09 13:02:03 +01:00
|
|
|
Q_ASSERT(stabSettings);
|
|
|
|
|
|
|
|
m_pidBankCount = stabSettings->getField("FlightModeMap")->getOptions().count();
|
|
|
|
|
2014-01-08 00:33:45 +01:00
|
|
|
// Set up fake tab widget stuff for pid banks support
|
2014-01-07 23:04:32 +01:00
|
|
|
m_pidTabBars.append(ui->basicPIDBankTabBar);
|
|
|
|
m_pidTabBars.append(ui->advancedPIDBankTabBar);
|
|
|
|
foreach(QTabBar * tabBar, m_pidTabBars) {
|
2014-01-09 13:02:03 +01:00
|
|
|
for (int i = 0; i < m_pidBankCount; i++) {
|
2014-01-08 00:33:45 +01:00
|
|
|
tabBar->addTab(tr("PID Bank %1").arg(i + 1));
|
|
|
|
tabBar->setTabData(i, QString("StabilizationSettingsBank%1").arg(i + 1));
|
2014-01-07 23:04:32 +01:00
|
|
|
}
|
|
|
|
tabBar->setExpanding(false);
|
|
|
|
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int)));
|
|
|
|
}
|
2012-07-21 10:58:05 -07:00
|
|
|
|
2014-01-09 13:02:03 +01:00
|
|
|
for (int i = 0; i < m_pidBankCount; i++) {
|
2014-01-09 19:52:56 +01:00
|
|
|
if (i > 0) {
|
2014-01-08 00:33:45 +01:00
|
|
|
m_stabilizationObjectsString.append(",");
|
|
|
|
}
|
|
|
|
m_stabilizationObjectsString.append(m_pidTabBars.at(0)->tabData(i).toString());
|
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
|
|
|
|
|
|
|
|
if (!settings->useExpertMode()) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->saveStabilizationToRAM_6->setVisible(false);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-05-15 16:24:49 -05:00
|
|
|
|
2012-02-06 17:33:54 +00:00
|
|
|
autoLoadWidgets();
|
2012-02-10 16:34:07 +00:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
realtimeUpdates = new QTimer(this);
|
2013-05-01 12:59:07 +02:00
|
|
|
connect(realtimeUpdates, SIGNAL(timeout()), this, SLOT(apply()));
|
2012-02-10 16:34:07 +00:00
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->realTimeUpdates_6, SIGNAL(toggled(bool)), this, SLOT(realtimeUpdatesSlot(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->realTimeUpdates_6);
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->realTimeUpdates_8, SIGNAL(toggled(bool)), this, SLOT(realtimeUpdatesSlot(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->realTimeUpdates_8);
|
2013-05-05 22:20:48 +02:00
|
|
|
connect(ui->realTimeUpdates_12, SIGNAL(toggled(bool)), this, SLOT(realtimeUpdatesSlot(bool)));
|
|
|
|
addWidget(ui->realTimeUpdates_12);
|
2014-01-19 23:15:53 +01:00
|
|
|
connect(ui->realTimeUpdates_7, SIGNAL(toggled(bool)), this, SLOT(realtimeUpdatesSlot(bool)));
|
|
|
|
addWidget(ui->realTimeUpdates_7);
|
2013-05-04 00:13:15 +02:00
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->checkBox_7, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->checkBox_7);
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->checkBox_2, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->checkBox_2);
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->checkBox_8, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->checkBox_8);
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(ui->checkBox_3, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->checkBox_3);
|
|
|
|
|
|
|
|
addWidget(ui->pushButton_2);
|
|
|
|
addWidget(ui->pushButton_3);
|
|
|
|
addWidget(ui->pushButton_4);
|
|
|
|
addWidget(ui->pushButton_5);
|
|
|
|
addWidget(ui->pushButton_6);
|
2014-09-17 06:15:07 +10:00
|
|
|
addWidget(ui->pushButton_7);
|
|
|
|
addWidget(ui->pushButton_8);
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->pushButton_9);
|
2014-09-07 00:20:22 +02:00
|
|
|
addWidget(ui->pushButton_10);
|
|
|
|
addWidget(ui->pushButton_11);
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->pushButton_20);
|
|
|
|
addWidget(ui->pushButton_22);
|
|
|
|
addWidget(ui->pushButton_23);
|
2012-04-19 13:00:20 -04:00
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
addWidget(ui->basicResponsivenessGroupBox);
|
2014-02-09 10:59:50 +01:00
|
|
|
addWidget(ui->basicResponsivenessCheckBox);
|
|
|
|
connect(ui->basicResponsivenessCheckBox, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-05 12:45:35 +02:00
|
|
|
addWidget(ui->advancedResponsivenessGroupBox);
|
2014-02-09 10:59:50 +01:00
|
|
|
addWidget(ui->advancedResponsivenessCheckBox);
|
|
|
|
connect(ui->advancedResponsivenessCheckBox, SIGNAL(toggled(bool)), this, SLOT(linkCheckBoxes(bool)));
|
2013-05-05 12:45:35 +02:00
|
|
|
|
2014-09-06 23:53:44 +02:00
|
|
|
connect(ui->defaultThrottleCurveButton, SIGNAL(clicked()), this, SLOT(resetThrottleCurveToDefault()));
|
2014-09-20 17:30:19 +02:00
|
|
|
connect(ui->enableThrustPIDScalingCheckBox, SIGNAL(toggled(bool)), ui->ThrustPIDSource, SLOT(setEnabled(bool)));
|
|
|
|
connect(ui->enableThrustPIDScalingCheckBox, SIGNAL(toggled(bool)), ui->ThrustPIDTarget, SLOT(setEnabled(bool)));
|
|
|
|
connect(ui->enableThrustPIDScalingCheckBox, SIGNAL(toggled(bool)), ui->ThrustPIDAxis, SLOT(setEnabled(bool)));
|
2014-09-07 00:20:22 +02:00
|
|
|
connect(ui->enableThrustPIDScalingCheckBox, SIGNAL(toggled(bool)), ui->thrustPIDScalingCurve, SLOT(setEnabled(bool)));
|
2014-09-21 14:28:07 +02:00
|
|
|
ui->thrustPIDScalingCurve->setXAxisLabel(tr("Thrust"));
|
|
|
|
ui->thrustPIDScalingCurve->setYAxisLabel(tr("Scaling factor"));
|
|
|
|
ui->thrustPIDScalingCurve->setMin(-0.5);
|
|
|
|
ui->thrustPIDScalingCurve->setMax(0.5);
|
2014-09-27 15:49:53 +02:00
|
|
|
ui->thrustPIDScalingCurve->initLinearCurve(5, -0.25, 0.25);
|
2014-09-28 02:00:54 +02:00
|
|
|
connect(ui->thrustPIDScalingCurve, SIGNAL(curveUpdated()), this, SLOT(throttleCurveUpdated()));
|
2014-09-06 23:53:44 +02:00
|
|
|
|
2014-09-07 00:20:22 +02:00
|
|
|
addWidget(ui->defaultThrottleCurveButton);
|
|
|
|
addWidget(ui->enableThrustPIDScalingCheckBox);
|
2014-09-06 23:53:44 +02:00
|
|
|
addWidget(ui->thrustPIDScalingCurve);
|
2014-09-21 14:28:07 +02:00
|
|
|
addWidget(ui->thrustPIDScalingCurve);
|
2013-05-05 12:45:35 +02:00
|
|
|
connect(this, SIGNAL(widgetContentsChanged(QWidget *)), this, SLOT(processLinkedWidgets(QWidget *)));
|
2012-05-26 09:55:04 -05:00
|
|
|
|
2013-06-15 13:00:54 +02:00
|
|
|
connect(this, SIGNAL(autoPilotConnected()), this, SLOT(onBoardConnected()));
|
|
|
|
|
2013-05-01 12:59:07 +02:00
|
|
|
disableMouseWheelEvents();
|
2013-05-04 00:13:15 +02:00
|
|
|
updateEnableControls();
|
2011-02-22 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigStabilizationWidget::~ConfigStabilizationWidget()
|
|
|
|
{
|
2012-02-10 16:34:07 +00:00
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
void ConfigStabilizationWidget::refreshWidgetsValues(UAVObject *o)
|
|
|
|
{
|
|
|
|
ConfigTaskWidget::refreshWidgetsValues(o);
|
|
|
|
|
2014-09-06 23:53:44 +02:00
|
|
|
updateThrottleCurveFromObject();
|
|
|
|
|
2014-02-09 10:59:50 +01:00
|
|
|
ui->basicResponsivenessCheckBox->setChecked(ui->rateRollKp_3->value() == ui->ratePitchKp_4->value() &&
|
2013-05-05 12:45:35 +02:00
|
|
|
ui->rateRollKi_3->value() == ui->ratePitchKi_4->value());
|
|
|
|
}
|
|
|
|
|
2014-09-06 23:53:44 +02:00
|
|
|
void ConfigStabilizationWidget::updateObjectsFromWidgets()
|
|
|
|
{
|
|
|
|
updateObjectFromThrottleCurve();
|
|
|
|
ConfigTaskWidget::updateObjectsFromWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::updateThrottleCurveFromObject()
|
|
|
|
{
|
2014-09-28 02:00:54 +02:00
|
|
|
bool dirty = isDirty();
|
2014-09-20 17:30:19 +02:00
|
|
|
UAVObject *stabBank = getObjectManager()->getObject(QString(m_pidTabBars.at(0)->tabData(m_currentPIDBank).toString()));
|
2014-09-21 14:28:07 +02:00
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
Q_ASSERT(stabBank);
|
|
|
|
qDebug() << "updatingCurveFromObject" << stabBank->getName();
|
2014-09-07 00:23:20 +02:00
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
UAVObjectField *field = stabBank->getField("ThrustPIDScaleCurve");
|
|
|
|
Q_ASSERT(field);
|
2014-09-06 23:53:44 +02:00
|
|
|
|
|
|
|
QList<double> curve;
|
2014-09-20 17:30:19 +02:00
|
|
|
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
|
|
|
qDebug() << field->getName() << field->getElementNames().at(i) << "=>" << field->getValue(i);
|
|
|
|
curve.append(field->getValue(i).toDouble());
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ui->thrustPIDScalingCurve->setCurve(&curve);
|
2014-09-20 17:30:19 +02:00
|
|
|
|
|
|
|
field = stabBank->getField("EnableThrustPIDScaling");
|
|
|
|
Q_ASSERT(field);
|
|
|
|
|
|
|
|
bool enabled = field->getValue() == "TRUE";
|
|
|
|
ui->enableThrustPIDScalingCheckBox->setChecked(enabled);
|
|
|
|
ui->thrustPIDScalingCurve->setEnabled(enabled);
|
2014-09-28 02:00:54 +02:00
|
|
|
setDirty(dirty);
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::updateObjectFromThrottleCurve()
|
|
|
|
{
|
2014-09-20 17:30:19 +02:00
|
|
|
UAVObject *stabBank = getObjectManager()->getObject(QString(m_pidTabBars.at(0)->tabData(m_currentPIDBank).toString()));
|
2014-09-21 14:28:07 +02:00
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
Q_ASSERT(stabBank);
|
|
|
|
qDebug() << "updatingObjectFromCurve" << stabBank->getName();
|
2014-09-07 00:23:20 +02:00
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
UAVObjectField *field = stabBank->getField("ThrustPIDScaleCurve");
|
|
|
|
Q_ASSERT(field);
|
2014-09-06 23:53:44 +02:00
|
|
|
|
2014-09-21 14:28:07 +02:00
|
|
|
QList<double> curve = ui->thrustPIDScalingCurve->getCurve();
|
2014-09-20 17:30:19 +02:00
|
|
|
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
|
|
|
field->setValue(curve.at(i), i);
|
|
|
|
qDebug() << field->getName() << field->getElementNames().at(i) << "<=" << curve.at(i);
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
field = stabBank->getField("EnableThrustPIDScaling");
|
|
|
|
Q_ASSERT(field);
|
|
|
|
field->setValue(ui->enableThrustPIDScalingCheckBox->isChecked() ? "TRUE" : "FALSE");
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::resetThrottleCurveToDefault()
|
|
|
|
{
|
2014-09-21 14:28:07 +02:00
|
|
|
UAVDataObject *defaultStabBank = (UAVDataObject *)getObjectManager()->getObject(QString(m_pidTabBars.at(0)->tabData(m_currentPIDBank).toString()));
|
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
Q_ASSERT(defaultStabBank);
|
|
|
|
defaultStabBank = defaultStabBank->dirtyClone();
|
|
|
|
|
|
|
|
UAVObjectField *field = defaultStabBank->getField("ThrustPIDScaleCurve");
|
|
|
|
Q_ASSERT(field);
|
2014-09-07 00:23:20 +02:00
|
|
|
|
2014-09-06 23:53:44 +02:00
|
|
|
QList<double> curve;
|
2014-09-20 17:30:19 +02:00
|
|
|
for (quint32 i = 0; i < field->getNumElements(); i++) {
|
|
|
|
curve.append(field->getValue(i).toDouble());
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ui->thrustPIDScalingCurve->setCurve(&curve);
|
2014-09-20 17:30:19 +02:00
|
|
|
|
|
|
|
field = defaultStabBank->getField("EnableThrustPIDScaling");
|
|
|
|
Q_ASSERT(field);
|
|
|
|
|
|
|
|
bool enabled = field->getValue() == "TRUE";
|
|
|
|
ui->enableThrustPIDScalingCheckBox->setChecked(enabled);
|
|
|
|
ui->thrustPIDScalingCurve->setEnabled(enabled);
|
|
|
|
|
|
|
|
delete defaultStabBank;
|
2014-09-06 23:53:44 +02:00
|
|
|
}
|
|
|
|
|
2014-09-28 02:00:54 +02:00
|
|
|
void ConfigStabilizationWidget::throttleCurveUpdated()
|
|
|
|
{
|
|
|
|
setDirty(true);
|
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
void ConfigStabilizationWidget::realtimeUpdatesSlot(bool value)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-05 12:45:35 +02:00
|
|
|
ui->realTimeUpdates_6->setChecked(value);
|
|
|
|
ui->realTimeUpdates_8->setChecked(value);
|
2013-05-05 22:20:48 +02:00
|
|
|
ui->realTimeUpdates_12->setChecked(value);
|
2014-01-19 23:15:53 +01:00
|
|
|
ui->realTimeUpdates_7->setChecked(value);
|
2013-05-01 12:59:07 +02:00
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
if (value && !realtimeUpdates->isActive()) {
|
2013-05-05 18:48:48 +02:00
|
|
|
realtimeUpdates->start(AUTOMATIC_UPDATE_RATE);
|
|
|
|
qDebug() << "Instant Update timer started.";
|
|
|
|
} else if (!value && realtimeUpdates->isActive()) {
|
2012-02-10 16:34:07 +00:00
|
|
|
realtimeUpdates->stop();
|
2013-05-05 18:48:48 +02:00
|
|
|
qDebug() << "Instant Update timer stopped.";
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
void ConfigStabilizationWidget::linkCheckBoxes(bool value)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-05 12:45:35 +02:00
|
|
|
if (sender() == ui->checkBox_7) {
|
|
|
|
ui->checkBox_3->setChecked(value);
|
|
|
|
} else if (sender() == ui->checkBox_3) {
|
|
|
|
ui->checkBox_7->setChecked(value);
|
|
|
|
} else if (sender() == ui->checkBox_8) {
|
|
|
|
ui->checkBox_2->setChecked(value);
|
|
|
|
} else if (sender() == ui->checkBox_2) {
|
|
|
|
ui->checkBox_8->setChecked(value);
|
2014-02-09 10:59:50 +01:00
|
|
|
} else if (sender() == ui->basicResponsivenessCheckBox) {
|
|
|
|
ui->advancedResponsivenessCheckBox->setChecked(!value);
|
|
|
|
ui->basicResponsivenessControls->setEnabled(value);
|
|
|
|
ui->advancedResponsivenessControls->setEnabled(!value);
|
2013-05-05 18:48:48 +02:00
|
|
|
if (value) {
|
2013-05-05 12:45:35 +02:00
|
|
|
processLinkedWidgets(ui->AttitudeResponsivenessSlider);
|
|
|
|
processLinkedWidgets(ui->RateResponsivenessSlider);
|
|
|
|
}
|
2014-02-09 10:59:50 +01:00
|
|
|
} else if (sender() == ui->advancedResponsivenessCheckBox) {
|
|
|
|
ui->basicResponsivenessCheckBox->setChecked(!value);
|
|
|
|
ui->basicResponsivenessControls->setEnabled(!value);
|
|
|
|
ui->advancedResponsivenessControls->setEnabled(value);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
void ConfigStabilizationWidget::processLinkedWidgets(QWidget *widget)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-05 12:45:35 +02:00
|
|
|
if (ui->checkBox_7->isChecked()) {
|
|
|
|
if (widget == ui->RateRollKp_2) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RatePitchKp->setValue(ui->RateRollKp_2->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->RateRollKi_2) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RatePitchKi->setValue(ui->RateRollKi_2->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->RatePitchKp) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RateRollKp_2->setValue(ui->RatePitchKp->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->RatePitchKi) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RateRollKi_2->setValue(ui->RatePitchKi->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->RollRateKd) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->PitchRateKd->setValue(ui->RollRateKd->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->PitchRateKd) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RollRateKd->setValue(ui->PitchRateKd->value());
|
2012-07-27 11:55:01 +01:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-05 12:45:35 +02:00
|
|
|
|
|
|
|
if (ui->checkBox_8->isChecked()) {
|
|
|
|
if (widget == ui->AttitudeRollKp) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudePitchKp_2->setValue(ui->AttitudeRollKp->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->AttitudeRollKi) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudePitchKi_2->setValue(ui->AttitudeRollKi->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->AttitudePitchKp_2) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudeRollKp->setValue(ui->AttitudePitchKp_2->value());
|
2013-05-05 12:45:35 +02:00
|
|
|
} else if (widget == ui->AttitudePitchKi_2) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudeRollKi->setValue(ui->AttitudePitchKi_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
|
2014-02-09 10:59:50 +01:00
|
|
|
if (ui->basicResponsivenessCheckBox->isChecked()) {
|
2013-05-05 12:45:35 +02:00
|
|
|
if (widget == ui->AttitudeResponsivenessSlider) {
|
|
|
|
ui->ratePitchKp_4->setValue(ui->AttitudeResponsivenessSlider->value());
|
|
|
|
} else if (widget == ui->RateResponsivenessSlider) {
|
|
|
|
ui->ratePitchKi_4->setValue(ui->RateResponsivenessSlider->value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 13:00:54 +02:00
|
|
|
|
|
|
|
void ConfigStabilizationWidget::onBoardConnected()
|
|
|
|
{
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
2013-06-22 14:24:47 +03:00
|
|
|
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
|
|
|
|
2013-06-15 13:00:54 +02:00
|
|
|
Q_ASSERT(utilMngr);
|
2013-06-25 12:21:16 +02:00
|
|
|
boardModel = utilMngr->getBoardModel();
|
2014-09-18 00:35:07 +10:00
|
|
|
// If Revolution board enable Althold tab, otherwise disable it
|
2013-06-25 12:21:16 +02:00
|
|
|
ui->AltitudeHold->setEnabled((boardModel & 0xff00) == 0x0900);
|
|
|
|
}
|
|
|
|
|
2014-01-07 23:04:32 +01:00
|
|
|
void ConfigStabilizationWidget::pidBankChanged(int index)
|
|
|
|
{
|
2014-09-28 02:00:54 +02:00
|
|
|
bool dirty = isDirty();
|
2014-09-30 00:39:51 +02:00
|
|
|
|
2014-09-20 17:30:19 +02:00
|
|
|
updateObjectFromThrottleCurve();
|
2014-01-07 23:04:32 +01:00
|
|
|
foreach(QTabBar * tabBar, m_pidTabBars) {
|
2014-01-09 09:39:47 +01:00
|
|
|
disconnect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int)));
|
2014-01-07 23:04:32 +01:00
|
|
|
tabBar->setCurrentIndex(index);
|
2014-01-09 09:39:47 +01:00
|
|
|
connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(pidBankChanged(int)));
|
2014-01-07 23:04:32 +01:00
|
|
|
}
|
2014-01-08 00:33:45 +01:00
|
|
|
|
2014-01-09 19:52:56 +01:00
|
|
|
for (int i = 0; i < m_pidTabBars.at(0)->count(); i++) {
|
2014-01-09 13:34:11 +01:00
|
|
|
setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(i).toString(), false);
|
2014-01-08 00:33:45 +01:00
|
|
|
}
|
2014-01-09 13:34:11 +01:00
|
|
|
|
|
|
|
setWidgetBindingObjectEnabled(m_pidTabBars.at(0)->tabData(index).toString(), true);
|
|
|
|
|
2014-01-09 09:39:47 +01:00
|
|
|
m_currentPIDBank = index;
|
2014-09-20 17:30:19 +02:00
|
|
|
qDebug() << "current bank:" << m_currentPIDBank;
|
|
|
|
updateThrottleCurveFromObject();
|
2014-09-28 02:00:54 +02:00
|
|
|
setDirty(dirty);
|
2014-01-07 23:04:32 +01:00
|
|
|
}
|
|
|
|
|
2013-06-25 12:21:16 +02:00
|
|
|
bool ConfigStabilizationWidget::shouldObjectBeSaved(UAVObject *object)
|
|
|
|
{
|
|
|
|
// AltitudeHoldSettings should only be saved for Revolution board to avoid error.
|
2013-06-25 22:31:10 +02:00
|
|
|
if ((boardModel & 0xff00) != 0x0900) {
|
|
|
|
return dynamic_cast<AltitudeHoldSettings *>(object) == 0;
|
|
|
|
} else {
|
2013-06-25 12:21:16 +02:00
|
|
|
return true;
|
|
|
|
}
|
2013-06-15 13:00:54 +02:00
|
|
|
}
|
2014-01-08 00:33:45 +01:00
|
|
|
|
|
|
|
QString ConfigStabilizationWidget::mapObjectName(const QString objectName)
|
|
|
|
{
|
2014-01-09 19:52:56 +01:00
|
|
|
if (objectName == "StabilizationSettingsBankX") {
|
2014-01-08 00:33:45 +01:00
|
|
|
return m_stabilizationObjectsString;
|
|
|
|
}
|
|
|
|
return ConfigTaskWidget::mapObjectName(objectName);
|
|
|
|
}
|