Skip to content

Commit e281a03

Browse files
committed
LP-551 Add signal/slot logic between Input and Output tab - Prevent actuator manipulation with Output warning and freeze Output tab while calibrating
1 parent 2a7e89b commit e281a03

5 files changed

Lines changed: 75 additions & 14 deletions

File tree

ground/gcs/src/plugins/config/configgadgetwidget.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
7777
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
7878

7979
QWidget *widget;
80+
QWidget *inputWidget;
81+
QWidget *outputWidget;
8082
QIcon *icon;
8183

8284
icon = new QIcon();
@@ -98,13 +100,15 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
98100
widget = new ConfigInputWidget(this);
99101
static_cast<ConfigTaskWidget *>(widget)->bind();
100102
stackWidget->insertTab(ConfigGadgetWidget::Input, widget, *icon, QString("Input"));
103+
inputWidget = widget;
101104

102105
icon = new QIcon();
103106
icon->addFile(":/configgadget/images/output_normal.png", QSize(), QIcon::Normal, QIcon::Off);
104107
icon->addFile(":/configgadget/images/output_selected.png", QSize(), QIcon::Selected, QIcon::Off);
105108
widget = new ConfigOutputWidget(this);
106109
static_cast<ConfigTaskWidget *>(widget)->bind();
107110
stackWidget->insertTab(ConfigGadgetWidget::Output, widget, *icon, QString("Output"));
111+
outputWidget = widget;
108112

109113
icon = new QIcon();
110114
icon->addFile(":/configgadget/images/ins_normal.png", QSize(), QIcon::Normal, QIcon::Off);
@@ -165,6 +169,11 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
165169
onOPLinkConnect();
166170
}
167171

172+
// Connect output tab and input tab for safe
173+
// output config and input calibration
174+
connect(outputWidget, SIGNAL(outputConfigSafe(bool)), inputWidget, SLOT(outputConfigSafe(bool)));
175+
connect(inputWidget, SIGNAL(inputCalibrationStatus(bool)), outputWidget, SLOT(inputCalibrationStatus(bool)));
176+
168177
help = 0;
169178
connect(stackWidget, SIGNAL(currentAboutToShow(int, bool *)), this, SLOT(tabAboutToChange(int, bool *)));
170179
}

ground/gcs/src/plugins/config/configinputwidget.cpp

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,12 @@ void ConfigInputWidget::resizeEvent(QResizeEvent *event)
509509

510510
void ConfigInputWidget::goToWizard()
511511
{
512+
if (!safeOutputConfig) {
513+
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output tab</b>."
514+
"<p>Please fix the issue before starting the Transmitter wizard</p>"), QMessageBox::Ok);
515+
return;
516+
}
517+
512518
QMessageBox msgBox;
513519

514520
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
@@ -519,6 +525,9 @@ void ConfigInputWidget::goToWizard()
519525
msgBox.setDefaultButton(QMessageBox::Ok);
520526
msgBox.exec();
521527

528+
// Tell Output tab we freeze actuators soon
529+
emit inputCalibrationStatus(true);
530+
522531
// Set correct tab visible before starting wizard.
523532
if (ui->tabWidget->currentIndex() != 0) {
524533
ui->tabWidget->setCurrentIndex(0);
@@ -587,6 +596,9 @@ void ConfigInputWidget::wzCancel()
587596
flightModeSettingsObj->setData(memento.flightModeSettingsData);
588597
actuatorSettingsObj->setData(memento.actuatorSettingsData);
589598
systemSettingsObj->setData(memento.systemSettingsData);
599+
600+
// Tell Output tab the calibration is ended
601+
emit inputCalibrationStatus(false);
590602
}
591603

592604
void ConfigInputWidget::registerControlActivity()
@@ -682,6 +694,9 @@ void ConfigInputWidget::wzNext()
682694
// move to Arming Settings tab
683695
ui->stackedWidget->setCurrentIndex(0);
684696
ui->tabWidget->setCurrentIndex(3);
697+
698+
// Tell Output tab the calibration is ended
699+
emit inputCalibrationStatus(false);
685700
break;
686701
default:
687702
Q_ASSERT(0);
@@ -1916,6 +1931,15 @@ void ConfigInputWidget::updateCalibration()
19161931

