Skip to content

Commit dd48f38

Browse files
rubenp02DonLakeFlyer
authored andcommitted
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 1828914 commit dd48f38

13 files changed

+65
-29
lines changed

src/FirmwarePlugin/APM/APMFirmwarePlugin.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ static void _MAV_CMD_DO_REPOSITION_ResultHandler(void *resultHandlerData, int /*
790790
delete data;
791791
}
792792

793-
void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate &gotoCoord) const
793+
void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate &gotoCoord, double forwardFlightLoiterRadius) const
794794
{
795795
if (qIsNaN(vehicle->altitudeRelative()->rawValue().toDouble())) {
796796
qgcApp()->showAppMessage(QStringLiteral("Unable to go to location, vehicle position not known."));
@@ -821,7 +821,7 @@ void APMFirmwarePlugin::guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoord
821821
MAV_FRAME_GLOBAL,
822822
-1.0f,
823823
MAV_DO_REPOSITION_FLAGS_CHANGE_MODE,
824-
0.0f,
824+
static_cast<float>(forwardFlightLoiterRadius),
825825
NAN,
826826
gotoCoord.latitude(),
827827
gotoCoord.longitude(),

src/FirmwarePlugin/APM/APMFirmwarePlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class APMFirmwarePlugin : public FirmwarePlugin
4040
bool isCapable(const Vehicle *vehicle, FirmwareCapabilities capabilities) const override;
4141
void setGuidedMode(Vehicle *vehicle, bool guidedMode) const override;
4242
void guidedModeTakeoff(Vehicle *vehicle, double altitudeRel) const override;
43-
void guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate& gotoCoord) const override;
43+
void guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius) const override;
4444
double minimumTakeoffAltitudeMeters(Vehicle *vehicle) const override;
4545
void startTakeoff(Vehicle *vehicle) const override;
4646
void startMission(Vehicle *vehicle) const override;

src/FirmwarePlugin/FirmwarePlugin.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ void FirmwarePlugin::guidedModeTakeoff(Vehicle *vehicle, double takeoffAltRel) c
153153
qgcApp()->showAppMessage(guided_mode_not_supported_by_vehicle);
154154
}
155155

156-
void FirmwarePlugin::guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate &gotoCoord) const
156+
void FirmwarePlugin::guidedModeGotoLocation(Vehicle *vehicle, const QGeoCoordinate &gotoCoord, double forwardFlightLoiterRadius) const
157157
{
158158
Q_UNUSED(vehicle);
159159
Q_UNUSED(gotoCoord);
160+
Q_UNUSED(forwardFlightLoiterRadius);
160161
qgcApp()->showAppMessage(guided_mode_not_supported_by_vehicle);
161162
}
162163

src/FirmwarePlugin/FirmwarePlugin.h

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

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

222222
/// Command vehicle to change altitude
223223
/// @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
@@ -400,8 +400,12 @@ bool PX4FirmwarePlugin::fixedWingAirSpeedLimitsAvailable(Vehicle* vehicle) const
400400
vehicle->parameterManager()->parameterExists(ParameterManager::defaultComponentId, "FW_AIRSPD_MAX");
401401
}
402402

403-
void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord) const
403+
void PX4FirmwarePlugin::guidedModeGotoLocation(Vehicle* vehicle, const QGeoCoordinate& gotoCoord, double forwardFlightLoiterRadius) const
404404
{
405+
// PX4 doesn't support setting the forward flight loiter radius of
406+
// MAV_CMD_DO_REPOSITION
407+
Q_UNUSED(forwardFlightLoiterRadius)
408+
405409
if (qIsNaN(vehicle->altitudeAMSL()->rawValue().toDouble())) {
406410
qgcApp()->showAppMessage(tr("Unable to go to location, vehicle position not known."));
407411
return;

src/FirmwarePlugin/PX4/PX4FirmwarePlugin.h

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

src/FlightDisplay/GuidedActionsController.qml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,12 @@ Item {
650650
_activeVehicle.guidedModeChangeAltitude(altitudeChangeInMeters, false /* pauseVehicle */)
651651
break
652652
case actionGoto:
653-
_activeVehicle.guidedModeGotoLocation(actionData)
653+
_activeVehicle.guidedModeGotoLocation(
654+
actionData,
655+
_vehicleInFwdFlight /* forwardFlightLoiterRadius */
656+
? _flyViewSettings.forwardFlightGoToLocationLoiterRad.value
657+
: 0
658+
)
654659
break
655660
case actionSetWaypoint:
656661
_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)