From 4b640c5d1dc969624429182da0c3d724a02a3e3e Mon Sep 17 00:00:00 2001 From: Laurent Lalanne Date: Sun, 8 Mar 2015 02:20:57 +0100 Subject: [PATCH] OP-1764 Add Throttle range check --- .../src/plugins/config/configinputwidget.cpp | 28 +++++++++++++++---- .../src/plugins/config/configinputwidget.h | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 52d2f598e..e21cebbbe 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -549,6 +549,8 @@ void ConfigInputWidget::wzNext() // Force flight mode neutral to middle and Throttle neutral at 4% adjustSpecialNeutrals(); + throttleError = false; + checkThrottleRange(); manualSettingsObj->setData(manualSettingsData); // move to Arming Settings tab @@ -1593,6 +1595,7 @@ void ConfigInputWidget::simpleCalibration(bool enable) ui->saveRCInputToRAM->setEnabled(false); ui->saveRCInputToSD->setEnabled(false); ui->runCalibration->setText(tr("Stop Manual Calibration")); + throttleError = false; QMessageBox msgBox; msgBox.setText(tr("

Arming Settings are now set to 'Always Disarmed' for your safety.

" @@ -1628,11 +1631,6 @@ void ConfigInputWidget::simpleCalibration(bool enable) connect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject *)), this, SLOT(updateCalibration())); } else { - ui->configurationWizard->setEnabled(true); - ui->saveRCInputToRAM->setEnabled(true); - ui->saveRCInputToSD->setEnabled(true); - ui->runCalibration->setText(tr("Start Manual Calibration")); - manualCommandData = manualCommandObj->getData(); manualSettingsData = manualSettingsObj->getData(); @@ -1641,16 +1639,21 @@ void ConfigInputWidget::simpleCalibration(bool enable) for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) { if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) { adjustSpecialNeutrals(); + checkThrottleRange(); } else { manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i]; } } - manualSettingsObj->setData(manualSettingsData); // Load actuator settings back from beginning of manual calibration actuatorSettingsObj->setData(previousActuatorSettingsData); + ui->configurationWizard->setEnabled(true); + ui->saveRCInputToRAM->setEnabled(true); + ui->saveRCInputToSD->setEnabled(true); + ui->runCalibration->setText(tr("Start Manual Calibration")); + disconnect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject *)), this, SLOT(updateCalibration())); } } @@ -1671,6 +1674,19 @@ void ConfigInputWidget::adjustSpecialNeutrals() manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) * 0.04); } +void ConfigInputWidget::checkThrottleRange() +{ + if ((abs(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] - + manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) < 300) && (throttleError == false)) { + throttleError = true; + QMessageBox::warning(this, tr("Warning"), tr("

There is something wrong with Throttle range. Please redo calibration and move ALL sticks, Throttle stick included.

"), QMessageBox::Ok); + + // Set Throttle neutral to max value so Throttle can't be positive + manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] = + manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE]; + } +} + bool ConfigInputWidget::shouldObjectBeSaved(UAVObject *object) { // ManualControlCommand no need to be saved diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index eac10856c..3c2a138d2 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -71,6 +71,7 @@ public: bool shouldObjectBeSaved(UAVObject *object); private: + bool throttleError; bool growing; bool reverse[ManualControlSettings::CHANNELNEUTRAL_NUMELEM]; txMovements currentMovement; @@ -199,6 +200,7 @@ private slots: void invertControls(); void simpleCalibration(bool state); void adjustSpecialNeutrals(); + void checkThrottleRange(); void updateCalibration(); void resetChannelSettings(); void resetActuatorSettings();