You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
426 lines
22 KiB
426 lines
22 KiB
10 years ago
|
/*=====================================================================
|
||
|
|
||
|
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/>.
|
||
|
|
||
|
======================================================================*/
|
||
|
|
||
10 years ago
|
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
|
||
|
|
||
9 years ago
|
/// PX4 Advanced Flight Mode configuration
|
||
|
Item {
|
||
|
id: root
|
||
|
|
||
|
// The following properties must be pushed in from the Loader
|
||
|
//property var qgcView - QGCView control
|
||
|
//property var qgcViewPanel - QGCViewPanel control
|
||
10 years ago
|
|
||
|
readonly property int monitorThresholdCharWidth: 8 // Character width of Monitor and Threshold labels
|
||
|
|
||
|
// User visible strings
|
||
|
|
||
10 years ago
|
readonly property string title: "FLIGHT MODES"
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
property string topHelpText: "Assign Flight Modes to radio control channels and adjust the thresholds for triggering them. " +
|
||
10 years ago
|
"You can assign multiple flight modes to a single channel. " +
|
||
10 years ago
|
"Turn your radio control on to test switch settings. " +
|
||
|
"The following channels: " + controller.reservedChannels +
|
||
|
" are not available for Flight Modes since they are already in use for other functions."
|
||
10 years ago
|
|
||
|
|
||
|
readonly property string fwManualModeName: "Manual/Main"
|
||
|
readonly property string mrManualModeName: "Stabilized/Main"
|
||
|
readonly property string fwManualModeDescription: "The pilot has full control of the aircraft, no assistance is provided. " +
|
||
|
"The Main mode switch must always be assigned to a channel in order to fly"
|
||
10 years ago
|
readonly property string mrManualModeDescription: "Roll and Pitch control angle of multi-rotor in respective direction. " +
|
||
|
"Centering Roll/Pitch will return multirotor to level attitude. " +
|
||
|
"Position is not automatically held, multi-rotor will continue drifting in the direction it was previously travelling. " +
|
||
10 years ago
|
"Altitude is controlled fully by pilot using the Throttle stick. " +
|
||
|
"The Main mode switch must always be assigned to a channel in order to fly"
|
||
|
|
||
|
readonly property string assistModeName: "Assist"
|
||
|
readonly property string assistModeDescription: "If Position Control is placed on a seperate channel from the Main mode channel, an additional 'Assist' mode is added to the Main switch. " +
|
||
|
"In order for the Attitude Control/Position Control switch to be active, the Main switch must be in Assist mode."
|
||
|
|
||
|
readonly property string autoModeName: "Auto"
|
||
|
readonly property string autoModeDescription: "If Loiter is placed on a seperate channel from the Main mode channel, an additional 'Auto' mode is added to the Main switch. " +
|
||
|
"In order for the Mission/Loiter switch to be active, the Main switch must be in Auto mode."
|
||
|
|
||
|
readonly property string fwAcroModeName: "Stabilized"
|
||
|
readonly property string mrAcroModeName: "Acro"
|
||
10 years ago
|
readonly property string fwAcroModeDescription: "Roll and Pitch control angle of aircraft in respective direction. " +
|
||
|
"Centering Roll/Pitch will return the aircraft to a level attitude. " +
|
||
|
"Neither altitude nor direction is automatically controlled. " +
|
||
|
"Both Throttle and Yaw and in full control of pilot."
|
||
|
readonly property string mrAcroModeDescription: "Roll and Pitch control angular rate of change of multi-rotor in respective direction. " +
|
||
|
"This allows for multi-rotor to rotate through a full 360 degrees in roll and/or pitch. " +
|
||
|
"Centering Roll/Pitch will return the multirotor to a level attitude. " +
|
||
|
"Position is not automatically held, multi-rotor will continue drifting in the direction it was previously travelling. " +
|
||
|
"Altitude is under manual control of pilot using the Throttle stick."
|
||
|
|
||
|
readonly property string altCtlModeName: "Altitude Control"
|
||
|
readonly property string fwAltCtlModeDescription: "Current Altitude is maintained automatically when Pitch is centered. " +
|
||
|
"Roll and Pitch centered gives level flight, but does not maintain straight line direction against wind. " +
|
||
|
"Throttle controls speed, Pitch controls climb/sink rate, Roll controls turn rate. " +
|
||
|
"Position Control and Attitude Control must always be on the same channel."
|
||
|
readonly property string mrAltCtlModeDescription: "Same as Stablized mode except that Throttle controls climb/sink rate. Centered Throttle holds altitude steady."
|
||
10 years ago
|
|
||
|
readonly property string posCtlModeName: "Position Control"
|
||
10 years ago
|
readonly property string fwPosCtlModeDescription: "Current Altitude is maintained automatically when Pitch is centered. " +
|
||
|
"Roll and Pitch centered gives level flight in a straight line compensating against wind. " +
|
||
|
"Throttle controls speed, Pitch controls climb/sink rate, Roll controls turn rate. " +
|
||
10 years ago
|
"Position Control and Attitude Control must always be on the same channel."
|
||
|
readonly property string mrPosCtlModeDescription: "Roll and Pitch control left-right and front-back speed over ground respectively. " +
|
||
10 years ago
|
"Centering Roll/Pitch will level and hold position. " +
|
||
10 years ago
|
"Yaw controls yaw rate as in Stablized mode. " +
|
||
10 years ago
|
"Centered throttle holds current altitude. " +
|
||
|
"Throttle above/below center controls climb/sink rate. " +
|
||
10 years ago
|
"Position Control and Attitude Control must always be on the same channel."
|
||
|
|
||
|
readonly property string missionModeName: "Mission"
|
||
|
readonly property string missionModeDescription: "The aircraft obeys the programmed mission sent by QGroundControl. " +
|
||
10 years ago
|
"If no mission was sent, aircraft will Loiter at current position instead."
|
||
10 years ago
|
|
||
|
readonly property string loiterModeName: "Loiter"
|
||
|
readonly property string fwLoiterModeDescription: "The aircraft flies in a circle around the current position at the current altitude. " +
|
||
|
"Loiter and Mission must always be on the same channel."
|
||
10 years ago
|
readonly property string mrLoiterModeDescription: "The multirotor hovers at the current position and altitude. " +
|
||
10 years ago
|
"Loiter and Mission must always be on the same channel."
|
||
|
|
||
|
readonly property string returnModeName: "Return"
|
||
10 years ago
|
readonly property string returnModeDescription: "The vehicle returns to the home position, loiters and then lands. " +
|
||
10 years ago
|
"The settings which control this sequence can be found under Setup - Safety."
|
||
|
|
||
|
readonly property string offboardModeName: "Offboard"
|
||
10 years ago
|
readonly property string offboardModeDescription: "All flight control aspects are controlled by an offboard system."
|
||
10 years ago
|
|
||
|
readonly property real modeSpacing: ScreenTools.defaultFontPixelHeight / 3
|
||
|
|
||
|
QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled }
|
||
|
|
||
9 years ago
|
PX4AdvancedFlightModesController {
|
||
10 years ago
|
id: controller
|
||
9 years ago
|
factPanel: qgcViewPanel
|
||
10 years ago
|
|
||
|
onModeRowsChanged: recalcModePositions()
|
||
10 years ago
|
}
|
||
|
|
||
10 years ago
|
Timer {
|
||
|
interval: 200
|
||
|
running: true
|
||
10 years ago
|
|
||
10 years ago
|
onTriggered: {
|
||
10 years ago
|
recalcModePositions()
|
||
10 years ago
|
}
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
function recalcModePositions() {
|
||
|
var spacing = ScreenTools.defaultFontPixelHeight / 2
|
||
|
var nextY = manualMode.y + manualMode.height + spacing
|
||
10 years ago
|
|
||
10 years ago
|
for (var index = 0; index < 9; index++) {
|
||
|
if (controller.assistModeRow == index) {
|
||
|
if (controller.assistModeVisible) {
|
||
|
assistMode.y = nextY
|
||
|
assistMode.z = 9 - index
|
||
|
nextY += assistMode.height + spacing
|
||
10 years ago
|
}
|
||
10 years ago
|
} else if (controller.autoModeRow == index) {
|
||
|
if (controller.autoModeVisible) {
|
||
|
autoMode.y = nextY
|
||
|
autoMode.z = 9 - index
|
||
|
nextY += autoMode.height + spacing
|
||
10 years ago
|
}
|
||
10 years ago
|
} else if (controller.acroModeRow == index) {
|
||
|
acroMode.y = nextY
|
||
|
acroMode.z = 9 - index
|
||
|
nextY += acroMode.height + spacing
|
||
|
} else if (controller.altCtlModeRow == index) {
|
||
|
altCtlMode.y = nextY
|
||
|
altCtlMode.z = 9 - index
|
||
|
nextY += altCtlMode.height + spacing
|
||
|
} else if (controller.posCtlModeRow == index) {
|
||
|
posCtlMode.y = nextY
|
||
|
posCtlMode.z = 9 - index
|
||
|
nextY += posCtlMode.height + spacing
|
||
|
} else if (controller.loiterModeRow == index) {
|
||
|
loiterMode.y = nextY
|
||
|
loiterMode.z = 9 - index
|
||
|
nextY += loiterMode.height + spacing
|
||
|
} else if (controller.missionModeRow == index) {
|
||
|
missionMode.y = nextY
|
||
|
missionMode.z = 9 - index
|
||
|
nextY += missionMode.height + spacing
|
||
|
} else if (controller.returnModeRow == index) {
|
||
|
returnMode.y = nextY
|
||
|
returnMode.z = 9 - index
|
||
|
nextY += returnMode.height + spacing
|
||
|
} else if (controller.offboardModeRow == index) {
|
||
|
offboardMode.y = nextY
|
||
|
offboardMode.z = 9 - index
|
||
|
nextY += offboardMode.height + spacing
|
||
10 years ago
|
}
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
10 years ago
|
scrollItem.height = nextY
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
Component {
|
||
|
id: joystickEnabledDialogComponent
|
||
10 years ago
|
|
||
9 years ago
|
QGCViewMessage {
|
||
|
message: "Flight Mode Config is disabled since you have a Joystick enabled."
|
||
10 years ago
|
}
|
||
9 years ago
|
}
|
||
|
|
||
|
ScrollView {
|
||
|
id: scroll
|
||
|
anchors.fill: parent
|
||
|
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
|
||
10 years ago
|
|
||
9 years ago
|
Item {
|
||
|
id: scrollItem
|
||
|
width: scroll.viewport.width
|
||
10 years ago
|
|
||
10 years ago
|
Item {
|
||
9 years ago
|
id: helpApplyRow
|
||
|
width: parent.width
|
||
|
height: Math.max(helpText.contentHeight, applyButton.y + applyButton.height)
|
||
|
|
||
|
QGCLabel {
|
||
|
id: helpText
|
||
|
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
|
||
|
anchors.left: parent.left
|
||
|
anchors.right: buttonColumn.left
|
||
|
text: topHelpText
|
||
|
font.pixelSize: ScreenTools.defaultFontPixelSize
|
||
|
wrapMode: Text.WordWrap
|
||
|
}
|
||
|
|
||
|
Column {
|
||
|
id: buttonColumn
|
||
|
anchors.rightMargin: ScreenTools.defaultFontPixelWidth
|
||
|
anchors.right: parent.right
|
||
|
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
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
|
QGCButton {
|
||
|
id: applyButton
|
||
|
text: "Generate Thresholds"
|
||
|
onClicked: controller.generateThresholds()
|
||
|
}
|
||
10 years ago
|
}
|
||
9 years ago
|
}
|
||
10 years ago
|
|
||
9 years ago
|
Item {
|
||
|
id: lastSpacer
|
||
|
anchors.top: helpApplyRow.bottom
|
||
|
height: ScreenTools.defaultFontPixelHeight
|
||
|
width: 10
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: manualMode
|
||
|
anchors.top: lastSpacer.bottom
|
||
|
flightModeName: controller.fixedWing ? fwManualModeName : mrManualModeName
|
||
|
flightModeDescription: controller.fixedWing ? fwManualModeDescription : mrManualModeDescription
|
||
|
rcValue: controller.manualModeRcValue
|
||
|
modeChannelIndex: controller.manualModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.manualModeSelected
|
||
|
thresholdValue: controller.manualModeThreshold
|
||
|
thresholdDragEnabled: false
|
||
|
|
||
|
onModeChannelIndexSelected: controller.manualModeChannelIndex = index
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: assistMode
|
||
|
visible: controller.assistModeVisible
|
||
|
flightModeName: assistModeName
|
||
|
flightModeDescription: assistModeDescription
|
||
|
rcValue: controller.assistModeRcValue
|
||
|
modeChannelIndex: controller.assistModeChannelIndex
|
||
|
modeChannelEnabled: false
|
||
|
modeSelected: controller.assistModeSelected
|
||
|
thresholdValue: controller.assistModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onThresholdValueChanged: controller.assistModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: autoMode
|
||
|
visible: controller.autoModeVisible
|
||
|
flightModeName: autoModeName
|
||
|
flightModeDescription: autoModeDescription
|
||
|
rcValue: controller.autoModeRcValue
|
||
|
modeChannelIndex: controller.autoModeChannelIndex
|
||
|
modeChannelEnabled: false
|
||
|
modeSelected: controller.autoModeSelected
|
||
|
thresholdValue: controller.autoModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onThresholdValueChanged: controller.autoModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: acroMode
|
||
|
flightModeName: controller.fixedWing ? fwAcroModeName : mrAcroModeName
|
||
|
flightModeDescription: controller.fixedWing ? fwAcroModeDescription : mrAcroModeDescription
|
||
|
rcValue: controller.acroModeRcValue
|
||
|
modeChannelIndex: controller.acroModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.acroModeSelected
|
||
|
thresholdValue: controller.acroModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onModeChannelIndexSelected: controller.acroModeChannelIndex = index
|
||
|
onThresholdValueChanged: controller.acroModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: altCtlMode
|
||
|
flightModeName: altCtlModeName
|
||
|
flightModeDescription: controller.fixedWing ? fwAltCtlModeDescription : mrAltCtlModeDescription
|
||
|
rcValue: controller.altCtlModeRcValue
|
||
|
modeChannelIndex: controller.altCtlModeChannelIndex
|
||
|
modeChannelEnabled: false
|
||
|
modeSelected: controller.altCtlModeSelected
|
||
|
thresholdValue: controller.altCtlModeThreshold
|
||
|
thresholdDragEnabled: !controller.assistModeVisible
|
||
10 years ago
|
|
||
9 years ago
|
onThresholdValueChanged: controller.altCtlModeThreshold = thresholdValue
|
||
10 years ago
|
|
||
9 years ago
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: posCtlMode
|
||
|
flightModeName: posCtlModeName
|
||
|
flightModeDescription: controller.fixedWing ? fwPosCtlModeDescription : mrPosCtlModeDescription
|
||
|
rcValue: controller.posCtlModeRcValue
|
||
|
modeChannelIndex: controller.posCtlModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.posCtlModeSelected
|
||
|
thresholdValue: controller.posCtlModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onModeChannelIndexSelected: controller.posCtlModeChannelIndex = index
|
||
|
onThresholdValueChanged: controller.posCtlModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: missionMode
|
||
|
flightModeName: missionModeName
|
||
|
flightModeDescription: missionModeDescription
|
||
|
rcValue: controller.missionModeRcValue
|
||
|
modeChannelIndex: controller.missionModeChannelIndex
|
||
|
modeChannelEnabled: false
|
||
|
modeSelected: controller.missionModeSelected
|
||
|
thresholdValue: controller.missionModeThreshold
|
||
|
thresholdDragEnabled: !controller.autoModeVisible
|
||
10 years ago
|
|
||
9 years ago
|
onThresholdValueChanged: controller.missionModeThreshold = thresholdValue
|
||
10 years ago
|
|
||
9 years ago
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: loiterMode
|
||
|
flightModeName: loiterModeName
|
||
|
flightModeDescription: controller.fixedWing ? fwLoiterModeDescription : mrLoiterModeDescription
|
||
|
rcValue: controller.loiterModeRcValue
|
||
|
modeChannelIndex: controller.loiterModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.loiterModeSelected
|
||
|
thresholdValue: controller.loiterModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onModeChannelIndexSelected: controller.loiterModeChannelIndex = index
|
||
|
onThresholdValueChanged: controller.loiterModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: returnMode
|
||
|
flightModeName: returnModeName
|
||
|
flightModeDescription: returnModeDescription
|
||
|
rcValue: controller.returnModeRcValue
|
||
|
modeChannelIndex: controller.returnModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.returnModeSelected
|
||
|
thresholdValue: controller.returnModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onModeChannelIndexSelected: controller.returnModeChannelIndex = index
|
||
|
onThresholdValueChanged: controller.returnModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
10 years ago
|
|
||
9 years ago
|
ModeSwitchDisplay {
|
||
|
id: offboardMode
|
||
|
flightModeName: offboardModeName
|
||
|
flightModeDescription: offboardModeDescription
|
||
|
rcValue: controller.offboardModeRcValue
|
||
|
modeChannelIndex: controller.offboardModeChannelIndex
|
||
|
modeChannelEnabled: true
|
||
|
modeSelected: controller.offboardModeSelected
|
||
|
thresholdValue: controller.offboardModeThreshold
|
||
|
thresholdDragEnabled: true
|
||
|
|
||
|
onModeChannelIndexSelected: controller.offboardModeChannelIndex = index
|
||
|
onThresholdValueChanged: controller.offboardModeThreshold = thresholdValue
|
||
|
|
||
|
Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 1000 } }
|
||
|
}
|
||
|
} // Item
|
||
|
} // Scroll View
|
||
|
} // Item
|