Skip to content

Commit 3a75a8c

Browse files
committed
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.
1 parent 450cf2a commit 3a75a8c

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ FlightMap {
388388
_activeVehicle.inFwdFlight &&
389389
!_activeVehicle.orbitActive
390390

391+
property alias coordinate: _fwdFlightGotoMapCircle.center
392+
property alias radius: _fwdFlightGotoMapCircle.radius
393+
394+
Component.onCompleted: {
395+
// Only allow editing the radius, not the position
396+
centerDragHandleVisible = false
397+
398+
globals.guidedControllerFlyView.fwdFlightGotoMapCircle = this
399+
}
400+
391401
Connections {
392402
target: QGroundControl.multiVehicleManager
393403
function onActiveVehicleChanged(activeVehicle) {
@@ -403,16 +413,47 @@ FlightMap {
403413
value: gotoLocationItem.coordinate
404414
}
405415

416+
function startLoiterRadiusEdit() {
417+
_fwdFlightGotoMapCircle.interactive = true
418+
}
419+
420+
// Called when loiter edit is confirmed
421+
function actionConfirmed() {
422+
_fwdFlightGotoMapCircle.interactive = false
423+
_fwdFlightGotoMapCircle._commitRadius()
424+
}
425+
426+
// Called when loiter edit is cancelled
427+
function actionCancelled() {
428+
_fwdFlightGotoMapCircle.interactive = false
429+
_fwdFlightGotoMapCircle._restoreRadius()
430+
}
431+
406432
QGCMapCircle {
407433
id: _fwdFlightGotoMapCircle
408434
interactive: false
409435
showRotation: true
410436
clockwiseRotation: true
411437

412438
property real _defaultLoiterRadius: _flyViewSettings.forwardFlightGoToLocationLoiterRad.value
439+
property real _committedRadius;
413440

414441
onCenterChanged: {
415442
radius.rawValue = _defaultLoiterRadius
443+
// Don't commit the radius in case this operation is undone
444+
}
445+
446+
Component.onCompleted: {
447+
radius.rawValue = _defaultLoiterRadius
448+
_commitRadius()
449+
}
450+
451+
function _commitRadius() {
452+
_committedRadius = radius.rawValue
453+
}
454+
455+
function _restoreRadius() {
456+
radius.rawValue = _committedRadius
416457
}
417458
}
418459
}
@@ -462,11 +503,17 @@ FlightMap {
462503
function actionConfirmed() {
463504
_commitCoordinate()
464505

506+
// Commit the new radius which possibly changed
507+
fwdFlightGotoMapCircle.actionConfirmed()
508+
465509
// We leave the indicator visible. The handling for onInGuidedModeChanged will hide it.
466510
}
467511

468512
function actionCancelled() {
469513
_restoreCoordinate()
514+
515+
// Also restore the loiter radius
516+
fwdFlightGotoMapCircle.actionCancelled()
470517
}
471518

472519
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
@@ -645,6 +657,12 @@ Item {
645657
var altitudeChangeInMeters = valueInMeters - _activeVehicle.altitudeRelative.rawValue
646658
_activeVehicle.guidedModeChangeAltitude(altitudeChangeInMeters, false /* pauseVehicle */)
647659
break
660+
case actionChangeLoiterRadius:
661+
_activeVehicle.guidedModeGotoLocation(
662+
fwdFlightGotoMapCircle.coordinate,
663+
fwdFlightGotoMapCircle.radius.rawValue
664+
)
665+
break
648666
case actionGoto:
649667
_activeVehicle.guidedModeGotoLocation(
650668
actionData,

0 commit comments

Comments
 (0)