1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

OP-1764 Add Throttle range check

This commit is contained in:
Laurent Lalanne 2015-03-08 02:20:57 +01:00
parent 782df3ca0c
commit 4b640c5d1d
2 changed files with 24 additions and 6 deletions

View File

@ -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("<p>Arming Settings are now set to 'Always Disarmed' for your safety.</p>"
@ -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("<p>There is something wrong with Throttle range. Please redo calibration and move <b>ALL sticks</b>, Throttle stick included.</p>"), 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

View File

@ -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();