Browse Source

Merge pull request #2934 from DonLakeFlyer/SimpleFlightMode

Simple flight mode config
QGC4.4
Don Gagne 9 years ago
parent
commit
f5776307c4
  1. 6
      qgroundcontrol.pro
  2. 4
      qgroundcontrol.qrc
  3. 20
      src/AutoPilotPlugins/PX4/FlightModesComponent.cc
  4. 54
      src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml
  5. 49
      src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml
  6. 116
      src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.cc
  7. 8
      src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.h
  8. 2
      src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc
  9. 67
      src/AutoPilotPlugins/PX4/PX4FlightModes.qml
  10. 140
      src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml
  11. 73
      src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc
  12. 62
      src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.h
  13. 2
      src/FactSystem/ParameterLoader.cc
  14. 201
      src/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml
  15. 6
      src/QGCApplication.cc
  16. 2
      src/VehicleSetup/VehicleComponent.cc

6
qgroundcontrol.pro

@ -590,7 +590,8 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \ src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \
src/AutoPilotPlugins/PX4/AirframeComponentController.h \ src/AutoPilotPlugins/PX4/AirframeComponentController.h \
src/AutoPilotPlugins/PX4/FlightModesComponent.h \ src/AutoPilotPlugins/PX4/FlightModesComponent.h \
src/AutoPilotPlugins/PX4/FlightModesComponentController.h \ src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.h \
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.h \
src/AutoPilotPlugins/PX4/PowerComponent.h \ src/AutoPilotPlugins/PX4/PowerComponent.h \
src/AutoPilotPlugins/PX4/PowerComponentController.h \ src/AutoPilotPlugins/PX4/PowerComponentController.h \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \ src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \
@ -646,7 +647,8 @@ SOURCES += \
src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \ src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \
src/AutoPilotPlugins/PX4/AirframeComponentController.cc \ src/AutoPilotPlugins/PX4/AirframeComponentController.cc \
src/AutoPilotPlugins/PX4/FlightModesComponent.cc \ src/AutoPilotPlugins/PX4/FlightModesComponent.cc \
src/AutoPilotPlugins/PX4/FlightModesComponentController.cc \ src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.cc \
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc \
src/AutoPilotPlugins/PX4/PowerComponent.cc \ src/AutoPilotPlugins/PX4/PowerComponent.cc \
src/AutoPilotPlugins/PX4/PowerComponentController.cc \ src/AutoPilotPlugins/PX4/PowerComponentController.cc \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \ src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \

4
qgroundcontrol.qrc

@ -14,7 +14,9 @@
<file alias="LogDownload.qml">src/ViewWidgets/LogDownload.qml</file> <file alias="LogDownload.qml">src/ViewWidgets/LogDownload.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file> <file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="FlightDisplayView.qml">src/FlightDisplay/FlightDisplayView.qml</file> <file alias="FlightDisplayView.qml">src/FlightDisplay/FlightDisplayView.qml</file>
<file alias="FlightModesComponent.qml">src/AutoPilotPlugins/PX4/FlightModesComponent.qml</file> <file alias="PX4FlightModes.qml">src/AutoPilotPlugins/PX4/PX4FlightModes.qml</file>
<file alias="PX4AdvancedFlightModes.qml">src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml</file>
<file alias="PX4SimpleFlightModes.qml">src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml</file>
<file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file> <file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
<file alias="APMFlightModesComponent.qml">src/AutoPilotPlugins/APM/APMFlightModesComponent.qml</file> <file alias="APMFlightModesComponent.qml">src/AutoPilotPlugins/APM/APMFlightModesComponent.qml</file>
<file alias="APMFlightModesComponentSummary.qml">src/AutoPilotPlugins/APM/APMFlightModesComponentSummary.qml</file> <file alias="APMFlightModesComponentSummary.qml">src/AutoPilotPlugins/APM/APMFlightModesComponentSummary.qml</file>

20
src/AutoPilotPlugins/PX4/FlightModesComponent.cc

@ -63,18 +63,30 @@ bool FlightModesComponent::requiresSetup(void) const
bool FlightModesComponent::setupComplete(void) const bool FlightModesComponent::setupComplete(void) const
{ {
return _autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1 || if (_autopilot->getParameterFact(-1, "COM_RC_IN_MODE")->rawValue().toInt() == 1) {
_autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_MODE_SW")->rawValue().toInt() != 0; return true;
}
if (_autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_MODE_SW")->rawValue().toInt() != 0 ||
(_autopilot->parameterExists(FactSystem::defaultComponentId, "RC_MAP_FLTMODE") && _autopilot->getParameterFact(FactSystem::defaultComponentId, "RC_MAP_FLTMODE")->rawValue().toInt() != 0)) {
return true;
}
return false;
} }
QStringList FlightModesComponent::setupCompleteChangedTriggerList(void) const QStringList FlightModesComponent::setupCompleteChangedTriggerList(void) const
{ {
return QStringList("RC_MAP_MODE_SW"); QStringList list;
list << QStringLiteral("RC_MAP_MODE_SW") << QStringLiteral("RC_MAP_FLTMODE");
return list;
} }
QUrl FlightModesComponent::setupSource(void) const QUrl FlightModesComponent::setupSource(void) const
{ {
return QUrl::fromUserInput("qrc:/qml/FlightModesComponent.qml"); return QUrl::fromUserInput("qrc:/qml/PX4FlightModes.qml");
} }
QUrl FlightModesComponent::summaryQmlSource(void) const QUrl FlightModesComponent::summaryQmlSource(void) const

54
src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml

