1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-31 16:52:10 +01:00

Merge remote-tracking branch 'origin/samguns/OP-1781_ground_input_channel_conf' into next

This commit is contained in:
m_thread 2015-03-28 12:33:24 +01:00
commit 4bd2e889ce
4 changed files with 106 additions and 6 deletions

View File

@ -300,7 +300,7 @@ static void receiverTask(__attribute__((unused)) void *parameters)
settings.FlightModeNumber < 1 || settings.FlightModeNumber > FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM settings.FlightModeNumber < 1 || settings.FlightModeNumber > FLIGHTMODESETTINGS_FLIGHTMODEPOSITION_NUMELEM
|| ||
// Similar checks for FlightMode channel but only if more than one flight mode has been set. Otherwise don't care // Similar checks for FlightMode channel but only if more than one flight mode has been set. Otherwise don't care
((settings.FlightModeNumber > 1) ((settings.FlightModeNumber > 1) && (frameType != FRAME_TYPE_GROUND)
&& (settings.ChannelGroups.FlightMode >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE && (settings.ChannelGroups.FlightMode >= MANUALCONTROLSETTINGS_CHANNELGROUPS_NONE
|| cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_INVALID || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_INVALID
|| cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_NODRIVER))) { || cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE] == (uint16_t)PIOS_RCVR_NODRIVER))) {

View File

@ -72,6 +72,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(), 1); accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(), 1);
accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(), 2); accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(), 2);
actuatorSettingsObj = ActuatorSettings::GetInstance(getObjectManager()); actuatorSettingsObj = ActuatorSettings::GetInstance(getObjectManager());
systemSettingsObj = SystemSettings::GetInstance(getObjectManager());
// Only instance 0 is present if the board is not connected. // Only instance 0 is present if the board is not connected.
// The other instances are populated lazily. // The other instances are populated lazily.
@ -349,6 +350,10 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 << ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY2; ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
ManualControlSettings::CHANNELGROUPS_YAW <<
ManualControlSettings::CHANNELGROUPS_ACCESSORY0;
updateEnableControls(); updateEnableControls();
} }
@ -420,6 +425,10 @@ void ConfigInputWidget::goToWizard()
actuatorSettingsData = actuatorSettingsObj->getData(); actuatorSettingsData = actuatorSettingsObj->getData();
previousActuatorSettingsData = actuatorSettingsData; previousActuatorSettingsData = actuatorSettingsData;
// Stash systemSettings
systemSettingsData = systemSettingsObj->getData();
previousSystemSettingsData = systemSettingsData;
// Now reset channel and actuator settings (disable outputs) // Now reset channel and actuator settings (disable outputs)
resetChannelSettings(); resetChannelSettings();
resetActuatorSettings(); resetActuatorSettings();
@ -463,6 +472,7 @@ void ConfigInputWidget::wzCancel()
manualSettingsObj->setData(previousManualSettingsData); manualSettingsObj->setData(previousManualSettingsData);
flightModeSettingsObj->setData(previousFlightModeSettingsData); flightModeSettingsObj->setData(previousFlightModeSettingsData);
actuatorSettingsObj->setData(previousActuatorSettingsData); actuatorSettingsObj->setData(previousActuatorSettingsData);
systemSettingsObj->setData(previousSystemSettingsData);
} }
void ConfigInputWidget::registerControlActivity() void ConfigInputWidget::registerControlActivity()
@ -552,6 +562,11 @@ void ConfigInputWidget::wzNext()
throttleError = false; throttleError = false;
checkThrottleRange(); checkThrottleRange();
// Force flight mode number to be 1 if 2 CH ground vehicle was selected
if (transmitterType == ground) {
forceOneFlightMode();
}
manualSettingsObj->setData(manualSettingsData); manualSettingsObj->setData(manualSettingsData);
// move to Arming Settings tab // move to Arming Settings tab
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
@ -629,6 +644,8 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
wizardUi->wzBack->setEnabled(true); wizardUi->wzBack->setEnabled(true);
if (transmitterType == heli) { if (transmitterType == heli) {
wizardUi->typeHeli->setChecked(true); wizardUi->typeHeli->setChecked(true);
} else if (transmitterType == ground) {
wizardUi->typeGround->setChecked(true);
} else { } else {
wizardUi->typeAcro->setChecked(true); wizardUi->typeAcro->setChecked(true);
} }
@ -687,6 +704,10 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
case wizardIdentifyCenter: case wizardIdentifyCenter:
setTxMovement(centerAll); setTxMovement(centerAll);
wizardUi->pagesStack->setCurrentWidget(wizardUi->identifyCenterPage); wizardUi->pagesStack->setCurrentWidget(wizardUi->identifyCenterPage);
if (transmitterType == ground) {
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.")));
}
break; break;
case wizardIdentifyLimits: case wizardIdentifyLimits:
{ {
@ -752,6 +773,12 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
case wizardChooseType: case wizardChooseType:
if (wizardUi->typeAcro->isChecked()) { if (wizardUi->typeAcro->isChecked()) {
transmitterType = acro; transmitterType = acro;
} else if (wizardUi->typeGround->isChecked()) {
transmitterType = ground;
/* Make sure to tell controller, this is really a ground vehicle. */
systemSettingsData = systemSettingsObj->getData();
systemSettingsData.AirframeType = SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR;
systemSettingsObj->setData(systemSettingsData);
} else { } else {
transmitterType = heli; transmitterType = heli;
} }
@ -885,7 +912,18 @@ void ConfigInputWidget::setChannel(int newChan)
*/ */
void ConfigInputWidget::nextChannel() void ConfigInputWidget::nextChannel()
{ {
QList <int> order = (transmitterType == heli) ? heliChannelOrder : acroChannelOrder; QList <int> order;
switch (transmitterType) {
case heli:
order = heliChannelOrder;
break;
case ground:
order = groundChannelOrder;
break;
default:
order = acroChannelOrder;
break;
}
if (currentChannelNum == -1) { if (currentChannelNum == -1) {
setChannel(order[0]); setChannel(order[0]);
@ -906,7 +944,18 @@ void ConfigInputWidget::nextChannel()
*/ */
void ConfigInputWidget::prevChannel() void ConfigInputWidget::prevChannel()
{ {
QList <int> order = transmitterType == heli ? heliChannelOrder : acroChannelOrder; QList <int> order;
switch (transmitterType) {
case heli:
order = heliChannelOrder;
break;
case ground:
order = groundChannelOrder;
break;
default:
order = acroChannelOrder;
break;
}
// No previous from unset channel or next state // No previous from unset channel or next state
if (currentChannelNum == -1) { if (currentChannelNum == -1) {
@ -1014,6 +1063,7 @@ void ConfigInputWidget::identifyLimits()
} }
manualSettingsObj->setData(manualSettingsData); manualSettingsObj->setData(manualSettingsData);
} }
void ConfigInputWidget::setMoveFromCommand(int command) void ConfigInputWidget::setMoveFromCommand(int command)
{ {
// ManualControlSettings::ChannelNumberElem: // ManualControlSettings::ChannelNumberElem:
@ -1634,8 +1684,31 @@ void ConfigInputWidget::simpleCalibration(bool enable)
manualCommandData = manualCommandObj->getData(); manualCommandData = manualCommandObj->getData();
manualSettingsData = manualSettingsObj->getData(); manualSettingsData = manualSettingsObj->getData();
QMessageBox::StandardButton reply;
reply = QMessageBox::question(this, tr("Ground vehicle"),
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>"
"<p>Attention, if you press <b>Yes</b>, then the <b>Flight Mode Count</b> will be set to 1.</p>"),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
transmitterType = ground;
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] =
manualCommandData.Channel[ManualControlSettings::CHANNELNUMBER_THROTTLE];
/* Make sure to tell controller, this is really a ground vehicle. */
systemSettingsData = systemSettingsObj->getData();
systemSettingsData.AirframeType = SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR;
systemSettingsObj->setData(systemSettingsData);
}
restoreMdataSingle(manualCommandObj, &manualControlMdata); restoreMdataSingle(manualCommandObj, &manualControlMdata);
// Force flight mode number to be 1 if 2 channel ground vehicle was confirmed
if (transmitterType == ground) {
forceOneFlightMode();
}
for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) { for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) {
if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) { if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) {
adjustSpecialNeutrals(); adjustSpecialNeutrals();
@ -1667,6 +1740,12 @@ void ConfigInputWidget::adjustSpecialNeutrals()
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] + (manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] +
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]) / 2; 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 // Force throttle to be near min, add 4% from total range to avoid arming issues
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] = manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE] =
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE] + manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE] +
@ -1737,3 +1816,10 @@ void ConfigInputWidget::resetActuatorSettings()
actuatorSettingsObj->setData(actuatorSettingsData); actuatorSettingsObj->setData(actuatorSettingsData);
} }
} }
void ConfigInputWidget::forceOneFlightMode()
{
manualCommandData = manualCommandObj->getData();
manualSettingsData.FlightModeNumber = 1;
manualSettingsObj->setData(manualSettingsData);
}

