Commit 12109fad authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4967 from DonLakeFlyer/GuidedFixes

Guided fixes
parents 4fe3514b b15835f7
......@@ -96,6 +96,16 @@ QGCView {
onResumeMissionReady: guidedActionsController.confirmAction(guidedActionsController.actionResumeMissionReady)
}
GeoFenceController {
id: flyGeoFenceController
Component.onCompleted: start(false /* editMode */)
}
RallyPointController {
id: flyRallyPointController
Component.onCompleted: start(false /* editMode */)
}
MessageDialog {
id: px4JoystickSupport
text: qsTr("Joystick support requires MAVLink MANUAL_CONTROL support. ") +
......@@ -123,6 +133,49 @@ QGCView {
}
}
// The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes
property bool vehicleArmed: _activeVehicle ? _activeVehicle.armed : true // true here prevents pop up from showing during shutdown
property bool vehicleWasArmed: false
property bool vehicleInMissionFlightMode: _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false
property bool promptForMissionRemove: false
onVehicleArmedChanged: {
if (vehicleArmed) {
if (!promptForMissionRemove) {
promptForMissionRemove = vehicleInMissionFlightMode
vehicleWasArmed = true
}
} else {
if (promptForMissionRemove && (flyMissionController.containsItems || flyGeoFenceController.containsItems || flyRallyPointController.containsItems)) {
root.showDialog(removeMissionDialogComponent, qsTr("Flight complete"), showDialogDefaultWidth, StandardButton.No | StandardButton.Yes)
}
promptForMissionRemove = false
}
}
onVehicleInMissionFlightModeChanged: {
if (!promptForMissionRemove && vehicleArmed) {
promptForMissionRemove = true
}
}
Component {
id: removeMissionDialogComponent
QGCViewMessage {
message: qsTr("Do you want to remove the mission from the vehicle?")
function accept() {
flyMissionController.removeAllFromVehicle()
flyGeoFenceController.removeAllFromVehicle()
flyRallyPointController.removeAllFromVehicle()
hideDialog()
}
}
}
QGCMapPalette { id: mapPal; lightColors: _mainIsMap ? _flightMap.isSatelliteMap : true }
QGCViewPanel {
......@@ -157,14 +210,16 @@ QGCView {
}
]
FlightDisplayViewMap {
id: _flightMap
anchors.fill: parent
missionController: flyMissionController
guidedActionsController: _guidedController
flightWidgets: flightDisplayViewWidgets
rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9
qgcView: root
scaleState: (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
id: _flightMap
anchors.fill: parent
missionController: flyMissionController
geoFenceController: flyGeoFenceController
rallyPointController: flyRallyPointController
guidedActionsController: _guidedController
flightWidgets: flightDisplayViewWidgets
rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9
qgcView: root
scaleState: (_mainIsMap && flyViewOverlay.item) ? (flyViewOverlay.item.scaleState ? flyViewOverlay.item.scaleState : "bottomMode") : "bottomMode"
}
}
......@@ -356,7 +411,7 @@ QGCView {
buttonVisible: [ _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true, _guidedController.smartShotsAvailable ]
buttonEnabled: [ _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable, _anySmartShotAvailable ]
property bool _anyActionAvailable: _guidedController.showEmergenyStop || _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property bool _anySmartShotAvailable: _guidedController.showOrbit
property var _actionModel: [
{
......
......@@ -33,6 +33,8 @@ FlightMap {
property alias scaleState: mapScale.state
property var missionController
property var geoFenceController
property var rallyPointController
property var guidedActionsController
property var flightWidgets
property var rightPanelWidth
......@@ -137,59 +139,6 @@ FlightMap {
}
}
GeoFenceController {
id: geoFenceController
Component.onCompleted: start(false /* editMode */)
}
RallyPointController {
id: rallyPointController
Component.onCompleted: start(false /* editMode */)
}
// The following code is used to track vehicle states such that we prompt to remove mission from vehicle when mission completes
property bool vehicleArmed: _activeVehicle ? _activeVehicle.armed : false
property bool vehicleWasArmed: false
property bool vehicleInMissionFlightMode: _activeVehicle ? (_activeVehicle.flightMode === _activeVehicle.missionFlightMode) : false
property bool promptForMissionRemove: false
onVehicleArmedChanged: {
if (vehicleArmed) {
if (!promptForMissionRemove) {
promptForMissionRemove = vehicleInMissionFlightMode
vehicleWasArmed = true
}
} else {
if (promptForMissionRemove && (missionController.containsItems || geoFenceController.containsItems || rallyPointController.containsItems)) {
qgcView.showDialog(removeMissionDialogComponent, qsTr("Flight complete"), showDialogDefaultWidth, StandardButton.No | StandardButton.Yes)
}
promptForMissionRemove = false
}
}
onVehicleInMissionFlightModeChanged: {
if (!promptForMissionRemove && vehicleArmed) {
promptForMissionRemove = true
}
}
Component {
id: removeMissionDialogComponent
QGCViewMessage {
message: qsTr("Do you want to remove the mission from the vehicle?")
function accept() {
missionController.removeAllFromVehicle()
geoFenceController.removeAllFromVehicle()
rallyPointController.removeAllFromVehicle()
hideDialog()
}
}
}
ExclusiveGroup {
id: _mapTypeButtonsExclusiveGroup
}
......@@ -239,7 +188,7 @@ FlightMap {
delegate: MissionItemMapVisual {
map: flightMap
onClicked: guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, object.sequenceNumber)
onClicked: guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, Math.max(object.sequenceNumber, 1))
}
}
......
......@@ -78,29 +78,41 @@ Item {
readonly property int actionResumeMissionReady: 14
readonly property int actionPause: 15
property bool showEmergenyStop: !_hideEmergenyStop && _activeVehicle && _activeVehicle.armed && _activeVehicle.flying
property bool showDisarm: _activeVehicle && _activeVehicle.armed && !_activeVehicle.flying
property bool showRTL: _activeVehicle && _activeVehicle.armed && _activeVehicle.guidedModeSupported && _activeVehicle.flying && !_vehicleInRTLMode
property bool showEmergenyStop: !_hideEmergenyStop && _activeVehicle && _vehicleArmed && _activeVehicle.flying
property bool showDisarm: _activeVehicle && _vehicleArmed && !_activeVehicle.flying
property bool showRTL: _activeVehicle && _vehicleArmed && _activeVehicle.guidedModeSupported && _activeVehicle.flying && !_vehicleInRTLMode
property bool showTakeoff: _activeVehicle && _activeVehicle.guidedModeSupported && !_activeVehicle.flying && !_activeVehicle.fixedWing
property bool showLand: _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.armed && !_activeVehicle.fixedWing && !_vehicleInLandMode
property bool showLand: _activeVehicle && _activeVehicle.guidedModeSupported && _vehicleArmed && !_activeVehicle.fixedWing && !_vehicleInLandMode
property bool showStartMission: _activeVehicle && _missionAvailable && !_missionActive
property bool showResumeMission: _activeVehicle && !_activeVehicle.flying && _missionAvailable && _resumeMissionIndex > 0
property bool showPause: _activeVehicle && _activeVehicle.armed && _activeVehicle.pauseVehicleSupported && _activeVehicle.flying && !_vehiclePaused
property bool showChangeAlt: (_activeVehicle && _activeVehicle.flying) && _activeVehicle.guidedModeSupported && _activeVehicle.armed && !_missionActive
property bool showOrbit: !_hideOrbit && _activeVehicle && _activeVehicle.flying && _activeVehicle.orbitModeSupported && _activeVehicle.armed && !_missionActive
property bool showPause: _activeVehicle && _vehicleArmed && _activeVehicle.pauseVehicleSupported && _activeVehicle.flying && !_vehiclePaused
property bool showChangeAlt: (_activeVehicle && _activeVehicle.flying) && _activeVehicle.guidedModeSupported && _vehicleArmed && !_missionActive
property bool showOrbit: !_hideOrbit && _activeVehicle && _activeVehicle.flying && _activeVehicle.orbitModeSupported && _vehicleArmed && !_missionActive
property bool showLandAbort: _activeVehicle && _activeVehicle.flying && _activeVehicle.fixedWing
property bool showGotoLocation: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _missionAvailable: missionController.containsItems
property bool _missionActive: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.missionFlightMode : false
property bool _vehiclePaused: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.pauseFlightMode : false
property bool _vehicleInRTLMode: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.rtlFlightMode : false
property bool _vehicleInLandMode: _activeVehicle ? _activeVehicle.flightMode === _activeVehicle.landFlightMode : false
property int _resumeMissionIndex: missionController.resumeMissionIndex
property bool _hideEmergenyStop: !QGroundControl.corePlugin.options.guidedBarShowEmergencyStop
property bool _hideOrbit: !QGroundControl.corePlugin.options.guidedBarShowOrbit
property var _actionData
onShowStartMissionChanged: console.log(showStartMission, _activeVehicle, _missionAvailable, _missionActive, _vehicleArmed, _vehicleInLandMode, _vehicleInRTLMode)
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property string _flightMode: _activeVehicle ? _activeVehicle.flightMode : ""
property bool _missionAvailable: missionController.containsItems
property bool _missionActive: _activeVehicle ? _vehicleArmed && (_vehicleInLandMode || _vehicleInRTLMode || _vehicleInMissionMode) : false
property bool _vehicleArmed: _activeVehicle ? _activeVehicle.armed : false
property bool _vehiclePaused: false
property bool _vehicleInMissionMode: false
property bool _vehicleInRTLMode: false
property bool _vehicleInLandMode: false
property int _resumeMissionIndex: missionController.resumeMissionIndex
property bool _hideEmergenyStop: !QGroundControl.corePlugin.options.guidedBarShowEmergencyStop
property bool _hideOrbit: !QGroundControl.corePlugin.options.guidedBarShowOrbit
property var _actionData
on_FlightModeChanged: {
_vehiclePaused = _flightMode === _activeVehicle.pauseFlightMode
_vehicleInRTLMode = _flightMode === _activeVehicle.rtlFlightMode
_vehicleInLandMode = _flightMode === _activeVehicle.landFlightMode
_vehicleInMissionMode = _flightMode === _activeVehicle.missionFlightMode // Must be last to get correct signalling for showStartMission popups
}
// Called when an action is about to be executed in order to confirm
function confirmAction(actionCode, actionData) {
......@@ -203,10 +215,10 @@ Item {
_activeVehicle.startMission()
break
case actionArm:
_activeVehicle.armed = true
_vehicleArmed = true
break
case actionDisarm:
_activeVehicle.armed = false
_vehicleArmed = false
break
case actionEmergencyStop:
_activeVehicle.emergencyStop()
......
......@@ -1482,7 +1482,7 @@ int MissionController::resumeMissionIndex(void) const
if (!_editMode) {
resumeIndex = _activeVehicle->missionManager()->lastCurrentIndex() + (_activeVehicle->firmwarePlugin()->sendHomePositionToVehicle() ? 0 : 1);
if (resumeIndex > 1) {
if (resumeIndex > 1 && resumeIndex != _visualItems->value<VisualMissionItem*>(_visualItems->count() - 1)->sequenceNumber()) {
// Resume at the item previous to the item we were heading towards
resumeIndex--;
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment