1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-18 08:54:15 +01:00

OP-1781 I think it's almost done, ready for a thoroughly test and review

This commit is contained in:
samguns 2015-03-18 14:58:46 +08:00
parent 22e0b88a8f
commit 97fd54b25d
3 changed files with 38 additions and 8 deletions

View File

@ -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("<p>Are you configuring a transmitter for your <b>ground vehicle</b> with reversible motor<br>"
"controlled by throttle stick?</p>"
"<p>If so, please make sure you've centered throttle control and press <b>Yes</b> button. Otherwise, press No.</p>"));
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()

View File

@ -193,6 +193,7 @@ private slots:
void openHelp();
void identifyControls();
void identifyLimits();
void identifyCenters();
void moveTxControls();
void moveSticks();
void dimOtherControls(bool value);

View File

@ -67,7 +67,7 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
<item>
<widget class="QRadioButton" name="typeGround">
<property name="text">
<string>Ground vehicle: has at least two channels for throttle and steering (yaw)</string>
<string>Surface: has reversible motor controlled by throttle stick</string>
</property>
</widget>
</item>