From a3e7464906cd3902d8adb14549def876f3218a55 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 22 Nov 2024 13:16:17 -0500 Subject: [PATCH] ADSB: Handle Missing Data --- src/ADSB/ADSB.h | 29 +++++--- src/ADSB/ADSBTCPLink.cc | 43 ++++++------ src/ADSB/ADSBVehicle.cc | 52 ++++++++++---- src/ADSB/ADSBVehicle.h | 23 +++++-- src/ADSB/ADSBVehicleManager.cc | 121 +++++++++++++++++++++++++++++++-- src/ADSB/ADSBVehicleManager.h | 8 ++- src/ADSB/CMakeLists.txt | 1 + src/Vehicle/Vehicle.cc | 36 +--------- src/Vehicle/Vehicle.h | 1 - test/ADSB/ADSBTest.cc | 6 +- 10 files changed, 220 insertions(+), 100 deletions(-) diff --git a/src/ADSB/ADSB.h b/src/ADSB/ADSB.h index b533ee70138..470097453a9 100644 --- a/src/ADSB/ADSB.h +++ b/src/ADSB/ADSB.h @@ -38,24 +38,33 @@ Q_ENUM_NS(MessageType) /// Enum for ADSB Info Types Available. enum AvailableInfoType { - CallsignAvailable = 1 << 0, - LocationAvailable = 1 << 1, - AltitudeAvailable = 1 << 2, - HeadingAvailable = 1 << 3, - AlertAvailable = 1 << 4, + LocationAvailable = 1 << 0, + AltitudeAvailable = 1 << 1, + HeadingAvailable = 1 << 2, + VelocityAvailable = 1 << 3, + CallsignAvailable = 1 << 4, + SquawkAvailable = 1 << 5, + VerticalVelAvailable = 1 << 6, + AlertAvailable = 1 << 7 }; Q_FLAG_NS(AvailableInfoType) Q_DECLARE_FLAGS(AvailableInfoTypes, AvailableInfoType) Q_DECLARE_OPERATORS_FOR_FLAGS(AvailableInfoTypes) struct VehicleInfo_t { - uint32_t icaoAddress; + AvailableInfoTypes availableFlags; + uint32_t icaoAddress = 0; QString callsign; QGeoCoordinate location; - double altitude; // TODO: Use Altitude in QGeoCoordinate? - double heading; - bool alert; - AvailableInfoTypes availableFlags; + double heading = 0.0; + uint16_t squawk = 0; + double velocity = 0.0; + double verticalVel = 0.0; + uint32_t lastContact = 0; + bool simulated = false; + bool baro = false; + bool alert = false; + // TODO: Use QGeoPositionInfo, QGeoPositionInfoSource, QGeoPositionInfoSourceFactory }; } // namespace ADSB diff --git a/src/ADSB/ADSBTCPLink.cc b/src/ADSB/ADSBTCPLink.cc index 022ad81fd62..30937ce9e1c 100644 --- a/src/ADSB/ADSBTCPLink.cc +++ b/src/ADSB/ADSBTCPLink.cc @@ -24,24 +24,26 @@ ADSBTCPLink::ADSBTCPLink(const QHostAddress &hostAddress, quint16 port, QObject , _processTimer(new QTimer(this)) { #ifdef QT_DEBUG - (void) connect(_socket, &QTcpSocket::stateChanged, this, [](QTcpSocket::SocketState state) { - switch (state) { - case QTcpSocket::UnconnectedState: - qCDebug(ADSBTCPLinkLog) << "ADSB Socket disconnected"; - break; - case QTcpSocket::SocketState::ConnectingState: - qCDebug(ADSBTCPLinkLog) << "ADSB Socket connecting..."; - break; - case QTcpSocket::SocketState::ConnectedState: - qCDebug(ADSBTCPLinkLog) << "ADSB Socket connected"; - break; - case QTcpSocket::SocketState::ClosingState: - qCDebug(ADSBTCPLinkLog) << "ADSB Socket closing..."; - break; - default: - break; - } - }, Qt::AutoConnection); + if (ADSBTCPLinkLog().isDebugEnabled()) { + (void) connect(_socket, &QTcpSocket::stateChanged, this, [](QTcpSocket::SocketState state) { + switch (state) { + case QTcpSocket::UnconnectedState: + qCDebug(ADSBTCPLinkLog) << "ADSB Socket disconnected"; + break; + case QTcpSocket::SocketState::ConnectingState: + qCDebug(ADSBTCPLinkLog) << "ADSB Socket connecting..."; + break; + case QTcpSocket::SocketState::ConnectedState: + qCDebug(ADSBTCPLinkLog) << "ADSB Socket connected"; + break; + case QTcpSocket::SocketState::ClosingState: + qCDebug(ADSBTCPLinkLog) << "ADSB Socket closing..."; + break; + default: + break; + } + }, Qt::AutoConnection); + } #endif (void) QObject::connect(_socket, &QTcpSocket::errorOccurred, this, [this](QTcpSocket::SocketError error) { @@ -55,8 +57,6 @@ ADSBTCPLink::ADSBTCPLink(const QHostAddress &hostAddress, quint16 port, QObject _processTimer->setInterval(_processInterval); // Set an interval for processing lines (void) connect(_processTimer, &QTimer::timeout, this, &ADSBTCPLink::_processLines); - init(); - // qCDebug(ADSBTCPLinkLog) << Q_FUNC_INFO << this; } @@ -209,10 +209,9 @@ void ADSBTCPLink::_parseAndEmitLocation(ADSB::VehicleInfo_t &adsbInfo, const QSt } const double altitude = modeCAltitude * 0.3048; - const QGeoCoordinate location(lat, lon); + const QGeoCoordinate location(lat, lon, altitude); adsbInfo.location = location; - adsbInfo.altitude = altitude; adsbInfo.alert = (alert == 1); adsbInfo.availableFlags = ADSB::LocationAvailable | ADSB::AltitudeAvailable | ADSB::AlertAvailable; diff --git a/src/ADSB/ADSBVehicle.cc b/src/ADSB/ADSBVehicle.cc index b17ab35e534..115fea20196 100644 --- a/src/ADSB/ADSBVehicle.cc +++ b/src/ADSB/ADSBVehicle.cc @@ -18,15 +18,15 @@ QGC_LOGGING_CATEGORY(ADSBVehicleLog, "qgc.adsb.adsbvehicle") ADSBVehicle::ADSBVehicle(const ADSB::VehicleInfo_t &vehicleInfo, QObject *parent) : QObject(parent) { + // qCDebug(ADSBVehicleLog) << Q_FUNC_INFO << this; + _info.icaoAddress = vehicleInfo.icaoAddress; update(vehicleInfo); - - // qCDebug(ADSBTCPLinkLog) << Q_FUNC_INFO << this; } ADSBVehicle::~ADSBVehicle() { - // qCDebug(ADSBTCPLinkLog) << Q_FUNC_INFO << this; + // qCDebug(ADSBVehicleLog) << Q_FUNC_INFO << this; } void ADSBVehicle::update(const ADSB::VehicleInfo_t &vehicleInfo) @@ -38,23 +38,17 @@ void ADSBVehicle::update(const ADSB::VehicleInfo_t &vehicleInfo) qCDebug(ADSBVehicleLog) << "Updating" << QStringLiteral("%1 Flags: %2").arg(vehicleInfo.icaoAddress, 0, 16).arg(vehicleInfo.availableFlags, 0, 2); - if (vehicleInfo.availableFlags & ADSB::CallsignAvailable) { - if (vehicleInfo.callsign != callsign()) { - _info.callsign = vehicleInfo.callsign; - emit callsignChanged(); - } - } - if (vehicleInfo.availableFlags & ADSB::LocationAvailable) { - if (vehicleInfo.location != coordinate()) { - _info.location = vehicleInfo.location; + if (!QGC::fuzzyCompare(vehicleInfo.location.latitude(), coordinate().latitude()) || !QGC::fuzzyCompare(vehicleInfo.location.longitude(), coordinate().longitude())) { + _info.location.setLatitude(vehicleInfo.location.latitude()); + _info.location.setLongitude(vehicleInfo.location.longitude()); emit coordinateChanged(); } } if (vehicleInfo.availableFlags & ADSB::AltitudeAvailable) { - if (!QGC::fuzzyCompare(vehicleInfo.altitude, altitude())) { - _info.altitude = vehicleInfo.altitude; + if (!QGC::fuzzyCompare(vehicleInfo.location.altitude(), altitude())) { + _info.location.setAltitude(vehicleInfo.location.altitude()); emit altitudeChanged(); } } @@ -66,6 +60,34 @@ void ADSBVehicle::update(const ADSB::VehicleInfo_t &vehicleInfo) } } + if (vehicleInfo.availableFlags & ADSB::VelocityAvailable) { + if (!QGC::fuzzyCompare(vehicleInfo.velocity, velocity())) { + _info.velocity = vehicleInfo.velocity; + emit velocityChanged(); + } + } + + if (vehicleInfo.availableFlags & ADSB::CallsignAvailable) { + if (vehicleInfo.callsign != callsign()) { + _info.callsign = vehicleInfo.callsign; + emit callsignChanged(); + } + } + + if (vehicleInfo.availableFlags & ADSB::SquawkAvailable) { + if (!QGC::fuzzyCompare(vehicleInfo.velocity, squawk())) { + _info.squawk = vehicleInfo.squawk; + emit squawkChanged(); + } + } + + if (vehicleInfo.availableFlags & ADSB::VerticalVelAvailable) { + if (!QGC::fuzzyCompare(vehicleInfo.verticalVel, verticalVel())) { + _info.verticalVel = vehicleInfo.verticalVel; + emit verticalVelChanged(); + } + } + if (vehicleInfo.availableFlags & ADSB::AlertAvailable) { if (vehicleInfo.alert != alert()) { _info.alert = vehicleInfo.alert; @@ -73,5 +95,5 @@ void ADSBVehicle::update(const ADSB::VehicleInfo_t &vehicleInfo) } } - (void) _lastUpdateTimer.restart(); + _lastUpdateTimer.start(); } diff --git a/src/ADSB/ADSBVehicle.h b/src/ADSB/ADSBVehicle.h index 2633e95da18..c607f8c285a 100644 --- a/src/ADSB/ADSBVehicle.h +++ b/src/ADSB/ADSBVehicle.h @@ -25,12 +25,15 @@ class ADSBVehicle : public QObject Q_OBJECT QML_ELEMENT - Q_PROPERTY(uint icaoAddress READ icaoAddress CONSTANT) - Q_PROPERTY(QString callsign READ callsign NOTIFY callsignChanged) - Q_PROPERTY(QGeoCoordinate coordinate READ coordinate NOTIFY coordinateChanged) - Q_PROPERTY(double altitude READ altitude NOTIFY altitudeChanged) - Q_PROPERTY(double heading READ heading NOTIFY headingChanged) - Q_PROPERTY(bool alert READ alert NOTIFY alertChanged) + Q_PROPERTY(uint icaoAddress READ icaoAddress CONSTANT) + Q_PROPERTY(QString callsign READ callsign NOTIFY callsignChanged) + Q_PROPERTY(QGeoCoordinate coordinate READ coordinate NOTIFY coordinateChanged) + Q_PROPERTY(double altitude READ altitude NOTIFY altitudeChanged) + Q_PROPERTY(double heading READ heading NOTIFY headingChanged) + Q_PROPERTY(double velocity READ velocity NOTIFY velocityChanged) + Q_PROPERTY(double verticalVel READ verticalVel NOTIFY verticalVelChanged) + Q_PROPERTY(uint16_t squawk READ squawk NOTIFY squawkChanged) + Q_PROPERTY(bool alert READ alert NOTIFY alertChanged) public: explicit ADSBVehicle(const ADSB::VehicleInfo_t &vehicleInfo, QObject *parent = nullptr); @@ -39,8 +42,11 @@ class ADSBVehicle : public QObject uint32_t icaoAddress() const { return _info.icaoAddress; } QString callsign() const { return _info.callsign; } QGeoCoordinate coordinate() const { return _info.location; } - double altitude() const { return _info.altitude; } + double altitude() const { return _info.location.altitude(); } double heading() const { return _info.heading; } + double velocity() const { return _info.velocity; } + double verticalVel() const { return _info.verticalVel; } + uint16_t squawk() const { return _info.squawk; } bool alert() const { return _info.alert; } bool expired() const { return _lastUpdateTimer.hasExpired(_expirationTimeoutMs); } void update(const ADSB::VehicleInfo_t &vehicleInfo); @@ -50,6 +56,9 @@ class ADSBVehicle : public QObject void callsignChanged(); void altitudeChanged(); void headingChanged(); + void velocityChanged(); + void verticalVelChanged(); + void squawkChanged(); void alertChanged(); private: diff --git a/src/ADSB/ADSBVehicleManager.cc b/src/ADSB/ADSBVehicleManager.cc index 503d52c9c3e..6cc196a07ee 100644 --- a/src/ADSB/ADSBVehicleManager.cc +++ b/src/ADSB/ADSBVehicleManager.cc @@ -31,6 +31,8 @@ ADSBVehicleManager::ADSBVehicleManager(ADSBVehicleManagerSettings *settings, QOb , _adsbVehicleCleanupTimer(new QTimer(this)) , _adsbVehicles(new QmlObjectListModel(this)) { + // qCDebug(ADSBVehicleManagerLog) << Q_FUNC_INFO << this; + (void) qRegisterMetaType("ADSB::VehicleInfo_t"); _adsbVehicleCleanupTimer->setSingleShot(false); @@ -52,13 +54,11 @@ ADSBVehicleManager::ADSBVehicleManager(ADSBVehicleManagerSettings *settings, QOb if (adsbEnabled->rawValue().toBool()) { _start(hostAddress->rawValue().toString(), port->rawValue().toUInt()); } - - // qCDebug(ADSBTCPLinkLog) << Q_FUNC_INFO << this; } ADSBVehicleManager::~ADSBVehicleManager() { - // qCDebug(ADSBTCPLinkLog) << Q_FUNC_INFO << this; + // qCDebug(ADSBVehicleManagerLog) << Q_FUNC_INFO << this; } ADSBVehicleManager *ADSBVehicleManager::instance() @@ -66,6 +66,108 @@ ADSBVehicleManager *ADSBVehicleManager::instance() return _adsbVehicleManager(); } +void ADSBVehicleManager::mavlinkMessageReceived(const mavlink_message_t &message) +{ + if (message.msgid != MAVLINK_MSG_ID_ADSB_VEHICLE) { + return; + } + + _handleADSBVehicle(message); +} + +void ADSBVehicleManager::_handleADSBVehicle(const mavlink_message_t &message) +{ + mavlink_adsb_vehicle_t adsbVehicleMsg{}; + mavlink_msg_adsb_vehicle_decode(&message, &adsbVehicleMsg); + + if (adsbVehicleMsg.tslc > kMaxTimeSinceLastSeen) { + return; + } + + ADSB::VehicleInfo_t vehicleInfo{}; + + vehicleInfo.availableFlags = ADSB::AvailableInfoTypes::fromInt(0); + + vehicleInfo.icaoAddress = adsbVehicleMsg.ICAO_address; + vehicleInfo.lastContact = adsbVehicleMsg.tslc; + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_COORDS) { + vehicleInfo.availableFlags |= ADSB::LocationAvailable; + vehicleInfo.location.setLatitude(adsbVehicleMsg.lat / 1e7); + vehicleInfo.location.setLongitude(adsbVehicleMsg.lon / 1e7); + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_ALTITUDE) { + vehicleInfo.availableFlags |= ADSB::AltitudeAvailable; + vehicleInfo.location.setAltitude(adsbVehicleMsg.altitude / 1e3); + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_HEADING) { + vehicleInfo.availableFlags |= ADSB::HeadingAvailable; + vehicleInfo.heading = adsbVehicleMsg.heading / 1e2; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_VELOCITY) { + vehicleInfo.availableFlags |= ADSB::VelocityAvailable; + vehicleInfo.velocity = adsbVehicleMsg.hor_velocity / 1e2; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_CALLSIGN) { + vehicleInfo.availableFlags |= ADSB::CallsignAvailable; + vehicleInfo.callsign = QString::fromLatin1(adsbVehicleMsg.callsign, sizeof(adsbVehicleMsg.callsign)); + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_SQUAWK) { + vehicleInfo.availableFlags |= ADSB::SquawkAvailable; + vehicleInfo.squawk = adsbVehicleMsg.squawk; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_SIMULATED) { + vehicleInfo.simulated = true; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_VERTICAL_VELOCITY_VALID) { + vehicleInfo.availableFlags |= ADSB::VerticalVelAvailable; + vehicleInfo.verticalVel = adsbVehicleMsg.ver_velocity; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_BARO_VALID) { + vehicleInfo.baro = true; + } + + if (adsbVehicleMsg.flags & ADSB_FLAGS_SOURCE_UAT) { + + } + + /*adsbVehicleMsg.altitude_type + ADSB_ALTITUDE_TYPE_PRESSURE_QNH + ADSB_ALTITUDE_TYPE_GEOMETRIC + + adsbVehicleMsg.emitter_type + ADSB_EMITTER_TYPE_NO_INFO + ADSB_EMITTER_TYPE_LIGHT + ADSB_EMITTER_TYPE_SMALL + ADSB_EMITTER_TYPE_LARGE + ADSB_EMITTER_TYPE_HIGH_VORTEX_LARGE + ADSB_EMITTER_TYPE_HEAVY + ADSB_EMITTER_TYPE_HIGHLY_MANUV + ADSB_EMITTER_TYPE_ROTOCRAFT + ADSB_EMITTER_TYPE_UNASSIGNED + ADSB_EMITTER_TYPE_GLIDER + ADSB_EMITTER_TYPE_LIGHTER_AIR + ADSB_EMITTER_TYPE_PARACHUTE + ADSB_EMITTER_TYPE_ULTRA_LIGHT + ADSB_EMITTER_TYPE_UNASSIGNED2 + ADSB_EMITTER_TYPE_UAV + ADSB_EMITTER_TYPE_SPACE + ADSB_EMITTER_TYPE_UNASSGINED3 + ADSB_EMITTER_TYPE_EMERGENCY_SURFACE + ADSB_EMITTER_TYPE_SERVICE_SURFACE + ADSB_EMITTER_TYPE_POINT_OBSTACLE*/ + + (void) QMetaObject::invokeMethod(this, [this, &vehicleInfo] { adsbVehicleUpdate(vehicleInfo); }, Qt::AutoConnection); +} + void ADSBVehicleManager::adsbVehicleUpdate(const ADSB::VehicleInfo_t &vehicleInfo) { const uint32_t icaoAddress = vehicleInfo.icaoAddress; @@ -77,7 +179,7 @@ void ADSBVehicleManager::adsbVehicleUpdate(const ADSB::VehicleInfo_t &vehicleInf if (vehicleInfo.availableFlags & ADSB::LocationAvailable) { ADSBVehicle* const adsbVehicle = new ADSBVehicle(vehicleInfo, this); _adsbICAOMap[icaoAddress] = adsbVehicle; - (void) _adsbVehicles->append(adsbVehicle); + _adsbVehicles->append(adsbVehicle); qCDebug(ADSBVehicleManagerLog) << "Added" << QString::number(adsbVehicle->icaoAddress()); } } @@ -85,7 +187,16 @@ void ADSBVehicleManager::adsbVehicleUpdate(const ADSB::VehicleInfo_t &vehicleInf void ADSBVehicleManager::_start(const QString &hostAddress, quint16 port) { Q_ASSERT(!_adsbTcpLink); - _adsbTcpLink = new ADSBTCPLink(QHostAddress(hostAddress), port, this); + + ADSBTCPLink *adsbTcpLink = new ADSBTCPLink(QHostAddress(hostAddress), port, this); + if (!adsbTcpLink->init()) { + delete adsbTcpLink; + adsbTcpLink = nullptr; + qCWarning(ADSBVehicleManagerLog) << "Failed to Initialize TCP Link at:" << hostAddress << port; + return; + } + + _adsbTcpLink = adsbTcpLink; (void) connect(_adsbTcpLink, &ADSBTCPLink::adsbVehicleUpdate, this, &ADSBVehicleManager::adsbVehicleUpdate, Qt::AutoConnection); (void) connect(_adsbTcpLink, &ADSBTCPLink::errorOccurred, this, &ADSBVehicleManager::_linkError, Qt::AutoConnection); diff --git a/src/ADSB/ADSBVehicleManager.h b/src/ADSB/ADSBVehicleManager.h index 4f6b9118ad0..14eb5cddca6 100644 --- a/src/ADSB/ADSBVehicleManager.h +++ b/src/ADSB/ADSBVehicleManager.h @@ -13,6 +13,7 @@ #include #include "ADSB.h" +#include "MAVLinkLib.h" Q_DECLARE_LOGGING_CATEGORY(ADSBVehicleManagerLog) @@ -30,13 +31,15 @@ class ADSBVehicleManager : public QObject Q_PROPERTY(const QmlObjectListModel *adsbVehicles READ adsbVehicles CONSTANT) public: - ADSBVehicleManager(ADSBVehicleManagerSettings *settings, QObject *parent = nullptr); + explicit ADSBVehicleManager(ADSBVehicleManagerSettings *settings, QObject *parent = nullptr); ~ADSBVehicleManager(); static ADSBVehicleManager *instance(); const QmlObjectListModel *adsbVehicles() const { return _adsbVehicles; } + void mavlinkMessageReceived(const mavlink_message_t &message); + public slots: void adsbVehicleUpdate(const ADSB::VehicleInfo_t &vehicleInfo); @@ -47,6 +50,7 @@ private slots: private: void _start(const QString &hostAddress, quint16 port); void _stop(); + void _handleADSBVehicle(const mavlink_message_t &message); ADSBVehicleManagerSettings *_adsbSettings = nullptr; QTimer *_adsbVehicleCleanupTimer = nullptr; @@ -54,4 +58,6 @@ private slots: QMap _adsbICAOMap; ADSBTCPLink *_adsbTcpLink = nullptr; + + static constexpr uint8_t kMaxTimeSinceLastSeen = 15; }; diff --git a/src/ADSB/CMakeLists.txt b/src/ADSB/CMakeLists.txt index e3c740a2f0e..da03f4ec52a 100644 --- a/src/ADSB/CMakeLists.txt +++ b/src/ADSB/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(ADSB Qt6::Core Qt6::Positioning Qt6::QmlIntegration + MAVLink QmlControls ) diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index aad58569932..1cd2cf56b2d 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -579,7 +579,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes _handleCameraImageCaptured(message); break; case MAVLINK_MSG_ID_ADSB_VEHICLE: - _handleADSBVehicle(message); + ADSBVehicleManager::instance()->mavlinkMessageReceived(message); break; case MAVLINK_MSG_ID_HIGH_LATENCY: _handleHighLatency(message); @@ -3287,40 +3287,6 @@ bool Vehicle::autoDisarm() return false; } -void Vehicle::_handleADSBVehicle(const mavlink_message_t &message) -{ - mavlink_adsb_vehicle_t adsbVehicleMsg; - mavlink_msg_adsb_vehicle_decode(&message, &adsbVehicleMsg); - - static constexpr int maxTimeSinceLastSeen = 15; - - if ((adsbVehicleMsg.flags & ADSB_FLAGS_VALID_COORDS) && (adsbVehicleMsg.tslc <= maxTimeSinceLastSeen)) { - ADSB::VehicleInfo_t vehicleInfo; - - vehicleInfo.availableFlags = ADSB::AvailableInfoTypes::fromInt(0); - vehicleInfo.icaoAddress = adsbVehicleMsg.ICAO_address; - - vehicleInfo.location.setLatitude(adsbVehicleMsg.lat / 1e7); - vehicleInfo.location.setLongitude(adsbVehicleMsg.lon / 1e7); - vehicleInfo.availableFlags |= ADSB::LocationAvailable; - - vehicleInfo.callsign = adsbVehicleMsg.callsign; - vehicleInfo.availableFlags |= ADSB::CallsignAvailable; - - if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_ALTITUDE) { - vehicleInfo.altitude = adsbVehicleMsg.altitude / 1e3; - vehicleInfo.availableFlags |= ADSB::AltitudeAvailable; - } - - if (adsbVehicleMsg.flags & ADSB_FLAGS_VALID_HEADING) { - vehicleInfo.heading = adsbVehicleMsg.heading / 1e2; - vehicleInfo.availableFlags |= ADSB::HeadingAvailable; - } - - (void) QMetaObject::invokeMethod(ADSBVehicleManager::instance(), "adsbVehicleUpdate", Qt::AutoConnection, vehicleInfo); - } -} - void Vehicle::_updateDistanceHeadingToHome() { if (coordinate().isValid() && homePosition().isValid()) { diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index daf6ed731e8..c5ccbe1a640 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -960,7 +960,6 @@ private slots: void _handleCameraFeedback (const mavlink_message_t& message); #endif void _handleCameraImageCaptured (const mavlink_message_t& message); - void _handleADSBVehicle (const mavlink_message_t& message); void _missionManagerError (int errorCode, const QString& errorMsg); void _geoFenceManagerError (int errorCode, const QString& errorMsg); void _rallyPointManagerError (int errorCode, const QString& errorMsg); diff --git a/test/ADSB/ADSBTest.cc b/test/ADSB/ADSBTest.cc index 8475face1a1..94083e0a3ab 100644 --- a/test/ADSB/ADSBTest.cc +++ b/test/ADSB/ADSBTest.cc @@ -13,8 +13,7 @@ void ADSBTest::_adsbVehicleTest() ADSB::VehicleInfo_t vehicleInfo; vehicleInfo.icaoAddress = 1; vehicleInfo.callsign = QStringLiteral("1"); - vehicleInfo.location = QGeoCoordinate(1., 1.); - vehicleInfo.altitude = 1.; + vehicleInfo.location = QGeoCoordinate(1., 1., 1.); vehicleInfo.heading = 1.; vehicleInfo.alert = false; vehicleInfo.availableFlags = ADSB::CallsignAvailable; @@ -79,8 +78,7 @@ void ADSBTest::_adsbVehicleManagerTest() ADSB::VehicleInfo_t vehicleInfo; vehicleInfo.icaoAddress = 1; vehicleInfo.callsign = QStringLiteral("1"); - vehicleInfo.location = QGeoCoordinate(1., 1.); - vehicleInfo.altitude = 1.; + vehicleInfo.location = QGeoCoordinate(1., 1., 1.); vehicleInfo.heading = 1.; vehicleInfo.alert = false; vehicleInfo.availableFlags = ADSB::LocationAvailable;