Skip to content

Commit 772af12

Browse files
committed
Support MAV_CMD_DO_REPOSITION radius parameter
Added support for the radius parameter of the MAV_CMD_DO_REPOSITION command. When in forward flight, this parameter can be used to specify the radius of the orbit around the Go here position in Guided Mode. A Fly View setting has been added to control this radius. Key changes: - Modified the guidedModeGotoLocation method across all firmware plugins to accept an optional forwardFlightLoiterRadius parameter, which sets the desired loiter radius during forward flight. - Added "Loiter Radius in Forward Flight" setting to the Guided Commands section of the FlyViewSettings to control the default radius. Note: PX4 doesn't doesn't handle the radius parameter per the MAVLink spec and therefore doesn't support this functionality.
1 parent 70fa6f6 commit 772af12

13 files changed

+64
-28
lines changed

src/FirmwarePlugin/APM/APMFirmwarePlugin.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static void _MAV_CMD_DO_REPOSITION_ResultHandler(void* resultHandlerData, int /*
798798
delete data;
799799
}
800800

801-
void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord)
801+
void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius)
802802
{
803803
if (qIsNaN(vehicle->altitudeRelative()->rawValue().toDouble())) {
804804
qgcApp()->showAppMessage(QStringLiteral("Unable to go to location, vehicle position not known."));
@@ -830,7 +830,7 @@ void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoord
830830
MAV_FRAME_GLOBAL,
831831
-1.0f,
832832
MAV_DO_REPOSITION_FLAGS_CHANGE_MODE,
833-
0.0f,
833+
static_cast<float>(forwardFlightLoiterRadius),
834834
NAN,
835835
gotoCoord.latitude(),
836836
gotoCoord.longitude(),

src/FirmwarePlugin/APM/APMFirmwarePlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class APMFirmwarePlugin : public FirmwarePlugin
4444
bool isCapable (const Vehicle *vehicle, FirmwareCapabilities capabilities) override;
4545
void setGuidedMode (Vehicle* vehicle, bool guidedMode) override;
4646
void guidedModeTakeoff (Vehicle* vehicle, double altitudeRel) override;
47-
void guidedModeGotoLocation (Vehicle* vehicle, const QGeoCoordinate& gotoCoord) override;
47+
void guidedModeGotoLocation (Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius) override;
4848
double minimumTakeoffAltitudeMeters (Vehicle* vehicle) override;
4949
void startMission (Vehicle* vehicle) override;
5050
QStringList flightModes (Vehicle* vehicle) override;

src/FirmwarePlugin/FirmwarePlugin.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ void FirmwarePlugin::guidedModeTakeoff(Vehicle* vehicle, double takeoffAltRel)
236236
qgcApp()->showAppMessage(guided_mode_not_supported_by_vehicle);
237237
}
238238

239-
void FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord)
239+
void FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius)
240240
{
241241
// Not supported by generic vehicle
242242
Q_UNUSED(vehicle);
243243
Q_UNUSED(gotoCoord);
244+
Q_UNUSED(forwardFlightLoiterRadius);
244245
qgcApp()->showAppMessage(guided_mode_not_supported_by_vehicle);
245246
}
246247

src/FirmwarePlugin/FirmwarePlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class FirmwarePlugin : public QObject
221221
virtual void startMission(Vehicle* vehicle);
222222

223223
/// Command vehicle to move to specified location (altitude is included and relative)
224-
virtual void guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord);
224+
virtual void guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius = 0.0);
225225

226226
/// Command vehicle to change altitude
227227
/// @param altitudeChange If > 0, go up by amount specified, if < 0, go down by amount specified

src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,12 @@ bool PX4FirmwarePlugin::fixedWingAirSpeedLimitsAvailable(Vehicle* vehicle)
407407
vehicle->parameterManager()->parameterExists(ParameterManager::defaultComponentId, "FW_AIRSPD_MAX");
408408
}
409409

410-
void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord)
410+
void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius)
411411
{
412+
// PX4 doesn't support setting the forward flight loiter radius of
413+
// MAV_CMD_DO_REPOSITION
414+
Q_UNUSED(forwardFlightLoiterRadius)
415+
412416
if (qIsNaN(vehicle->altitudeAMSL()->rawValue().toDouble())) {
413417
qgcApp()->showAppMessage(tr("Unable to go to location, vehicle position not known."));
414418
return;

src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PX4FirmwarePlugin : public FirmwarePlugin
5252
double minimumEquivalentAirspeed(Vehicle* vehicle) override;
5353
bool mulirotorSpeedLimitsAvailable(Vehicle* vehicle) override;
5454
bool fixedWingAirSpeedLimitsAvailable(Vehicle* vehicle) override;
55-
void guidedModeGotoLocation (Vehicle* vehicle, const QGeoCoordinate& gotoCoord) override;
55+
void guidedModeGotoLocation (Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius) override;
5656
void guidedModeChangeAltitude (Vehicle* vehicle, double altitudeRel, bool pauseVehicle) override;
5757
void guidedModeChangeGroundSpeedMetersSecond(Vehicle* vehicle, double groundspeed) override;
5858
void guidedModeChangeEquivalentAirspeedMetersSecond(Vehicle* vehicle, double airspeed_equiv) override;

src/FlightDisplay/GuidedActionsController.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,12 @@ Item {
646646
_activeVehicle.guidedModeChangeAltitude(altitudeChangeInMeters, false /* pauseVehicle */)
647647
break
648648
case actionGoto:
649-
_activeVehicle.guidedModeGotoLocation(actionData)
649+
_activeVehicle.guidedModeGotoLocation(
650+
actionData,
651+
_vehicleInFwdFlight /* forwardFlightLoiterRadius */
652+
? _flyViewSettings.forwardFlightGoToLocationLoiterRad.value
653+
: 0
654+
)
650655
break
651656
case actionSetWaypoint:
652657
_activeVehicle.setCurrentMissionSequence(actionData)