@ -5,6 +5,7 @@ import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0 import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0 import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0
FactPanel { FactPanel {
id: panel id: panel
@ -14,33 +15,68 @@ FactPanel {
QGCPalette { id: qgcPal; colorGroupEnabled: enabled } QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
FactPanelController { id: controller; factPanel: panel } FactPanelController { id: controller; factPanel: panel }
property Fact modeSwFact: controller.getParameterFact(-1, "RC_MAP_MODE_SW") property Fact _nullFact
property Fact posCtlSwFact: controller.getParameterFact(-1, "RC_MAP_POSCTL_SW") property Fact _rcMapFltmode: controller.parameterExists(-1, "RC_MAP_FLTMODE") ? controller.getParameterFact(-1, "RC_MAP_FLTMODE") : _nullFact
property Fact loiterSwFact: controller.getParameterFact(-1, "RC_MAP_LOITER_SW") property Fact _rcMapModeSw: controller.getParameterFact(-1, "RC_MAP_MODE_SW")
property Fact returnSwFact: controller.getParameterFact(-1, "RC_MAP_RETURN_SW") property bool _simpleMode: _rcMapFltmode.value > 0 || _rcMapModeSw.value == 0
Column {
Loader {
anchors.fill: parent anchors.fill: parent
sourceComponent: _simpleMode ? simple : advanced
}
Component {
id: simple
Column {
anchors.margins: 8 anchors.margins: 8
VehicleSummaryRow { VehicleSummaryRow {
labelText: "Mode switch:" labelText: "Mode switch:"
valueText: modeSwFact ? (modeSwFact.value === 0 ? "Setup required" : modeSwFact.valueString) : "" valueText: _rcMapFltmode.value === 0 ? "Setup required" : _rcMapFltmode.enumStringValue
}
Repeater {
model: 6
VehicleSummaryRow {
labelText: "Flight Mode " + (index + 1) + ":"
valueText: controller.getParameterFact(-1, "COM_FLTMODE" + (index + 1)).enumStringValue
}
}
}
}
Component {
id: advanced
Column {
anchors.margins: 8
property Fact posCtlSwFact: controller.getParameterFact(-1, "RC_MAP_POSCTL_SW")
property Fact loiterSwFact: controller.getParameterFact(-1, "RC_MAP_LOITER_SW")
property Fact returnSwFact: controller.getParameterFact(-1, "RC_MAP_RETURN_SW")
VehicleSummaryRow {
labelText: "Mode switch:"
valueText: _rcMapModeSw.value === 0 ? "Setup required" : _rcMapModeSw.valueString
} }
VehicleSummaryRow { VehicleSummaryRow {
labelText: "Position Ctl switch:" labelText: "Position Ctl switch:"
valueText: posCtlSwFact ? (posCtlSwFact.value === 0 ? "Disabled" : posCtlSwFact.valueString) : "" valueText: posCtlSwFact.value === 0 ? "Disabled" : posCtlSwFact.valueString
} }
VehicleSummaryRow { VehicleSummaryRow {
labelText: "Loiter switch:" labelText: "Loiter switch:"
valueText: loiterSwFact ? (loiterSwFact.value === 0 ? "Disabled" : loiterSwFact.valueString) : "" valueText: loiterSwFact.value === 0 ? "Disabled" : loiterSwFact.valueString
} }
VehicleSummaryRow { VehicleSummaryRow {
labelText: "Return switch:" labelText: "Return switch:"
valueText: returnSwFact ? (returnSwFact.value === 0 ? "Disabled" : returnSwFact.valueString) : "" valueText: returnSwFact.value === 0 ? "Disabled" : returnSwFact.valueString
}
} }
} }
} }

49
src/AutoPilotPlugins/PX4/FlightModesComponent.qml → src/AutoPilotPlugins/PX4/PX4AdvancedFlightModes.qml

@ -34,9 +34,13 @@ import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0 import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
QGCView { /// PX4 Advanced Flight Mode configuration
id: qgcView Item {
viewPanel: panel id: root
// The following properties must be pushed in from the Loader
//property var qgcView - QGCView control
//property var qgcViewPanel - QGCViewPanel control
readonly property int monitorThresholdCharWidth: 8 // Character width of Monitor and Threshold labels readonly property int monitorThresholdCharWidth: 8 // Character width of Monitor and Threshold labels
@ -120,13 +124,11 @@ QGCView {
readonly property real modeSpacing: ScreenTools.defaultFontPixelHeight / 3 readonly property real modeSpacing: ScreenTools.defaultFontPixelHeight / 3
property Fact rcInMode: controller.getParameterFact(-1, "COM_RC_IN_MODE")
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
FlightModesComponentController { PX4AdvancedFlightModesController {
id: controller id: controller
factPanel: panel factPanel: qgcViewPanel
onModeRowsChanged: recalcModePositions() onModeRowsChanged: recalcModePositions()
} }
@ -137,9 +139,6 @@ QGCView {
onTriggered: { onTriggered: {
recalcModePositions() recalcModePositions()
if (rcInMode.value == 1) {
showDialog(joystickEnabledDialogComponent, title, qgcView.showDialogDefaultWidth, 0)
}
} }
} }
@ -194,10 +193,6 @@ QGCView {
scrollItem.height = nextY scrollItem.height = nextY
} }
QGCViewPanel {
id: panel
anchors.fill: parent
Component { Component {
id: joystickEnabledDialogComponent id: joystickEnabledDialogComponent
@ -218,27 +213,40 @@ QGCView {
Item { Item {
id: helpApplyRow id: helpApplyRow
width: parent.width width: parent.width
height: Math.max(helpText.contentHeight, applyButton.height) height: Math.max(helpText.contentHeight, applyButton.y + applyButton.height)
QGCLabel { QGCLabel {
id: helpText id: helpText
anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left anchors.left: parent.left
anchors.right: applyButton.left anchors.right: buttonColumn.left
text: topHelpText text: topHelpText
font.pixelSize: ScreenTools.defaultFontPixelSize font.pixelSize: ScreenTools.defaultFontPixelSize
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
} }
QGCButton { Column {
id: applyButton id: buttonColumn
anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.rightMargin: ScreenTools.defaultFontPixelWidth
anchors.right: parent.right anchors.right: parent.right
text: "Generate Thresholds" spacing: ScreenTools.defaultFontPixelHeight / 4
QGCButton {
text: "Use Simple Flight Modes"
visible: controller.parameterExists(-1, "RC_MAP_FLTMODE")
onClicked: {
controller.getParameterFact(-1, "RC_MAP_MODE_SW").value = 0
controller.getParameterFact(-1, "RC_MAP_FLTMODE").value = 5
}
}
QGCButton {
id: applyButton
text: "Generate Thresholds"
onClicked: controller.generateThresholds() onClicked: controller.generateThresholds()
} }
} }
}
Item { Item {
id: lastSpacer id: lastSpacer
@ -414,5 +422,4 @@ QGCView {
} }
} // Item } // Item
} // Scroll View } // Scroll View
} // QGCViewPanel } // Item
} // QGCView

116
src/AutoPilotPlugins/PX4/FlightModesComponentController.cc → src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.cc

@ -24,14 +24,14 @@
/// @file /// @file
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
#include "FlightModesComponentController.h" #include "PX4AdvancedFlightModesController.h"
#include "QGCMAVLink.h" #include "QGCMAVLink.h"
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include <QVariant> #include <QVariant>
#include <QQmlProperty> #include <QQmlProperty>
FlightModesComponentController::FlightModesComponentController(void) : PX4AdvancedFlightModesController::PX4AdvancedFlightModesController(void) :
_validConfiguration(false), _validConfiguration(false),
_channelCount(18), _channelCount(18),
_manualModeSelected(false), _manualModeSelected(false),
@ -55,10 +55,10 @@ FlightModesComponentController::FlightModesComponentController(void) :
_init(); _init();
_validateConfiguration(); _validateConfiguration();
connect(_vehicle, &Vehicle::rcChannelsChanged, this, &FlightModesComponentController::_rcChannelsChanged); connect(_vehicle, &Vehicle::rcChannelsChanged, this, &PX4AdvancedFlightModesController::_rcChannelsChanged);
} }
void FlightModesComponentController::_init(void) void PX4AdvancedFlightModesController::_init(void)
{ {
// FIXME: What about VTOL? That confuses the whole Flight Mode naming scheme // FIXME: What about VTOL? That confuses the whole Flight Mode naming scheme
_fixedWing = _vehicle->vehicleType() == MAV_TYPE_FIXED_WING; _fixedWing = _vehicle->vehicleType() == MAV_TYPE_FIXED_WING;
@ -151,7 +151,7 @@ void FlightModesComponentController::_init(void)
/// This will look for parameter settings which would cause the config to not run correctly. /// This will look for parameter settings which would cause the config to not run correctly.
/// It will set _validConfiguration and _configurationErrors as needed. /// It will set _validConfiguration and _configurationErrors as needed.
void FlightModesComponentController::_validateConfiguration(void) void PX4AdvancedFlightModesController::_validateConfiguration(void)
{ {
_validConfiguration = true; _validConfiguration = true;
@ -205,7 +205,7 @@ void FlightModesComponentController::_validateConfiguration(void)
} }
/// Connected to Vehicle::rcChannelsChanged signal /// Connected to Vehicle::rcChannelsChanged signal
void FlightModesComponentController::_rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]) void PX4AdvancedFlightModesController::_rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels])
{ {
for (int channel=0; channel<channelCount; channel++) { for (int channel=0; channel<channelCount; channel++) {
int channelValue = pwmValues[channel]; int channelValue = pwmValues[channel];
@ -232,7 +232,7 @@ void FlightModesComponentController::_rcChannelsChanged(int channelCount, int pw
emit switchLiveRangeChanged(); emit switchLiveRangeChanged();
} }
double FlightModesComponentController::_switchLiveRange(const QString& param) double PX4AdvancedFlightModesController::_switchLiveRange(const QString& param)
{ {
QVariant value; QVariant value;
@ -244,27 +244,27 @@ double FlightModesComponentController::_switchLiveRange(const QString& param)
} }
} }
double FlightModesComponentController::manualModeRcValue(void) double PX4AdvancedFlightModesController::manualModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_MODE_SW"); return _switchLiveRange("RC_MAP_MODE_SW");
} }
double FlightModesComponentController::assistModeRcValue(void) double PX4AdvancedFlightModesController::assistModeRcValue(void)
{ {
return manualModeRcValue(); return manualModeRcValue();
} }
double FlightModesComponentController::autoModeRcValue(void) double PX4AdvancedFlightModesController::autoModeRcValue(void)
{ {
return manualModeRcValue(); return manualModeRcValue();
} }
double FlightModesComponentController::acroModeRcValue(void) double PX4AdvancedFlightModesController::acroModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_ACRO_SW"); return _switchLiveRange("RC_MAP_ACRO_SW");
} }
double FlightModesComponentController::altCtlModeRcValue(void) double PX4AdvancedFlightModesController::altCtlModeRcValue(void)
{ {
int posCtlSwitchChannel = getParameterFact(-1, "RC_MAP_POSCTL_SW")->rawValue().toInt(); int posCtlSwitchChannel = getParameterFact(-1, "RC_MAP_POSCTL_SW")->rawValue().toInt();
@ -275,12 +275,12 @@ double FlightModesComponentController::altCtlModeRcValue(void)
} }
} }
double FlightModesComponentController::posCtlModeRcValue(void) double PX4AdvancedFlightModesController::posCtlModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_POSCTL_SW"); return _switchLiveRange("RC_MAP_POSCTL_SW");
} }
double FlightModesComponentController::missionModeRcValue(void) double PX4AdvancedFlightModesController::missionModeRcValue(void)
{ {
int returnSwitchChannel = getParameterFact(-1, "RC_MAP_RETURN_SW")->rawValue().toInt(); int returnSwitchChannel = getParameterFact(-1, "RC_MAP_RETURN_SW")->rawValue().toInt();
int loiterSwitchChannel = getParameterFact(-1, "RC_MAP_LOITER_SW")->rawValue().toInt(); int loiterSwitchChannel = getParameterFact(-1, "RC_MAP_LOITER_SW")->rawValue().toInt();
@ -302,22 +302,22 @@ double FlightModesComponentController::missionModeRcValue(void)
return _switchLiveRange(switchChannelParam); return _switchLiveRange(switchChannelParam);
} }
double FlightModesComponentController::loiterModeRcValue(void) double PX4AdvancedFlightModesController::loiterModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_LOITER_SW"); return _switchLiveRange("RC_MAP_LOITER_SW");
} }
double FlightModesComponentController::returnModeRcValue(void) double PX4AdvancedFlightModesController::returnModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_RETURN_SW"); return _switchLiveRange("RC_MAP_RETURN_SW");
} }
double FlightModesComponentController::offboardModeRcValue(void) double PX4AdvancedFlightModesController::offboardModeRcValue(void)
{ {
return _switchLiveRange("RC_MAP_OFFB_SW"); return _switchLiveRange("RC_MAP_OFFB_SW");
} }
void FlightModesComponentController::_recalcModeSelections(void) void PX4AdvancedFlightModesController::_recalcModeSelections(void)
{ {
_manualModeSelected = false; _manualModeSelected = false;
_assistModeSelected = false; _assistModeSelected = false;
@ -377,7 +377,7 @@ void FlightModesComponentController::_recalcModeSelections(void)
emit modesSelectedChanged(); emit modesSelectedChanged();
} }
void FlightModesComponentController::_recalcModeRows(void) void PX4AdvancedFlightModesController::_recalcModeRows(void)
{ {
int modeSwitchChannel = getParameterFact(-1, "RC_MAP_MODE_SW")->rawValue().toInt(); int modeSwitchChannel = getParameterFact(-1, "RC_MAP_MODE_SW")->rawValue().toInt();
int acroSwitchChannel = getParameterFact(-1, "RC_MAP_ACRO_SW")->rawValue().toInt(); int acroSwitchChannel = getParameterFact(-1, "RC_MAP_ACRO_SW")->rawValue().toInt();
@ -467,140 +467,140 @@ void FlightModesComponentController::_recalcModeRows(void)
emit modeRowsChanged(); emit modeRowsChanged();
} }
double FlightModesComponentController::manualModeThreshold(void) double PX4AdvancedFlightModesController::manualModeThreshold(void)
{ {
return 0.0; return 0.0;
} }
double FlightModesComponentController::assistModeThreshold(void) double PX4AdvancedFlightModesController::assistModeThreshold(void)
{ {
return getParameterFact(-1, "RC_ASSIST_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_ASSIST_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::autoModeThreshold(void) double PX4AdvancedFlightModesController::autoModeThreshold(void)
{ {
return getParameterFact(-1, "RC_AUTO_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_AUTO_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::acroModeThreshold(void) double PX4AdvancedFlightModesController::acroModeThreshold(void)
{ {
return getParameterFact(-1, "RC_ACRO_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_ACRO_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::altCtlModeThreshold(void) double PX4AdvancedFlightModesController::altCtlModeThreshold(void)
{ {
return _assistModeVisible ? 0.0 : getParameterFact(-1, "RC_ASSIST_TH")->rawValue().toDouble(); return _assistModeVisible ? 0.0 : getParameterFact(-1, "RC_ASSIST_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::posCtlModeThreshold(void) double PX4AdvancedFlightModesController::posCtlModeThreshold(void)
{ {
return getParameterFact(-1, "RC_POSCTL_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_POSCTL_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::missionModeThreshold(void) double PX4AdvancedFlightModesController::missionModeThreshold(void)
{ {
return _autoModeVisible ? 0.0 : getParameterFact(-1, "RC_AUTO_TH")->rawValue().toDouble(); return _autoModeVisible ? 0.0 : getParameterFact(-1, "RC_AUTO_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::loiterModeThreshold(void) double PX4AdvancedFlightModesController::loiterModeThreshold(void)
{ {
return getParameterFact(-1, "RC_LOITER_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_LOITER_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::returnModeThreshold(void) double PX4AdvancedFlightModesController::returnModeThreshold(void)
{ {
return getParameterFact(-1, "RC_RETURN_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_RETURN_TH")->rawValue().toDouble();
} }
double FlightModesComponentController::offboardModeThreshold(void) double PX4AdvancedFlightModesController::offboardModeThreshold(void)
{ {
return getParameterFact(-1, "RC_OFFB_TH")->rawValue().toDouble(); return getParameterFact(-1, "RC_OFFB_TH")->rawValue().toDouble();
} }
void FlightModesComponentController::setAssistModeThreshold(double threshold) void PX4AdvancedFlightModesController::setAssistModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_ASSIST_TH")->setRawValue(threshold); getParameterFact(-1, "RC_ASSIST_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setAutoModeThreshold(double threshold) void PX4AdvancedFlightModesController::setAutoModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_AUTO_TH")->setRawValue(threshold); getParameterFact(-1, "RC_AUTO_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setAcroModeThreshold(double threshold) void PX4AdvancedFlightModesController::setAcroModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_ACRO_TH")->setRawValue(threshold); getParameterFact(-1, "RC_ACRO_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setAltCtlModeThreshold(double threshold) void PX4AdvancedFlightModesController::setAltCtlModeThreshold(double threshold)
{ {
setAssistModeThreshold(threshold); setAssistModeThreshold(threshold);
} }
void FlightModesComponentController::setPosCtlModeThreshold(double threshold) void PX4AdvancedFlightModesController::setPosCtlModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_POSCTL_TH")->setRawValue(threshold); getParameterFact(-1, "RC_POSCTL_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setMissionModeThreshold(double threshold) void PX4AdvancedFlightModesController::setMissionModeThreshold(double threshold)
{ {
setAutoModeThreshold(threshold); setAutoModeThreshold(threshold);
} }
void FlightModesComponentController::setLoiterModeThreshold(double threshold) void PX4AdvancedFlightModesController::setLoiterModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_LOITER_TH")->setRawValue(threshold); getParameterFact(-1, "RC_LOITER_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setReturnModeThreshold(double threshold) void PX4AdvancedFlightModesController::setReturnModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_RETURN_TH")->setRawValue(threshold); getParameterFact(-1, "RC_RETURN_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
void FlightModesComponentController::setOffboardModeThreshold(double threshold) void PX4AdvancedFlightModesController::setOffboardModeThreshold(double threshold)
{ {
getParameterFact(-1, "RC_OFFB_TH")->setRawValue(threshold); getParameterFact(-1, "RC_OFFB_TH")->setRawValue(threshold);
_recalcModeSelections(); _recalcModeSelections();
} }
int FlightModesComponentController::_channelToChannelIndex(int channel) int PX4AdvancedFlightModesController::_channelToChannelIndex(int channel)
{ {
return _channelListModelChannel.lastIndexOf(channel); return _channelListModelChannel.lastIndexOf(channel);
} }
int FlightModesComponentController::_channelToChannelIndex(const QString& channelParam) int PX4AdvancedFlightModesController::_channelToChannelIndex(const QString& channelParam)
{ {
return _channelToChannelIndex(getParameterFact(-1, channelParam)->rawValue().toInt()); return _channelToChannelIndex(getParameterFact(-1, channelParam)->rawValue().toInt());
} }
int FlightModesComponentController::manualModeChannelIndex(void) int PX4AdvancedFlightModesController::manualModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_MODE_SW"); return _channelToChannelIndex("RC_MAP_MODE_SW");
} }
int FlightModesComponentController::assistModeChannelIndex(void) int PX4AdvancedFlightModesController::assistModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_MODE_SW"); return _channelToChannelIndex("RC_MAP_MODE_SW");
} }
int FlightModesComponentController::autoModeChannelIndex(void) int PX4AdvancedFlightModesController::autoModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_MODE_SW"); return _channelToChannelIndex("RC_MAP_MODE_SW");
} }
int FlightModesComponentController::acroModeChannelIndex(void) int PX4AdvancedFlightModesController::acroModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_ACRO_SW"); return _channelToChannelIndex("RC_MAP_ACRO_SW");
} }
int FlightModesComponentController::altCtlModeChannelIndex(void) int PX4AdvancedFlightModesController::altCtlModeChannelIndex(void)
{ {
int posCtlSwitchChannel = getParameterFact(-1, "RC_MAP_POSCTL_SW")->rawValue().toInt(); int posCtlSwitchChannel = getParameterFact(-1, "RC_MAP_POSCTL_SW")->rawValue().toInt();
@ -611,17 +611,17 @@ int FlightModesComponentController::altCtlModeChannelIndex(void)
} }
} }
int FlightModesComponentController::posCtlModeChannelIndex(void) int PX4AdvancedFlightModesController::posCtlModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_POSCTL_SW"); return _channelToChannelIndex("RC_MAP_POSCTL_SW");
} }
int FlightModesComponentController::loiterModeChannelIndex(void) int PX4AdvancedFlightModesController::loiterModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_LOITER_SW"); return _channelToChannelIndex("RC_MAP_LOITER_SW");
} }
int FlightModesComponentController::missionModeChannelIndex(void) int PX4AdvancedFlightModesController::missionModeChannelIndex(void)
{ {
int loiterSwitchChannel = getParameterFact(-1, "RC_MAP_LOITER_SW")->rawValue().toInt(); int loiterSwitchChannel = getParameterFact(-1, "RC_MAP_LOITER_SW")->rawValue().toInt();
@ -632,22 +632,22 @@ int FlightModesComponentController::missionModeChannelIndex(void)
} }
} }
int FlightModesComponentController::returnModeChannelIndex(void) int PX4AdvancedFlightModesController::returnModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_RETURN_SW"); return _channelToChannelIndex("RC_MAP_RETURN_SW");
} }
int FlightModesComponentController::offboardModeChannelIndex(void) int PX4AdvancedFlightModesController::offboardModeChannelIndex(void)
{ {
return _channelToChannelIndex("RC_MAP_OFFB_SW"); return _channelToChannelIndex("RC_MAP_OFFB_SW");
} }
int FlightModesComponentController::_channelIndexToChannel(int index) int PX4AdvancedFlightModesController::_channelIndexToChannel(int index)
{ {
return _channelListModelChannel[index]; return _channelListModelChannel[index];
} }
void FlightModesComponentController::setManualModeChannelIndex(int index) void PX4AdvancedFlightModesController::setManualModeChannelIndex(int index)
{ {
getParameterFact(-1, "RC_MAP_MODE_SW")->setRawValue(_channelIndexToChannel(index)); getParameterFact(-1, "RC_MAP_MODE_SW")->setRawValue(_channelIndexToChannel(index));
@ -657,7 +657,7 @@ void FlightModesComponentController::setManualModeChannelIndex(int index)
} }
void FlightModesComponentController::setAcroModeChannelIndex(int index) void PX4AdvancedFlightModesController::setAcroModeChannelIndex(int index)
{ {
getParameterFact(-1, "RC_MAP_ACRO_SW")->setRawValue(_channelIndexToChannel(index)); getParameterFact(-1, "RC_MAP_ACRO_SW")->setRawValue(_channelIndexToChannel(index));
@ -665,7 +665,7 @@ void FlightModesComponentController::setAcroModeChannelIndex(int index)
_recalcModeRows(); _recalcModeRows();
} }
void FlightModesComponentController::setPosCtlModeChannelIndex(int index) void PX4AdvancedFlightModesController::setPosCtlModeChannelIndex(int index)
{ {
int channel = _channelIndexToChannel(index); int channel = _channelIndexToChannel(index);
@ -687,7 +687,7 @@ void FlightModesComponentController::setPosCtlModeChannelIndex(int index)
} }
void FlightModesComponentController::setLoiterModeChannelIndex(int index) void PX4AdvancedFlightModesController::setLoiterModeChannelIndex(int index)
{ {
int channel = _channelIndexToChannel(index); int channel = _channelIndexToChannel(index);
@ -709,7 +709,7 @@ void FlightModesComponentController::setLoiterModeChannelIndex(int index)
} }
void FlightModesComponentController::setReturnModeChannelIndex(int index) void PX4AdvancedFlightModesController::setReturnModeChannelIndex(int index)
{ {
getParameterFact(-1, "RC_MAP_RETURN_SW")->setRawValue(_channelIndexToChannel(index)); getParameterFact(-1, "RC_MAP_RETURN_SW")->setRawValue(_channelIndexToChannel(index));
_recalcModeSelections(); _recalcModeSelections();
@ -718,7 +718,7 @@ void FlightModesComponentController::setReturnModeChannelIndex(int index)
} }
void FlightModesComponentController::setOffboardModeChannelIndex(int index) void PX4AdvancedFlightModesController::setOffboardModeChannelIndex(int index)
{ {
getParameterFact(-1, "RC_MAP_OFFB_SW")->setRawValue(_channelIndexToChannel(index)); getParameterFact(-1, "RC_MAP_OFFB_SW")->setRawValue(_channelIndexToChannel(index));
_recalcModeSelections(); _recalcModeSelections();
@ -727,7 +727,7 @@ void FlightModesComponentController::setOffboardModeChannelIndex(int index)
} }
void FlightModesComponentController::generateThresholds(void) void PX4AdvancedFlightModesController::generateThresholds(void)
{ {
// Reset all thresholds to 0.0 // Reset all thresholds to 0.0

8
src/AutoPilotPlugins/PX4/FlightModesComponentController.h → src/AutoPilotPlugins/PX4/PX4AdvancedFlightModesController.h

@ -24,8 +24,8 @@
/// @file /// @file
/// @author Don Gagne <don@thegagnes.com> /// @author Don Gagne <don@thegagnes.com>
#ifndef FLIGHTMODESCOMPONENTCONTROLLER_H #ifndef PX4AdvancedFlightModesController_H
#define FLIGHTMODESCOMPONENTCONTROLLER_H #define PX4AdvancedFlightModesController_H
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
@ -37,12 +37,12 @@
#include "FactPanelController.h" #include "FactPanelController.h"
/// MVC Controller for FlightModesComponent.qml. /// MVC Controller for FlightModesComponent.qml.
class FlightModesComponentController : public FactPanelController class PX4AdvancedFlightModesController : public FactPanelController
{ {
Q_OBJECT Q_OBJECT
public: public:
FlightModesComponentController(void); PX4AdvancedFlightModesController(void);
Q_PROPERTY(bool validConfiguration MEMBER _validConfiguration CONSTANT) Q_PROPERTY(bool validConfiguration MEMBER _validConfiguration CONSTANT)
Q_PROPERTY(QString configurationErrors MEMBER _configurationErrors CONSTANT) Q_PROPERTY(QString configurationErrors MEMBER _configurationErrors CONSTANT)

2
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc

@ -24,7 +24,7 @@
#include "PX4AutoPilotPlugin.h" #include "PX4AutoPilotPlugin.h"
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "PX4AirframeLoader.h" #include "PX4AirframeLoader.h"
#include "FlightModesComponentController.h" #include "PX4AdvancedFlightModesController.h"
#include "AirframeComponentController.h" #include "AirframeComponentController.h"
#include "UAS.h" #include "UAS.h"
#include "FirmwarePlugin/PX4/PX4ParameterMetaData.h" // FIXME: Hack #include "FirmwarePlugin/PX4/PX4ParameterMetaData.h" // FIXME: Hack

67
src/AutoPilotPlugins/PX4/PX4FlightModes.qml

@ -0,0 +1,67 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0
/// PX4 Flight Mode configuration. This control will load either the Simple or Advanced Flight Mode config
/// based on current parameter settings.
QGCView {
id: rootQGCView
viewPanel: panel
property Fact _nullFact
property Fact _rcMapFltmode: controller.parameterExists(-1, "RC_MAP_FLTMODE") ? controller.getParameterFact(-1, "RC_MAP_FLTMODE") : _nullFact
property Fact _rcMapModeSw: controller.getParameterFact(-1, "RC_MAP_MODE_SW")
property bool _simpleMode: _rcMapFltmode.value > 0 || _rcMapModeSw.value == 0
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
FactPanelController {
id: controller
factPanel: panel
}
QGCViewPanel {
id: panel
anchors.fill: parent
Loader {
anchors.fill: parent
source: _simpleMode ? "qrc:/qml/PX4SimpleFlightModes.qml" : "qrc:/qml/PX4AdvancedFlightModes.qml"
property var qgcView: rootQGCView
property var qgcViewPanel: panel
}
} // QGCViewPanel
} // QGCView

140
src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml

@ -0,0 +1,140 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.ScreenTools 1.0
Item {
id: root
// The following properties must be pushed in from the Loader
//property var qgcView - QGCView control
//property var qgcViewPanel - QGCViewPanel control
property real _margins: ScreenTools.defaultFontPixelHeight / 2
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
PX4SimpleFlightModesController {
id: controller
factPanel: qgcViewPanel
}
QGCFlickable {
anchors.fill: parent
clip: true
contentWidth: contentColumn.width
contentHeight: contentColumn.height
Column {
id: contentColumn
spacing: _margins
QGCLabel {
id: flightModeLabel
text: "Flight Mode Settings"
font.weight: Font.DemiBold
}
Item {
height: modeChannelCombo.height
width: modeChannelCombo.x + modeChannelCombo.width
QGCLabel {
id: modeChannelLabel
anchors.baseline: modeChannelCombo.baseline
text: "Flight mode channel:"
}
FactComboBox {
id: modeChannelCombo
anchors.leftMargin: _margins
anchors.left: modeChannelLabel.right
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.getParameterFact(-1, "RC_MAP_FLTMODE")
indexModel: false
}
}
Rectangle {
id: flightModeSettings
width: flightModeColumn.width + (_margins * 2)
height: flightModeColumn.height + ScreenTools.defaultFontPixelHeight
color: qgcPal.windowShade
Column {
id: flightModeColumn
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.left: parent.left
anchors.top: parent.top
spacing: ScreenTools.defaultFontPixelHeight
Repeater {
model: 6
Row {
spacing: ScreenTools.defaultFontPixelWidth
property int index: modelData + 1
property var pwmStrings: [ "PWM 0 - 1230", "PWM 1231 - 1360", "PWM 1361 - 1490", "PWM 1491 - 1620", "PWM 1621 - 1749", "PWM 1750 +"]
QGCLabel {
anchors.baseline: modeCombo.baseline
text: "Flight Mode " + index + ":"
color: controller.activeFlightMode == index ? "yellow" : qgcPal.text
}
FactComboBox {
id: modeCombo
width: ScreenTools.defaultFontPixelWidth * 20
fact: controller.getParameterFact(-1, "COM_FLTMODE" + index)
indexModel: false
}
QGCLabel {
anchors.baseline: modeCombo.baseline
text: pwmStrings[modelData]
}
}
} // Repeater - Flight Modes
} // Column - Flight Modes
} // Rectangle - Flight Modes
QGCButton {
text: "Use Advanced Flight Modes"
onClicked: {
controller.getParameterFact(-1, "RC_MAP_MODE_SW").value = 5
controller.getParameterFact(-1, "RC_MAP_FLTMODE").value = 0
}
}
} // Column
} // QGCFlickable
} // QGCView

73
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.cc

@ -0,0 +1,73 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "PX4SimpleFlightModesController.h"
#include "QGCMAVLink.h"
#include "AutoPilotPluginManager.h"
#include <QVariant>
#include <QQmlProperty>
PX4SimpleFlightModesController::PX4SimpleFlightModesController(void)
: _activeFlightMode(0)
, _channelCount(Vehicle::cMaxRcChannels)
{
QStringList usedParams;
usedParams << QStringLiteral("COM_FLTMODE1") << QStringLiteral("COM_FLTMODE2") << QStringLiteral("COM_FLTMODE3")
<< QStringLiteral("COM_FLTMODE4") << QStringLiteral("COM_FLTMODE5") << QStringLiteral("COM_FLTMODE6")
<< QStringLiteral("RC_MAP_FLTMODE");
if (!_allParametersExists(FactSystem::defaultComponentId, usedParams)) {
return;
}
connect(_vehicle, &Vehicle::rcChannelsChanged, this, &PX4SimpleFlightModesController::_rcChannelsChanged);
}
/// Connected to Vehicle::rcChannelsChanged signal
void PX4SimpleFlightModesController::_rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels])
{
int flightModeChannel = getParameterFact(-1, "RC_MAP_FLTMODE")->rawValue().toInt() - 1;
if (flightModeChannel < 0 || flightModeChannel > channelCount) {
return;
}
_activeFlightMode = 0;
int channelValue = pwmValues[flightModeChannel];
if (channelValue != -1) {
bool found = false;
int rgThreshold[] = { 1230, 1360, 1490, 1620, 1749 };
for (int i=0; i<5; i++) {
if (channelValue <= rgThreshold[i]) {
_activeFlightMode = i + 1;
found = true;
break;
}
}
if (!found) {
_activeFlightMode = 6;
}
}
emit activeFlightModeChanged(_activeFlightMode);
}

62
src/AutoPilotPlugins/PX4/PX4SimpleFlightModesController.h

@ -0,0 +1,62 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef PX4SimpleFlightModesController_H
#define PX4SimpleFlightModesController_H
#include <QObject>
#include <QQuickItem>
#include <QList>
#include <QStringList>
#include "UASInterface.h"
#include "AutoPilotPlugin.h"
#include "FactPanelController.h"
#include "Vehicle.h"
/// MVC Controller for PX4SimpleFlightModes.qml
class PX4SimpleFlightModesController : public FactPanelController
{
Q_OBJECT
public:
PX4SimpleFlightModesController(void);
Q_PROPERTY(int activeFlightMode READ activeFlightMode NOTIFY activeFlightModeChanged)
Q_PROPERTY(int channelCount MEMBER _channelCount CONSTANT)
int activeFlightMode(void) const { return _activeFlightMode; }
signals:
void activeFlightModeChanged(int activeFlightMode);
void channelOptionEnabledChanged(void);
private slots:
void _rcChannelsChanged(int channelCount, int pwmValues[Vehicle::cMaxRcChannels]);
private:
int _activeFlightMode;
int _channelCount;
};
#endif

2
src/FactSystem/ParameterLoader.cc

@ -44,7 +44,7 @@ QGC_LOGGING_CATEGORY(ParameterLoaderVerboseLog, "ParameterLoaderVerboseLog")
Fact ParameterLoader::_defaultFact; Fact ParameterLoader::_defaultFact;
const char* ParameterLoader::_cachedMetaDataFilePrefix = "ParamaterFactMetaData"; const char* ParameterLoader::_cachedMetaDataFilePrefix = "ParameterFactMetaData";
ParameterLoader::ParameterLoader(Vehicle* vehicle) ParameterLoader::ParameterLoader(Vehicle* vehicle)
: QObject(vehicle) : QObject(vehicle)

201
src/FirmwarePlugin/PX4/PX4ParameterFactMetaData.xml

@ -2,8 +2,7 @@
<parameters> <parameters>
<version>3</version> <version>3</version>
<parameter_version_major>1</parameter_version_major> <parameter_version_major>1</parameter_version_major>
<parameter_version_minor>1</parameter_version_minor> <parameter_version_minor>1</parameter_version_minor> <group name="UAVCAN Motor Parameters" no_code_generation="true">
<group name="UAVCAN Motor Parameters" no_code_generation="true">
<parameter default="75" name="ctl_bw" type="INT32"> <parameter default="75" name="ctl_bw" type="INT32">
<short_desc>Speed controller bandwidth</short_desc> <short_desc>Speed controller bandwidth</short_desc>
<long_desc>Speed controller bandwidth, in Hz. Higher values result in faster speed and current rise times, but may result in overshoot and higher current consumption. For fixed-wing aircraft, this value should be less than 50 Hz; for multirotors, values up to 100 Hz may provide improvements in responsiveness.</long_desc> <long_desc>Speed controller bandwidth, in Hz. Higher values result in faster speed and current rise times, but may result in overshoot and higher current consumption. For fixed-wing aircraft, this value should be less than 50 Hz; for multirotors, values up to 100 Hz may provide improvements in responsiveness.</long_desc>
@ -3583,6 +3582,33 @@ replay messages for logging</short_desc>
</parameter> </parameter>
</group> </group>
<group name="Radio Switches"> <group name="Radio Switches">
<parameter default="0" name="RC_MAP_FLTMODE" type="INT32">
<short_desc>Single channel flight mode selection</short_desc>
<long_desc>If this parameter is non-zero, flight modes are only selected by this channel and are assigned to six slots.</long_desc>
<min>0</min>
<max>18</max>
<values>
<value code="11">RC Channel 11</value>
<value code="10">RC Channel 10</value>
<value code="13">RC Channel 13</value>
<value code="12">RC Channel 12</value>
<value code="15">RC Channel 15</value>
<value code="14">RC Channel 14</value>
<value code="17">RC Channel 17</value>
<value code="16">RC Channel 16</value>
<value code="18">RC Channel 18</value>
<value code="1">RC Channel 1</value>
<value code="0">Unassigned</value>
<value code="3">RC Channel 3</value>
<value code="2">RC Channel 2</value>
<value code="5">RC Channel 5</value>
<value code="4">RC Channel 4</value>
<value code="7">RC Channel 7</value>
<value code="6">RC Channel 6</value>
<value code="9">RC Channel 9</value>
<value code="8">RC Channel 8</value>
</values>
</parameter>
<parameter default="0" name="RC_MAP_MODE_SW" type="INT32"> <parameter default="0" name="RC_MAP_MODE_SW" type="INT32">
<short_desc>Mode switch channel mapping</short_desc> <short_desc>Mode switch channel mapping</short_desc>
<long_desc>This is the main flight mode selector. The channel index (starting from 1 for channel 1) indicates which channel should be used for deciding about the main mode. A value of zero indicates the switch is not assigned.</long_desc> <long_desc>This is the main flight mode selector. The channel index (starting from 1 for channel 1) indicates which channel should be used for deciding about the main mode. A value of zero indicates the switch is not assigned.</long_desc>
@ -4775,121 +4801,118 @@ Maps the change of airspeed error to the acceleration setpoint</short_desc>
<parameter default="0.1" name="RV_YAW_P" type="FLOAT"> <parameter default="0.1" name="RV_YAW_P" type="FLOAT">
<short_desc>RV_YAW_P</short_desc> <short_desc>RV_YAW_P</short_desc>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE_CH" type="INT32"> <parameter default="-1" name="COM_FLTMODE1" type="INT32">
<short_desc>COM_FLTMODE_CH</short_desc>
</parameter>
<parameter default="0" name="COM_FLTMODE1" type="INT32">
<short_desc>First flightmode slot (1000-1160)</short_desc> <short_desc>First flightmode slot (1000-1160)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE2" type="INT32"> <parameter default="-1" name="COM_FLTMODE2" type="INT32">
<short_desc>Second flightmode slot (1160-1320)</short_desc> <short_desc>Second flightmode slot (1160-1320)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE3" type="INT32"> <parameter default="-1" name="COM_FLTMODE3" type="INT32">
<short_desc>Third flightmode slot (1320-1480)</short_desc> <short_desc>Third flightmode slot (1320-1480)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE4" type="INT32"> <parameter default="-1" name="COM_FLTMODE4" type="INT32">
<short_desc>Fourth flightmode slot (1480-1640)</short_desc> <short_desc>Fourth flightmode slot (1480-1640)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE5" type="INT32"> <parameter default="-1" name="COM_FLTMODE5" type="INT32">
<short_desc>Fift flightmode slot (1640-1800)</short_desc> <short_desc>Fift flightmode slot (1640-1800)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="0" name="COM_FLTMODE6" type="INT32"> <parameter default="-1" name="COM_FLTMODE6" type="INT32">
<short_desc>Sixt flightmode slot (1800-2000)</short_desc> <short_desc>Sixt flightmode slot (1800-2000)</short_desc>
<long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc> <long_desc>If the main switch channel is in this range the selected flight mode will be applied.</long_desc>
<values> <values>
<value code="11">AUTO / TAKEOFF</value> <value code="11">AUTO / LAND</value>
<value code="10">RATTITUDE</value> <value code="10">AUTO / TAKEOFF</value>
<value code="12">AUTO / LAND</value> <value code="1">ALTITUDE CONTROL</value>
<value code="1">MANUAL</value> <value code="0">MANUAL</value>
<value code="0">Unassigned</value> <value code="3">AUTO / MISSION</value>
<value code="3">POSITION CONTROL</value> <value code="2">POSITION CONTROL</value>
<value code="2">ALTITUDE CONTROL</value> <value code="-1">Unassigned</value>
<value code="5">AUTO / PAUSE</value> <value code="4">AUTO / PAUSE</value>
<value code="4">AUTO / MISSION</value> <value code="7">OFFBOARD</value>
<value code="7">ACRO</value> <value code="6">ACRO</value>
<value code="6">RETURN TO LAUNCH</value> <value code="9">RATTITUDE</value>
<value code="9">STABILIZED</value> <value code="5">RETURN TO LAUNCH</value>
<value code="8">OFFBOARD</value> <value code="8">STABILIZED</value>
</values> </values>
</parameter> </parameter>
<parameter default="-1.0" name="TEST_MIN" type="FLOAT"> <parameter default="-1.0" name="TEST_MIN" type="FLOAT">

6
src/QGCApplication.cc

@ -61,7 +61,8 @@
#include "ViewWidgetController.h" #include "ViewWidgetController.h"
#include "ParameterEditorController.h" #include "ParameterEditorController.h"
#include "CustomCommandWidgetController.h" #include "CustomCommandWidgetController.h"
#include "FlightModesComponentController.h" #include "PX4AdvancedFlightModesController.h"
#include "PX4SimpleFlightModesController.h"
#include "APMFlightModesComponentController.h" #include "APMFlightModesComponentController.h"
#include "AirframeComponentController.h" #include "AirframeComponentController.h"
#include "SensorsComponentController.h" #include "SensorsComponentController.h"
@ -434,7 +435,8 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); qmlRegisterType<ParameterEditorController> ("QGroundControl.Controllers", 1, 0, "ParameterEditorController");
qmlRegisterType<APMFlightModesComponentController> ("QGroundControl.Controllers", 1, 0, "APMFlightModesComponentController"); qmlRegisterType<APMFlightModesComponentController> ("QGroundControl.Controllers", 1, 0, "APMFlightModesComponentController");
qmlRegisterType<FlightModesComponentController> ("QGroundControl.Controllers", 1, 0, "FlightModesComponentController"); qmlRegisterType<PX4AdvancedFlightModesController> ("QGroundControl.Controllers", 1, 0, "PX4AdvancedFlightModesController");
qmlRegisterType<PX4SimpleFlightModesController> ("QGroundControl.Controllers", 1, 0, "PX4SimpleFlightModesController");
qmlRegisterType<APMAirframeComponentController> ("QGroundControl.Controllers", 1, 0, "APMAirframeComponentController"); qmlRegisterType<APMAirframeComponentController> ("QGroundControl.Controllers", 1, 0, "APMAirframeComponentController");
qmlRegisterType<AirframeComponentController> ("QGroundControl.Controllers", 1, 0, "AirframeComponentController"); qmlRegisterType<AirframeComponentController> ("QGroundControl.Controllers", 1, 0, "AirframeComponentController");
qmlRegisterType<APMSensorsComponentController> ("QGroundControl.Controllers", 1, 0, "APMSensorsComponentController"); qmlRegisterType<APMSensorsComponentController> ("QGroundControl.Controllers", 1, 0, "APMSensorsComponentController");

2
src/VehicleSetup/VehicleComponent.cc

@ -62,9 +62,11 @@ void VehicleComponent::setupTriggerSignals(void)
{ {
// Watch for changed on trigger list params // Watch for changed on trigger list params
foreach (const QString &paramName, setupCompleteChangedTriggerList()) { foreach (const QString &paramName, setupCompleteChangedTriggerList()) {
if (_autopilot->parameterExists(FactSystem::defaultComponentId, paramName)) {
Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName); Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName);
connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated); connect(fact, &Fact::valueChanged, this, &VehicleComponent::_triggerUpdated);
} }
}
} }
void VehicleComponent::_triggerUpdated(QVariant /*value*/) void VehicleComponent::_triggerUpdated(QVariant /*value*/)

Loading…
Cancel
Save