Skip to content
Open
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
19 changes: 10 additions & 9 deletions src/FirmwarePlugin/APM/APMFirmwarePlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1044,23 +1044,24 @@ bool APMFirmwarePlugin::_guidedModeTakeoff(Vehicle *vehicle, double altitudeRel)
return true;
}


void APMFirmwarePlugin::startTakeoff(Vehicle *vehicle) const
{
if (vehicle->flying()) {
QGC::showAppMessage(tr("Unable to start takeoff: Vehicle is already in the air."));
return;
}

if (!vehicle->armed()) {
if (!_setFlightModeAndValidate(vehicle, takeOffFlightMode())) {
QGC::showAppMessage(tr("Unable to start takeoff: Vehicle failed to change to Takeoff mode."));
return;
}
// The vehicle is on the ground, so it's safe to switch to Takeoff mode regardless of arming state
if (!_setFlightModeAndValidate(vehicle, takeOffFlightMode())) {
QGC::showAppMessage(tr("Unable to start takeoff: Vehicle failed to change to Takeoff mode."));
return;
}

if (!_armVehicleAndValidate(vehicle)) {
QGC::showAppMessage(tr("Unable to start takeoff: Vehicle failed to arm."));
return;
}
// Only arm the vehicle if it is not already armed
if (!vehicle->armed() && !_armVehicleAndValidate(vehicle)) {
QGC::showAppMessage(tr("Unable to start takeoff: Vehicle failed to arm."));
return;
}
}

Expand Down
Loading