src/Settings/FlyView.SettingsGroup.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@
6161
"default": 1000,
6262
"min": 1
6363
},
64+
{
65+
"name": "forwardFlightGoToLocationLoiterRad",
66+
"shortDesc": "Loiter radius for orbiting the Go To Location during forward flight. This only applies if the firmware supports a radius in MAV_CMD_DO_REPOSITION commands.",
67+
"type": "double",
68+
"units": "m",
69+
"default": 80,
70+
"min": 25
71+
},
6472
{
6573
"name": "updateHomePosition",
6674
"shortDesc": "Send updated GCS' home position to autopilot in case of change of the home position",

src/Settings/FlyViewSettings.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ DECLARE_SETTINGSFACT(FlyViewSettings, showLogReplayStatusBar)
2222
DECLARE_SETTINGSFACT(FlyViewSettings, showAdditionalIndicatorsCompass)
2323
DECLARE_SETTINGSFACT(FlyViewSettings, lockNoseUpCompass)
2424
DECLARE_SETTINGSFACT(FlyViewSettings, maxGoToLocationDistance)
25+
DECLARE_SETTINGSFACT(FlyViewSettings, forwardFlightGoToLocationLoiterRad)
2526
DECLARE_SETTINGSFACT(FlyViewSettings, keepMapCenteredOnVehicle)
2627
DECLARE_SETTINGSFACT(FlyViewSettings, showSimpleCameraControl)
2728
DECLARE_SETTINGSFACT(FlyViewSettings, showObstacleDistanceOverlay)

src/Settings/FlyViewSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class FlyViewSettings : public SettingsGroup
2525
DEFINE_SETTINGFACT(showAdditionalIndicatorsCompass)
2626
DEFINE_SETTINGFACT(lockNoseUpCompass)
2727
DEFINE_SETTINGFACT(maxGoToLocationDistance)
28+
DEFINE_SETTINGFACT(forwardFlightGoToLocationLoiterRad)
2829
DEFINE_SETTINGFACT(keepMapCenteredOnVehicle)
2930
DEFINE_SETTINGFACT(showSimpleCameraControl)
3031
DEFINE_SETTINGFACT(showObstacleDistanceOverlay)

0 commit comments

Comments
 (0)