Skip to content

Commit

Permalink
Add Frontend UI for GripperAction Feature
Browse files Browse the repository at this point in the history
Now the user can release and grab the gripper while the UAV has
motors armed with the action button and also while the motors are
disarmed in a specific toolbar option.
  • Loading branch information
DieBorr authored and booo committed Jun 25, 2023
1 parent f831565 commit 14e9b94
Show file tree
Hide file tree
Showing 16 changed files with 272 additions and 1 deletion.
3 changes: 3 additions & 0 deletions qgcresources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<file alias="XDelete.svg">resources/XDelete.svg</file>
<file alias="XDeleteBlack.svg">resources/XDeleteBlack.svg</file>
<file alias="waypoint.svg">resources/waypoint.svg</file>
<file alias="Gripper.svg">resources/Gripper.svg</file>
<file alias="GripperRelease.svg">resources/GripperRelease.svg</file>
<file alias="GripperGrab.svg">resources/GripperGrab.svg</file>
<file>resources/icons/qgroundcontrol.ico</file>
</qresource>
<qresource prefix="/res/firmware">
Expand Down
3 changes: 3 additions & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
<file alias="QGroundControl/Controls/PreFlightCheckGroup.qml">src/QmlControls/PreFlightCheckGroup.qml</file>
<file alias="QGroundControl/Controls/PreFlightCheckModel.qml">src/QmlControls/PreFlightCheckModel.qml</file>
<file alias="QGroundControl/Controls/QGCButton.qml">src/QmlControls/QGCButton.qml</file>
<file alias="QGroundControl/Controls/QGCColumnButton.qml">src/QmlControls/QGCColumnButton.qml</file>
<file alias="QGroundControl/Controls/AutotuneUI.qml">src/QmlControls/AutotuneUI.qml</file>
<file alias="QGroundControl/Controls/QGCCheckBox.qml">src/QmlControls/QGCCheckBox.qml</file>
<file alias="QGroundControl/Controls/QGCColoredImage.qml">src/QmlControls/QGCColoredImage.qml</file>
Expand Down Expand Up @@ -221,6 +222,8 @@
<file alias="QGroundControl/FlightDisplay/GuidedActionLand.qml">src/FlightDisplay/GuidedActionLand.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionList.qml">src/FlightDisplay/GuidedActionList.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionTakeoff.qml">src/FlightDisplay/GuidedActionTakeoff.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionGripper.qml">src/FlightDisplay/GuidedActionGripper.qml</file>
<file alias="QGroundControl/FlightDisplay/GripperMenu.qml">src/FlightDisplay/GripperMenu.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionPause.qml">src/FlightDisplay/GuidedActionPause.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedActionRTL.qml">src/FlightDisplay/GuidedActionRTL.qml</file>
<file alias="QGroundControl/FlightDisplay/GuidedValueSlider.qml">src/FlightDisplay/GuidedValueSlider.qml</file>
Expand Down
20 changes: 20 additions & 0 deletions resources/Gripper.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions resources/GripperGrab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions resources/GripperRelease.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/FlightDisplay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ add_custom_target(FligthDisplayQml
GuidedActionRTL.qml
GuidedActionsController.qml
GuidedActionTakeoff.qml
GuidedActionGripper.qml
GripperMenu.qml
GuidedValueSlider.qml
GuidedToolStripAction.qml
MultiRotorChecklist.qml
Expand Down
1 change: 1 addition & 0 deletions src/FlightDisplay/FlyView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Item {
property var _guidedController: guidedActionsController
property var _guidedActionList: guidedActionList
property var _guidedValueSlider: guidedValueSlider
property var _widgetLayer: widgetLayer
property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
property rect _centerViewport: Qt.rect(0, 0, width, height)
property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
Expand Down
3 changes: 2 additions & 1 deletion src/FlightDisplay/FlyViewToolStripActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ ToolStripActionList {
GuidedActionLand { },
GuidedActionRTL { },
GuidedActionPause { },
GuidedActionActionList { }
GuidedActionActionList { },
GuidedActionGripper { }
]
}
5 changes: 5 additions & 0 deletions src/FlightDisplay/FlyViewWidgetLayer.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Item {
property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
property rect _centerViewport: Qt.rect(0, 0, width, height)
property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
property alias _gripperMenu: gripperOptions

QGCToolInsets {
id: _totalToolInsets
Expand Down Expand Up @@ -258,6 +259,10 @@ Item {
property real leftInset: x + width
}

GripperMenu {
id: gripperOptions
}

FlyViewAirspaceIndicator {
anchors.top: parent.top
anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
Expand Down
71 changes: 71 additions & 0 deletions src/FlightDisplay/GripperMenu.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@

import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.2
import QtLocation 5.3
import QtPositioning 5.3
import QtQuick.Layouts 1.2

import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Vehicle 1.0
import QGroundControl.FlightMap 1.0

Component {
id: messageDialogComponent
QGCPopupDialog {
title: "Select one action"
property var acceptFunction: null
buttons: StandardButton.Cancel

onRejected:{
_guidedController._gripperFunction = Vehicle.Invalid_option
_guidedController.closeAll()
close()
}

onAccepted: {
if (acceptFunction) {
_guidedController._gripperFunction = Vehicle.Invalid_option
close()
}
}

RowLayout {
QGCColumnButton {
id: grabButton
text: "Grab"
iconSource: "/res/GripperGrab.svg"
pointSize: ScreenTools.defaultFontPointSize * 3.5
backRadius: width / 40
heightFactor: 0.75
Layout.preferredHeight: releaseButton.height
Layout.preferredWidth: releaseButton.width

onClicked: {
_guidedController._gripperFunction = Vehicle.Gripper_grab
close()
}
}

QGCColumnButton {
id: releaseButton
text: "Release"
iconSource: "/res/GripperRelease.svg"
pointSize: ScreenTools.defaultFontPointSize * 3.5
backRadius: width / 40
heightFactor: 0.75
Layout.preferredWidth: ScreenTools.defaultFontPixelWidth * 27
Layout.preferredHeight: Layout.preferredWidth / 1.20

onClicked: {
_guidedController._gripperFunction = Vehicle.Gripper_release
close()
}
}
}
}
}
24 changes: 24 additions & 0 deletions src/FlightDisplay/GuidedActionGripper.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/

import QGroundControl.FlightDisplay 1.0
import QGroundControl 1.0

GuidedToolStripAction {
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _initialConnectComplete: activeVehicle ? activeVehicle.initialConnectComplete : false
property bool _grip_enable: _initialConnectComplete ? activeVehicle.hasGripper : false
property bool _isVehicleArmed: _initialConnectComplete ? activeVehicle.armed : false

text: "Gripper"
iconSource: "/res/Gripper.svg"
visible: !_isVehicleArmed && _grip_enable // in this way if the pilot it's on the ground can release the cargo without actions tool
enabled: _grip_enable
actionID: _guidedController.actionGripper
}
6 changes: 6 additions & 0 deletions src/FlightDisplay/GuidedActionList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ Rectangle {
text: guidedController.changeSpeedMessage,
action: guidedController.actionChangeSpeed,
visible: guidedController.showChangeSpeed
},
{
title: guidedController.gripperTitle,
text: guidedController.gripperMessage,
action: guidedController.actionGripper,
visible: guidedController.showGripper
}
]

Expand Down
15 changes: 15 additions & 0 deletions src/FlightDisplay/GuidedActionsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Item {
readonly property string disarmTitle: qsTr("Disarm")
readonly property string rtlTitle: qsTr("Return")
readonly property string takeoffTitle: qsTr("Takeoff")
readonly property string gripperTitle: qsTr("Gripper Function")
readonly property string landTitle: qsTr("Land")
readonly property string startMissionTitle: qsTr("Start Mission")
readonly property string mvStartMissionTitle: qsTr("Start Mission (MV)")
Expand All @@ -62,6 +63,7 @@ Item {
readonly property string disarmMessage: qsTr("Disarm the vehicle")
readonly property string emergencyStopMessage: qsTr("WARNING: THIS WILL STOP ALL MOTORS. IF VEHICLE IS CURRENTLY IN THE AIR IT WILL CRASH.")
readonly property string takeoffMessage: qsTr("Takeoff from ground and hold position.")
readonly property string gripperMessage: qsTr("Grab or Release the cargo")
readonly property string startMissionMessage: qsTr("Takeoff from ground and start the current mission.")
readonly property string continueMissionMessage: qsTr("Continue the mission from the current waypoint.")
readonly property string resumeMissionUploadFailMessage: qsTr("Upload of resume mission failed. Confirm to retry upload")
Expand Down Expand Up @@ -105,6 +107,7 @@ Item {
readonly property int actionActionList: 23
readonly property int actionForceArm: 24
readonly property int actionChangeSpeed: 25
readonly property int actionGripper: 26

property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _useChecklist: QGroundControl.settingsManager.appSettings.useChecklist.rawValue && QGroundControl.corePlugin.options.preFlightChecklistUrl.toString().length
Expand All @@ -113,6 +116,7 @@ Item {
property bool _canArm: _activeVehicle ? (_checklistPassed && (!_activeVehicle.healthAndArmingCheckReport.supported || _activeVehicle.healthAndArmingCheckReport.canArm)) : false
property bool _canTakeoff: _activeVehicle ? (_checklistPassed && (!_activeVehicle.healthAndArmingCheckReport.supported || _activeVehicle.healthAndArmingCheckReport.canTakeoff)) : false
property bool _canStartMission: _activeVehicle ? (_checklistPassed && (!_activeVehicle.healthAndArmingCheckReport.supported || _activeVehicle.healthAndArmingCheckReport.canStartMission)) : false
property bool _initialConnectComplete: _activeVehicle ? _activeVehicle.initialConnectComplete : false

property bool showEmergenyStop: _guidedActionsEnabled && !_hideEmergenyStop && _vehicleArmed && _vehicleFlying
property bool showArm: _guidedActionsEnabled && !_vehicleArmed && _canArm
Expand All @@ -131,6 +135,7 @@ Item {
property bool showLandAbort: _guidedActionsEnabled && _vehicleFlying && _fixedWingOnApproach
property bool showGotoLocation: _guidedActionsEnabled && _vehicleFlying
property bool showActionList: _guidedActionsEnabled && (showStartMission || showResumeMission || showChangeAlt || showLandAbort || actionList.hasCustomActions)
property bool showGripper: _initialConnectComplete ? _activeVehicle.hasGripper : false
property string changeSpeedTitle: _fixedWing ? changeAirspeedTitle : changeCruiseSpeedTitle
property string changeSpeedMessage: _fixedWing ? changeAirspeedMessage : changeCruiseSpeedMessage

Expand Down Expand Up @@ -163,6 +168,7 @@ Item {
property bool _fixedWingOnApproach: _activeVehicle ? _activeVehicle.fixedWing && _vehicleLanding : false
property bool _fixedWing: _activeVehicle ? _activeVehicle.fixedWing || _activeVehicle.vtolInFwdFlight : false
property bool _speedLimitsAvailable: _activeVehicle && ((_fixedWing && _activeVehicle.haveFWSpeedLimits) || (!_fixedWing && _activeVehicle.haveMRSpeedLimits))
property var _gripperFunction: undefined

// You can turn on log output for GuidedActionsController by turning on GuidedActionsControllerLog category
property bool __guidedModeSupported: _activeVehicle ? _activeVehicle.guidedModeSupported : false
Expand Down Expand Up @@ -496,6 +502,12 @@ Item {
confirmDialog.message = changeSpeedMessage
guidedValueSlider.visible = true
break
case actionGripper:
confirmDialog.hideTrigger = true
confirmDialog.title = gripperTitle
confirmDialog.message = gripperMessage
_widgetLayer._gripperMenu.createObject(mainWindow).open()
break
default:
console.warn("Unknown actionCode", actionCode)
return
Expand Down Expand Up @@ -585,6 +597,9 @@ Item {
}
}
break
case actionGripper:
_gripperFunction === undefined ? _activeVehicle.sendGripperAction(Vehicle.Invalid_option) : _activeVehicle.sendGripperAction(_gripperFunction)
break
default:
console.warn(qsTr("Internal error: unknown actionCode"), actionCode)
break
Expand Down
Loading

0 comments on commit 14e9b94

Please sign in to comment.