mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 23:56:33 +00:00
Improve use of MAVSDK::first_autopilot()
Check return value of MAVSDK::first_autopilot(). Before application crashed if ArduPilot was not running. Type: Improvement Issue: https://denyspopov.atlassian.net/browse/AZ-17
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
const char *AZ_CONNECTION_SERIAL = "serial:///dev/ttyS0:115200";
|
const char *AZ_CONNECTION_SERIAL = "serial:///dev/ttyS0:115200";
|
||||||
const char *AZ_CONNECTION_UDP = "udp://:14550";
|
const char *AZ_CONNECTION_UDP = "udp://:14550";
|
||||||
const int AZ_RELATIVE_FLY_ALTITUDE = 50;
|
const int AZ_RELATIVE_FLY_ALTITUDE = 50;
|
||||||
|
const float AZ_GET_AUTOPILOT_TIMEOUT = 3.0;
|
||||||
|
|||||||
@@ -73,8 +73,16 @@ bool AzDroneController::stateConnect(void)
|
|||||||
|
|
||||||
bool AzDroneController::stateAutopilot(void)
|
bool AzDroneController::stateAutopilot(void)
|
||||||
{
|
{
|
||||||
// Get the first autopilot from the flight controller.
|
std::optional<std::shared_ptr<System>> autopilot = mMavsdk.first_autopilot(AZ_GET_AUTOPILOT_TIMEOUT);
|
||||||
return (mSystem = mMavsdk.first_autopilot(3.0).value()) != nullptr;
|
|
||||||
|
if (autopilot.has_value()) {
|
||||||
|
mSystem = autopilot.value();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
qCritical() << "MAVSDK::first_autopilot() failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AzDroneController::stateTelemetryModule(void)
|
bool AzDroneController::stateTelemetryModule(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user