19171932
void ConfigInputWidget::simpleCalibration(bool enable)
19181933
{
1934+
if (!safeOutputConfig) {
1935+
if (enable) {
1936+
QMessageBox::warning(this, tr("Warning"), tr("There is something wrong in <b>Output tab</b>."
1937+
"<p>Please fix the issue before starting the Manual Calibration</p>"), QMessageBox::Ok);
1938+
ui->runCalibration->setChecked(false);
1939+
}
1940+
return;
1941+
}
1942+
19191943
if (enable) {
19201944
ui->configurationWizard->setEnabled(false);
19211945
ui->applyButton->setEnabled(false);
@@ -1932,6 +1956,9 @@ void ConfigInputWidget::simpleCalibration(bool enable)
19321956
msgBox.setDefaultButton(QMessageBox::Ok);
19331957
msgBox.exec();
19341958

1959+
// Tell Output tab we freeze actuators soon
1960+
emit inputCalibrationStatus(true);
1961+
19351962
manualCommandData = manualCommandObj->getData();
19361963

19371964
manualSettingsData = manualSettingsObj->getData();
@@ -1999,6 +2026,9 @@ void ConfigInputWidget::simpleCalibration(bool enable)
19992026
ui->saveButton->setEnabled(true);
20002027
ui->runCalibration->setText(tr("Start Manual Calibration"));
20012028

2029+
// Tell Output tab the calibration is ended
2030+
emit inputCalibrationStatus(false);
2031+
20022032
disconnect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject *)), this, SLOT(updateCalibration()));
20032033
}
20042034
}
@@ -2082,7 +2112,7 @@ void ConfigInputWidget::resetActuatorSettings()
20822112
QString mixerType;
20832113

20842114
// Clear all output data : Min, max, neutral at same value
2085-
// 1000 for motors and 1500 for all others (Reversable motor included)
2115+
// min value for motors and neutral for all others (Reversable motor, servo)
20862116
for (unsigned int output = 0; output < ActuatorSettings::CHANNELMAX_NUMELEM; output++) {
20872117
QString mixerNumType = QString("Mixer%1Type").arg(output + 1);
20882118
UAVObjectField *field = mixer->getField(mixerNumType);
@@ -2092,13 +2122,13 @@ void ConfigInputWidget::resetActuatorSettings()
20922122
mixerType = field->getValue().toString();
20932123
}
20942124
if ((mixerType == "Motor") || (mixerType == "Disabled")) {
2095-
actuatorSettingsData.ChannelMax[output] = 1000;
2096-
actuatorSettingsData.ChannelMin[output] = 1000;
2097-
actuatorSettingsData.ChannelNeutral[output] = 1000;
2125+
// Apply current min setting to neutral/max values
2126+
actuatorSettingsData.ChannelMax[output] = actuatorSettingsData.ChannelMin[output];
2127+
actuatorSettingsData.ChannelNeutral[output] = actuatorSettingsData.ChannelMin[output];
20982128
} else {
2099-
actuatorSettingsData.ChannelMax[output] = 1500;
2100-
actuatorSettingsData.ChannelMin[output] = 1500;
2101-
actuatorSettingsData.ChannelNeutral[output] = 1500;
2129+
// Apply current neutral setting to min/max values
2130+
actuatorSettingsData.ChannelMax[output] = actuatorSettingsData.ChannelNeutral[output];
2131+
actuatorSettingsData.ChannelMin[output] = actuatorSettingsData.ChannelNeutral[output];
21022132
}
21032133
UAVObjectUpdaterHelper updateHelper;
21042134
actuatorSettingsObj->setData(actuatorSettingsData, false);
@@ -2189,3 +2219,8 @@ void ConfigInputWidget::enableControlsChanged(bool enabled)
21892219
ui->failsafeBatteryWarningFlightModeCb->setEnabled(enabled && batteryModuleEnabled);
21902220
ui->failsafeBatteryCriticalFlightModeCb->setEnabled(enabled && batteryModuleEnabled);
21912221
}
2222+
2223+
void ConfigInputWidget::outputConfigSafe(bool status)
2224+
{
2225+
safeOutputConfig = status;
2226+
}

