diff --git a/src/comm/QGCFlightGearLink.cc b/src/comm/QGCFlightGearLink.cc index 9e9391735e19cc51336559fa62c2cc881a9d6919..d1d0117664d6b1a46e72094f45b402f484dd01d2 100644 --- a/src/comm/QGCFlightGearLink.cc +++ b/src/comm/QGCFlightGearLink.cc @@ -47,7 +47,7 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments flightGearVersion(0), startupArguments(startupArguments), _sensorHilEnabled(true), - barometerOffsetkPa(0.0) + barometerOffsetkPa(0.0f) { this->host = host; this->port = port+mav->getUASID(); diff --git a/src/comm/QGCHilLink.h b/src/comm/QGCHilLink.h index bd96e37fc029a8687fc553b3b1b37a569b1f32f7..788165097f6c4992a35445559fc5ee979a462791 100644 --- a/src/comm/QGCHilLink.h +++ b/src/comm/QGCHilLink.h @@ -72,8 +72,6 @@ public slots: protected: virtual void setName(QString name) = 0; - static const unsigned int barometerOffsetkPa = 2; - signals: /** * @brief This signal is emitted instantly when the link is connected diff --git a/src/comm/QGCXPlaneLink.cc b/src/comm/QGCXPlaneLink.cc index 47da6d961817e7c3ed35660a0506e7648f9d3c47..ef9dfd0c3f9c914e04daa163d09b1a5d080269f4 100644 --- a/src/comm/QGCXPlaneLink.cc +++ b/src/comm/QGCXPlaneLink.cc @@ -48,10 +48,12 @@ QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress socket(NULL), process(NULL), terraSync(NULL), + barometerOffsetkPa(15.0f), airframeID(QGCXPlaneLink::AIRFRAME_UNKNOWN), xPlaneConnected(false), xPlaneVersion(0), simUpdateLast(QGC::groundTimeMilliseconds()), + simUpdateFirst(0), simUpdateLastText(QGC::groundTimeMilliseconds()), simUpdateHz(0), _sensorHilEnabled(true) @@ -452,6 +454,10 @@ void QGCXPlaneLink::readBytes() { xPlaneConnected = true; + if (oldConnectionState != xPlaneConnected) { + simUpdateFirst = QGC::groundTimeMilliseconds(); + } + for (unsigned i = 0; i < nsegs; i++) { // Get index @@ -642,6 +648,11 @@ void QGCXPlaneLink::readBytes() qDebug() << "UNKNOWN PACKET:" << data; } + // Wait for 0.5s before actually using the data, so that all fields are filled + if (QGC::groundTimeMilliseconds() - simUpdateFirst < 500) { + return; + } + // Send updated state if (emitUpdate && (QGC::groundTimeMilliseconds() - simUpdateLast) > 3) { diff --git a/src/comm/QGCXPlaneLink.h b/src/comm/QGCXPlaneLink.h index 696d3c2b188b1700ac7986b7d6ba7c2a6b28b4ac..f80110f968802d621d74d88b47fbf894ee60a4e8 100644 --- a/src/comm/QGCXPlaneLink.h +++ b/src/comm/QGCXPlaneLink.h @@ -197,6 +197,7 @@ protected: float true_airspeed; float groundspeed; float xmag, ymag, zmag, abs_pressure, diff_pressure, pressure_alt, temperature; + float barometerOffsetkPa; float man_roll, man_pitch, man_yaw; QString airframeName; @@ -204,6 +205,7 @@ protected: bool xPlaneConnected; unsigned int xPlaneVersion; quint64 simUpdateLast; + quint64 simUpdateFirst; quint64 simUpdateLastText; float simUpdateHz; bool _sensorHilEnabled;