Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/FlyView/GuidedActionsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ Item {
case actionSetWaypoint:
confirmDialog.title = setWaypointTitle
confirmDialog.message = setWaypointMessage
if (_activeVehicle.supports.restartMission) {
confirmDialog.optionText = qsTr("Restart Mission")
confirmDialog.optionChecked = false
}
break;
case actionOrbit:
confirmDialog.title = orbitTitle
Expand Down Expand Up @@ -635,7 +639,7 @@ Item {
}
break
case actionSetWaypoint:
_activeVehicle.setCurrentMissionSequence(actionData)
_activeVehicle.setCurrentMissionSequence(actionData, optionChecked /* restartMission */)
break
case actionOrbit:
var valueInMeters = _unitsConversion.appSettingsVerticalDistanceUnitsToMeters(sliderOutputValue)
Expand Down
5 changes: 3 additions & 2 deletions src/Vehicle/Vehicle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ void Vehicle::landingGearRetract()
1.0f); // up
}

void Vehicle::setCurrentMissionSequence(int seq)
void Vehicle::setCurrentMissionSequence(int seq, bool restartMission)
{
if (!_firmwarePlugin->sendHomePositionToVehicle()) {
seq--;
Expand Down Expand Up @@ -2124,7 +2124,8 @@ void Vehicle::setCurrentMissionSequence(int seq)
static_cast<uint8_t>(defaultComponentId()),
MAV_CMD_DO_SET_MISSION_CURRENT,
true, // showError
static_cast<uint16_t>(seq)
static_cast<uint16_t>(seq),
restartMission ? 1.0f : 0.0f
);
}

Expand Down
12 changes: 8 additions & 4 deletions src/Vehicle/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,22 @@ class Vehicle : public VehicleFactGroup, public VehicleTypes
/// Command vehicle to abort landing
Q_INVOKABLE void abortLanding(double climbOutAltitude);

/// Command vichecle to deploy landing gear
/// Command vehicle to deploy landing gear
Q_INVOKABLE void landingGearDeploy();

/// Command vichecle to retract landing gear
/// Command vehicle to retract landing gear
Q_INVOKABLE void landingGearRetract();

Q_INVOKABLE void startTakeoff();

Q_INVOKABLE void startMission();

/// Alter the current mission item on the vehicle
Q_INVOKABLE void setCurrentMissionSequence(int seq);
/// Set the current mission item on the vehicle.
/// @param seq Mission sequence number to make current.
/// @param restartMission Passed as param2 of MAV_CMD_DO_SET_MISSION_CURRENT when the
/// firmware supports that command (e.g. ArduPilot). Has no effect on firmware
/// that falls back to the deprecated MISSION_SET_CURRENT message (e.g. PX4).
Q_INVOKABLE void setCurrentMissionSequence(int seq, bool restartMission = false);

/// Reboot vehicle
Q_INVOKABLE void rebootVehicle();
Expand Down
8 changes: 8 additions & 0 deletions src/Vehicle/VehicleSupports.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ bool VehicleSupports::changeHeading() const
{
return _vehicle->firmwarePlugin()->isCapable(_vehicle, FirmwarePlugin::ChangeHeadingCapability);
}

bool VehicleSupports::restartMission() const
{
auto* instanceData = _vehicle->firmwarePluginInstanceData();
if (!instanceData) return false;
return instanceData->anyVersionSupportsCommand(MAV_CMD_DO_SET_MISSION_CURRENT)
== FirmwarePluginInstanceData::CommandSupportedResult::SUPPORTED;
}
2 changes: 2 additions & 0 deletions src/Vehicle/VehicleSupports.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VehicleSupports : public QObject
Q_PROPERTY(bool guidedTakeoffWithAltitude READ guidedTakeoffWithAltitude CONSTANT)
Q_PROPERTY(bool guidedTakeoffWithoutAltitude READ guidedTakeoffWithoutAltitude CONSTANT)
Q_PROPERTY(bool changeHeading READ changeHeading CONSTANT)
Q_PROPERTY(bool restartMission READ restartMission CONSTANT)

bool throttleModeCenterZero() const;
bool negativeThrust() const;
Expand All @@ -46,6 +47,7 @@ class VehicleSupports : public QObject
bool guidedTakeoffWithAltitude() const;
bool guidedTakeoffWithoutAltitude() const;
bool changeHeading() const;
bool restartMission() const;

signals:
void terrainFrameChanged();
Expand Down
Loading