Skip to content

Commit 89ced2d

Browse files
rubenp02DonLakeFlyer
authored andcommitted
Add "Change Loiter Radius" action
Added a new Guided mode action to change the radius of the orbit around the Go here position when in forward flight. This action integrates with the Go here circle visuals, allowing the new radius to be selected using the MapCircleVisuals interactive editing gizmo. The current radius is shown in a text bubble next to the gizmo.
1 parent b2e24d7 commit 89ced2d

File tree

4 files changed

+124
-15
lines changed

4 files changed

+124
-15
lines changed

src/FlightDisplay/FlyViewAdditionalActionsList.qml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ QtObject {
1313
property var guidedController
1414

1515
property bool anyActionAvailable: guidedController.showStartMission || guidedController.showContinueMission || guidedController.showChangeAlt ||
16-
guidedController.showLandAbort || guidedController.showChangeSpeed || guidedController.showGripper
16+
guidedController.showChangeLoiterRadius || guidedController.showLandAbort || guidedController.showChangeSpeed ||
17+
guidedController.showGripper
1718
property var model: [
1819
{
1920
title: guidedController.startMissionTitle,
@@ -33,6 +34,12 @@ QtObject {
3334
action: guidedController.actionChangeAlt,
3435
visible: guidedController.showChangeAlt
3536
},
37+
{
38+
title: guidedController.changeLoiterRadiusTitle,
39+
text: guidedController.changeLoiterRadiusMessage,
40+
action: guidedController.actionChangeLoiterRadius,
41+
visible: guidedController.showChangeLoiterRadius
42+
},
3643
{
3744
title: guidedController.landAbortTitle,
3845
text: guidedController.landAbortMessage,

src/FlightDisplay/FlyViewMap.qml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,23 @@ FlightMap {
370370

371371
// GoTo Location forward flight circle visuals
372372
QGCMapCircleVisuals {
373-
id: fwdFlightGotoMapCircle
374-
mapControl: parent
375-
mapCircle: _fwdFlightGotoMapCircle
376-
visible: gotoLocationItem.visible && _activeVehicle &&
377-
_activeVehicle.inFwdFlight &&
378-
!_activeVehicle.orbitActive
373+
id: fwdFlightGotoMapCircle
374+
mapControl: parent
375+
mapCircle: _fwdFlightGotoMapCircle
376+
radiusLabelVisible: true
377+
visible: gotoLocationItem.visible && _activeVehicle &&
378+
_activeVehicle.inFwdFlight &&
379+
!_activeVehicle.orbitActive
380+
381+
property alias coordinate: _fwdFlightGotoMapCircle.center
382+
property alias radius: _fwdFlightGotoMapCircle.radius
383+
384+
Component.onCompleted: {
385+
// Only allow editing the radius, not the position
386+
centerDragHandleVisible = false
387+
388+
globals.guidedControllerFlyView.fwdFlightGotoMapCircle = this
389+
}
379390

380391
Connections {
381392
target: QGroundControl.multiVehicleManager
@@ -392,16 +403,47 @@ FlightMap {
392403
value: gotoLocationItem.coordinate
393404
}
394405

406+
function startLoiterRadiusEdit() {
407+
_fwdFlightGotoMapCircle.interactive = true
408+
}
409+
410+
// Called when loiter edit is confirmed
411+
function actionConfirmed() {
412+
_fwdFlightGotoMapCircle.interactive = false
413+
_fwdFlightGotoMapCircle._commitRadius()
414+
}
415+
416+
// Called when loiter edit is cancelled
417+
function actionCancelled() {
418+
_fwdFlightGotoMapCircle.interactive = false
419+
_fwdFlightGotoMapCircle._restoreRadius()
420+
}
421+
395422
QGCMapCircle {
396423
id: _fwdFlightGotoMapCircle
397424
interactive: false
398425
showRotation: true
399426
clockwiseRotation: true
400427

401428
property real _defaultLoiterRadius: _flyViewSettings.forwardFlightGoToLocationLoiterRad.value
429+
property real _committedRadius;
402430

403431
onCenterChanged: {
404432
radius.rawValue = _defaultLoiterRadius
433+
// Don't commit the radius in case this operation is undone
434+
}
435+
436+
Component.onCompleted: {
437+
radius.rawValue = _defaultLoiterRadius
438+
_commitRadius()
439+
}
440+
441+
function _commitRadius() {
442+
_committedRadius = radius.rawValue
443+
}
444+
445+
function _restoreRadius() {
446+
radius.rawValue = _committedRadius
405447
}
406448
}
407449
}
@@ -451,11 +493,17 @@ FlightMap {
451493
function actionConfirmed() {
452494
_commitCoordinate()
453495

496+
// Commit the new radius which possibly changed
497+
fwdFlightGotoMapCircle.actionConfirmed()
498+
454499
// We leave the indicator visible. The handling for onInGuidedModeChanged will hide it.
455500
}
456501

457502
function actionCancelled() {
458503
_restoreCoordinate()
504+
505+
// Also restore the loiter radius
506+
fwdFlightGotoMapCircle.actionCancelled()
459507
}
460508

461509
function _commitCoordinate() {

src/FlightDisplay/GuidedActionsController.qml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Item {
2929
property var missionController
3030
property var confirmDialog
3131
property var guidedValueSlider
32+
property var fwdFlightGotoMapCircle
3233
property var orbitMapCircle
3334

3435
readonly property string emergencyStopTitle: qsTr("EMERGENCY STOP")
@@ -48,6 +49,7 @@ Item {
4849
readonly property string pauseTitle: qsTr("Pause")
4950
readonly property string mvPauseTitle: qsTr("Pause (MV)")
5051
readonly property string changeAltTitle: qsTr("Change Altitude")
52+
readonly property string changeLoiterRadiusTitle: qsTr("Change Loiter Radius")
5153
readonly property string changeCruiseSpeedTitle: qsTr("Change Max Ground Speed")
5254
readonly property string changeAirspeedTitle: qsTr("Change Airspeed")
5355
readonly property string orbitTitle: qsTr("Orbit")
@@ -76,8 +78,9 @@ Item {
7678
readonly property string landMessage: qsTr("Land the vehicle at the current position.")
7779
readonly property string rtlMessage: qsTr("Return to the launch position of the vehicle.")
7880
readonly property string changeAltMessage: qsTr("Change the altitude of the vehicle up or down.")
81+
readonly property string changeLoiterRadiusMessage: qsTr("Change the forward flight loiter radius.")
7982
readonly property string changeCruiseSpeedMessage: qsTr("Change the maximum horizontal cruise speed.")
80-
readonly property string changeAirspeedMessage: qsTr("Change the equivalent airspeed setpoint")
83+
readonly property string changeAirspeedMessage: qsTr("Change the equivalent airspeed setpoint.")
8184
readonly property string gotoMessage: qsTr("Move the vehicle to the specified location.")
8285
property string setWaypointMessage: qsTr("Adjust current waypoint to %1.").arg(_actionData)
8386
readonly property string orbitMessage: qsTr("Orbit the vehicle around the specified location.")
@@ -123,6 +126,7 @@ Item {
123126
readonly property int actionChangeHeading: 30
124127
readonly property int actionMVArm: 31
125128
readonly property int actionMVDisarm: 32
129+
readonly property int actionChangeLoiterRadius: 33
126130

127131

128132

@@ -150,6 +154,7 @@ Item {
150154
property bool showContinueMission: _guidedActionsEnabled && _missionAvailable && !_missionActive && _vehicleArmed && _vehicleFlying && (_currentMissionIndex < _missionItemCount - 1)
151155
property bool showPause: _guidedActionsEnabled && _vehicleArmed && _activeVehicle.pauseVehicleSupported && _vehicleFlying && !_vehiclePaused && !_fixedWingOnApproach
152156
property bool showChangeAlt: _guidedActionsEnabled && _vehicleFlying && _activeVehicle.guidedModeSupported && _vehicleArmed && !_missionActive
157+
property bool showChangeLoiterRadius: _guidedActionsEnabled && _vehicleFlying && _activeVehicle.guidedModeSupported && _vehicleArmed && !_missionActive && _vehicleInFwdFlight && fwdFlightGotoMapCircle.visible
153158
property bool showChangeSpeed: _guidedActionsEnabled && _vehicleFlying && _activeVehicle.guidedModeSupported && _vehicleArmed && !_missionActive && _speedLimitsAvailable
154159
property bool showOrbit: _guidedActionsEnabled && _vehicleFlying && __orbitSupported && !_missionActive && _activeVehicle.homePosition.isValid && !isNaN(_activeVehicle.homePosition.altitude)
155160
property bool showROI: _guidedActionsEnabled && _vehicleFlying && __roiSupported
@@ -500,6 +505,13 @@ Item {
500505
confirmDialog.hideTrigger = Qt.binding(function() { return !showChangeAlt })
501506
guidedValueSlider.visible = true
502507
break;
508+
case actionChangeLoiterRadius:
509+
confirmDialog.title = changeLoiterRadiusTitle
510+
confirmDialog.message = changeLoiterRadiusMessage
511+
confirmDialog.hideTrigger = Qt.binding(function() { return !showChangeLoiterRadius })
512+
confirmDialog.mapIndicator = fwdFlightGotoMapCircle
513+
fwdFlightGotoMapCircle.startLoiterRadiusEdit()
514+
break
503515
case actionGoto:
504516
confirmDialog.title = gotoTitle
505517
confirmDialog.message = gotoMessage
@@ -649,6 +661,12 @@ Item {
649661
var altitudeChangeInMeters = valueInMeters - _activeVehicle.altitudeRelative.rawValue
650662
_activeVehicle.guidedModeChangeAltitude(altitudeChangeInMeters, false /* pauseVehicle */)
651663
break
664+
case actionChangeLoiterRadius:
665+
_activeVehicle.guidedModeGotoLocation(
666+
fwdFlightGotoMapCircle.coordinate,
667+
fwdFlightGotoMapCircle.radius.rawValue
668+
)
669+
break
652670
case actionGoto:
653671
_activeVehicle.guidedModeGotoLocation(
654672
actionData,

src/FlightMap/MapItems/QGCMapCircleVisuals.qml

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Item {
3131
property int borderWidth: 3
3232
property color borderColor: QGroundControl.globalPalette.mapMissionTrajectory
3333
property bool centerDragHandleVisible: true
34+
property bool radiusLabelVisible: false
3435
property real _radius: mapCircle ? mapCircle.radius.rawValue : 0
3536

3637
property var _circleComponent
@@ -178,13 +179,48 @@ Item {
178179
anchorPoint.y: dragHandle.height / 2
179180
z: QGroundControl.zOrderMapItems + 2
180181

181-
sourceItem: Rectangle {
182-
id: dragHandle
183-
width: ScreenTools.defaultFontPixelHeight * 1.5
184-
height: width
185-
radius: width / 2
186-
color: "white"
187-
opacity: .90
182+
sourceItem: Item {
183+
id: handleContainer
184+
width: dragHandle.width + labelControl.width
185+
height: dragHandle.height
186+
187+
Rectangle {
188+
id: dragHandle
189+
width: ScreenTools.defaultFontPixelHeight * 1.5
190+
height: width
191+
radius: width / 2
192+
color: "white"
193+
opacity: .90
194+
}
195+
196+
Rectangle {
197+
id: labelControl
198+
199+
anchors {
200+
bottom: dragHandle.top
201+
bottomMargin: ScreenTools.defaultFontPixelHeight * 0.25
202+
horizontalCenter: dragHandle.horizontalCenter
203+
}
204+
height: dragHandle.height
205+
width: labelText.width + (ScreenTools.defaultFontPixelHeight * 0.25 * 2)
206+
radius: height / 2
207+
208+
color: "white"
209+
opacity: 0.5
210+
visible: _root.radiusLabelVisible
211+
}
212+
213+
QGCLabel {
214+
id: labelText
215+
216+
anchors.centerIn: labelControl
217+
218+
color: "black"
219+
text: QGroundControl.unitsConversion.metersToAppSettingsHorizontalDistanceUnits(_radius).toFixed(0) +
220+
" " + QGroundControl.unitsConversion.appSettingsHorizontalDistanceUnitsString
221+
verticalAlignment: Text.AlignVCenter
222+
visible: labelControl.visible
223+
}
188224
}
189225
}
190226
}

0 commit comments

Comments
 (0)