View File

@ -50,6 +50,7 @@
#include "flightstatus.h" #include "flightstatus.h"
#include "accessorydesired.h" #include "accessorydesired.h"
#include <QPointer> #include <QPointer>
#include "systemsettings.h"
class Ui_InputWidget; class Ui_InputWidget;
@ -62,7 +63,7 @@ public:
enum txMode { mode1, mode2, mode3, mode4 }; enum txMode { mode1, mode2, mode3, mode4 };
enum txMovements { moveLeftVerticalStick, moveRightVerticalStick, moveLeftHorizontalStick, moveRightHorizontalStick, moveAccess0, moveAccess1, moveAccess2, moveFlightMode, centerAll, moveAll, nothing }; enum txMovements { moveLeftVerticalStick, moveRightVerticalStick, moveLeftHorizontalStick, moveRightHorizontalStick, moveAccess0, moveAccess1, moveAccess2, moveFlightMode, centerAll, moveAll, nothing };
enum txMovementType { vertical, horizontal, jump, mix }; enum txMovementType { vertical, horizontal, jump, mix };
enum txType { acro, heli }; enum txType { acro, heli, ground };
void startInputWizard() void startInputWizard()
{ {
goToWizard(); goToWizard();
@ -111,6 +112,7 @@ private:
int currentChannelNum; int currentChannelNum;
QList<int> heliChannelOrder; QList<int> heliChannelOrder;
QList<int> acroChannelOrder; QList<int> acroChannelOrder;
QList<int> groundChannelOrder;
UAVObject::Metadata manualControlMdata; UAVObject::Metadata manualControlMdata;
ManualControlCommand *manualCommandObj; ManualControlCommand *manualCommandObj;
@ -138,6 +140,10 @@ private:
ReceiverActivity *receiverActivityObj; ReceiverActivity *receiverActivityObj;
ReceiverActivity::DataFields receiverActivityData; ReceiverActivity::DataFields receiverActivityData;
SystemSettings *systemSettingsObj;
SystemSettings::DataFields systemSettingsData;
SystemSettings::DataFields previousSystemSettingsData;
QSvgRenderer *m_renderer; QSvgRenderer *m_renderer;
// Background: background // Background: background
@ -204,6 +210,7 @@ private slots:
void updateCalibration(); void updateCalibration();
void resetChannelSettings(); void resetChannelSettings();
void resetActuatorSettings(); void resetActuatorSettings();
void forceOneFlightMode();
protected: protected:
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);

View File

@ -64,6 +64,13 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QRadioButton" name="typeGround">
<property name="text">
<string>Surface: has reversible motor controlled by throttle stick, plus yaw control (2 channels)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QRadioButton" name="typeHeli"> <widget class="QRadioButton" name="typeHeli">
<property name="text"> <property name="text">
@ -74,7 +81,7 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
<item> <item>
<widget class="QLabel" name="typePageFooter"> <widget class="QLabel" name="typePageFooter">
<property name="text"> <property name="text">
<string>If selecting the Helicopter option, please engage throttle hold now.</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If selecting the Helicopter option, please engage throttle hold now.&lt;/p&gt;&lt;p&gt;If selecting the Surface option, the &lt;b&gt;Flight Mode Count&lt;/b&gt; will be set to be 1.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
@ -89,7 +96,7 @@ You can press 'back' at any time to return to the previous screen or press 'Canc
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>23</height>
</size> </size>
</property> </property>
</spacer> </spacer>