ground/gcs/src/plugins/config/configinputwidget.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ class ConfigInputWidget : public ConfigTaskWidget {
7272
void enableControls(bool enable);
7373
bool shouldObjectBeSaved(UAVObject *object);
7474

75+
public slots:
76+
void outputConfigSafe(bool status);
77+
78+
signals:
79+
void inputCalibrationStatus(bool started);
80+
7581
private:
7682
bool throttleError;
7783
bool growing;
7884
bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM];
85+
bool safeOutputConfig;
7986
txMovements currentMovement;
8087
int movePos;
8188
void setTxMovement(txMovements movement);

ground/gcs/src/plugins/config/configoutputwidget.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ void ConfigOutputWidget::onBankTypeChange()
667667
updateChannelConfigWarning(warning_found);
668668
}
669669

670-
bool ConfigOutputWidget::checkOutputConfig()
670+
void ConfigOutputWidget::checkOutputConfig()
671671
{
672672
ChannelConfigWarning current_warning = None;
673673
ChannelConfigWarning warning_found = None;
@@ -691,11 +691,8 @@ bool ConfigOutputWidget::checkOutputConfig()
691691

692692
updateChannelConfigWarning(warning_found);
693693

694-
if (warning_found > None) {
695-
return false;
696-
}
697-
698-
return true;
694+
// Emit signal to be received by Input tab
695+
emit outputConfigSafe(warning_found == None);
699696
}
700697

701698
void ConfigOutputWidget::stopTests()
@@ -779,6 +776,12 @@ QString ConfigOutputWidget::bankModeName(int index)
779776
return bankModeOptions.at(index);
780777
}
781778

779+
void ConfigOutputWidget::inputCalibrationStatus(bool started)
780+
{
781+
// Disable controls if a input calibration is started
782+
enableControls(!started);
783+
}
784+
782785
OutputBankControls::OutputBankControls(MixerSettings *mixer, QLabel *label, QColor color, QComboBox *rateCombo, QComboBox *modeCombo) :
783786
m_mixer(mixer), m_label(label), m_color(color), m_rateCombo(rateCombo), m_modeCombo(modeCombo)
784787
{}

ground/gcs/src/plugins/config/configoutputwidget.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ class ConfigOutputWidget : public ConfigTaskWidget {
8585
ConfigOutputWidget(QWidget *parent = 0);
8686
~ConfigOutputWidget();
8787

88-
bool checkOutputConfig();
88+
public slots:
89+
void inputCalibrationStatus(bool started);
90+
91+
signals:
92+
void outputConfigSafe(bool status);
8993

9094
protected:
9195
void enableControls(bool enable);
@@ -102,6 +106,8 @@ class ConfigOutputWidget : public ConfigTaskWidget {
102106
UAVObject::Metadata m_accInitialData;
103107
QList<OutputBankControls> m_banks;
104108

109+
bool inputCalibrationStarted;
110+
105111
OutputChannelForm *getOutputChannelForm(const int index) const;
106112
void updateChannelInSlider(QSlider *slider, QLabel *min, QLabel *max, QCheckBox *rev, int value);
107113
void assignOutputChannel(UAVDataObject *obj, QString &str);
@@ -110,6 +116,7 @@ class ConfigOutputWidget : public ConfigTaskWidget {
110116
enum ChannelConfigWarning { None, CannotDriveServo, IsNormalMotorCheckNeutral, IsReversibleMotorCheckNeutral, BiDirectionalDShotNotSupported };
111117
void setChannelLimits(OutputChannelForm *channelForm, OutputBankControls *bankControls);
112118
ChannelConfigWarning checkChannelConfig(OutputChannelForm *channelForm, OutputBankControls *bankControls);
119+
void checkOutputConfig();
113120
void updateChannelConfigWarning(ChannelConfigWarning warning);
114121
QString bankModeName(int index);
115122

0 commit comments

Comments
 (0)