Fix ArduPilot "flying" determination
This commit is contained in:
@@ -279,20 +279,15 @@ bool APMFirmwarePlugin::_handleIncomingStatusText(Vehicle* /*vehicle*/, mavlink_
|
||||
|
||||
void APMFirmwarePlugin::_handleIncomingHeartbeat(Vehicle* vehicle, mavlink_message_t* message)
|
||||
{
|
||||
bool flying = false;
|
||||
|
||||
mavlink_heartbeat_t heartbeat;
|
||||
mavlink_msg_heartbeat_decode(message, &heartbeat);
|
||||
|
||||
if (message->compid == MAV_COMP_ID_AUTOPILOT1) {
|
||||
// We pull Vehicle::flying state from HEARTBEAT on ArduPilot. This is a firmware specific test.
|
||||
if (vehicle->armed()) {
|
||||
bool flying = false;
|
||||
|
||||
flying = heartbeat.system_status == MAV_STATE_ACTIVE;
|
||||
if (!flying && vehicle->flying()) {
|
||||
// If we were previously flying, and we go into critical or emergency assume we are still flying
|
||||
flying = heartbeat.system_status == MAV_STATE_CRITICAL || heartbeat.system_status == MAV_STATE_EMERGENCY;
|
||||
}
|
||||
// We pull Vehicle::flying state from HEARTBEAT on ArduPilot. This is a firmware specific test.
|
||||
if (vehicle->armed() && (heartbeat.system_status == MAV_STATE_ACTIVE || heartbeat.system_status == MAV_STATE_CRITICAL || heartbeat.system_status == MAV_STATE_EMERGENCY)) {
|
||||
flying = true;
|
||||
}
|
||||
vehicle->_setFlying(flying);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user