diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index 6481259aa..ac6b56300 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -696,7 +696,9 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step) setTxMovement(centerAll); wizardUi->pagesStack->setCurrentWidget(wizardUi->identifyCenterPage); if (transmitterType == ground) { - wizardUi->identifyCenterInstructions->setText(QString(tr("Please center all controls and trims and press Next when ready."))); + wizardUi->identifyCenterInstructions->setText(QString(tr("Please center all controls and trims and press Next when ready.\n\n" + "For a ground vehicle, this center position will be used as neutral value of each channel."))); + connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyCenters())); } break; case wizardIdentifyLimits: @@ -1041,6 +1043,19 @@ void ConfigInputWidget::identifyLimits() } manualSettingsObj->setData(manualSettingsData); } + +void ConfigInputWidget::identifyCenters() +{ + if (transmitterType != ground) + return; + + manualCommandData = manualCommandObj->getData(); + manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNUMBER_THROTTLE] = + manualCommandData.Channel[ManualControlSettings::CHANNELNUMBER_THROTTLE]; + + manualSettingsObj->setData(manualSettingsData); +} + void ConfigInputWidget::setMoveFromCommand(int command) { // ManualControlSettings::ChannelNumberElem: @@ -1661,6 +1676,21 @@ void ConfigInputWidget::simpleCalibration(bool enable) manualCommandData = manualCommandObj->getData(); manualSettingsData = manualSettingsObj->getData(); + QMessageBox msgBox; + QPushButton *yesButton = msgBox.addButton(tr("Yes"), QMessageBox::YesRole); + QPushButton *noButton = msgBox.addButton(tr("No"), QMessageBox::NoRole); + msgBox.setText(tr("

Are you configuring a transmitter for your ground vehicle with reversible motor
" + "controlled by throttle stick?

" + "

If so, please make sure you've centered throttle control and press Yes button. Otherwise, press No.

")); + msgBox.setDefaultButton(noButton); + msgBox.exec(); + + if (msgBox.clickedButton() == yesButton) { + transmitterType = ground; + manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] = + manualCommandData.Channel[ManualControlSettings::CHANNELNUMBER_THROTTLE]; + } + restoreMdataSingle(manualCommandObj, &manualControlMdata); for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) { @@ -1694,17 +1724,16 @@ void ConfigInputWidget::adjustSpecialNeutrals() (manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] + manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]) / 2; + // A ground vehicle has a reversible motor, the center position of throttle is the neutral setting. + // So do not have to set a special neutral value for it. + if (transmitterType == ground) + return; + // Force throttle to be near min, add 4% from total range to avoid arming issues manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] = manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE] + ((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] - manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) * 0.04); - - if (transmitterType == ground) { - manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] = - (manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE] + - manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]) / 2; - } } void ConfigInputWidget::checkThrottleRange() diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.h b/ground/openpilotgcs/src/plugins/config/configinputwidget.h index 61e1d2385..b65a389f1 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.h @@ -193,6 +193,7 @@ private slots: void openHelp(); void identifyControls(); void identifyLimits(); + void identifyCenters(); void moveTxControls(); void moveSticks(); void dimOtherControls(bool value); diff --git a/ground/openpilotgcs/src/plugins/config/input_wizard.ui b/ground/openpilotgcs/src/plugins/config/input_wizard.ui index 34b3b5945..95b594780 100644 --- a/ground/openpilotgcs/src/plugins/config/input_wizard.ui +++ b/ground/openpilotgcs/src/plugins/config/input_wizard.ui @@ -67,7 +67,7 @@ You can press 'back' at any time to return to the previous screen or press 'Canc - Ground vehicle: has at least two channels for throttle and steering (yaw) + Surface: has reversible motor controlled by throttle stick