3#include <QtCore/QDateTime>
4#include <QtCore/QPointer>
20bool activeVehicleConnected()
23 Vehicle*
const vehicle = manager ? manager->activeVehicle() :
nullptr;
32 case GPS_FIX_TYPE_2D_FIX:
33 return Quality::Fix2D;
34 case GPS_FIX_TYPE_3D_FIX:
35 case GPS_FIX_TYPE_STATIC:
36 return Quality::Fix3D;
37 case GPS_FIX_TYPE_DGPS:
38 case GPS_FIX_TYPE_PPP:
39 return Quality::Differential;
40 case GPS_FIX_TYPE_RTK_FLOAT:
41 return Quality::RTKFloat;
42 case GPS_FIX_TYPE_RTK_FIXED:
43 return Quality::RTKFixed;
45 return Quality::NoFix;
64 , _scheduler(scheduler)
70 using Observation = std::optional<GPSObservation>;
73 return [source, observe]() -> Observation {
74 if (!source || !activeVehicleConnected()) {
77 return (source->*observe)();
91 QObject::disconnect(_gpsConnection);
92 QObject::disconnect(_messageConnection);
100 [
this, gps](
const QGeoPositionInfo& position,
int fixType) {
101 _gps = GpsReport{.position = position,
103 .horizontalDop = gps->hdop()->rawValue().toDouble(),
104 .receivedAtUs = _scheduler->
nowUs()};
109 if (message.msgid != MAVLINK_MSG_ID_GLOBAL_POSITION_INT) {
112 mavlink_global_position_int_t position;
113 mavlink_msg_global_position_int_decode(&message, &position);
115 if (position.lat == 0 && position.lon == 0) {
123 .receivedAtUs = _scheduler->
nowUs()};
127bool NTRIPVehicleGgaSource::_fresh(quint64 receivedAtUs)
const
134 if (!_gps || !_fresh(_gps->receivedAtUs)) {
137 GPSObservation observation = vehicleObservation(_gps->position, fixQuality(_gps->fixType), _gps->receivedAtUs);
139 if (qIsFinite(_gps->horizontalDop)) {
147 if (!_estimate || !_fresh(_estimate->receivedAtUs)) {
151 return vehicleObservation(QGeoPositionInfo(_estimate->coordinate, QDateTime::currentDateTimeUtc()),
152 GPSObservation::FixQuality::Extrapolated, _estimate->receivedAtUs)
struct __mavlink_message mavlink_message_t
static constexpr std::chrono::milliseconds FRESHNESS_TIMEOUT
Default position age at which health becomes Stale and the position stops being usable.
static MultiVehicleManager * instance()
void activeVehicleChanged(Vehicle *activeVehicle)
void setGgaPositionProvider(NTRIPGgaReporter::PositionSource source, NTRIPGgaReporter::PositionProvider provider)
std::optional< GPSObservation > estimateObservation() const
The fresh observation from the vehicle's GLOBAL_POSITION_INT estimate.
std::optional< GPSObservation > gpsObservation() const
The fresh observation from the vehicle's GPS with a fix.
NTRIPVehicleGgaSource(RuntimeScheduler *scheduler, QObject *parent=nullptr)
scheduler stamps receipt times and must outlive this source.
void setVehicle(Vehicle *vehicle)
Tracks vehicle's reports; reports from before this call are not used.
void attach(NTRIPManager *ntrip)
virtual quint64 nowUs() const =0
void positionReported(const QGeoPositionInfo &position, int fixType)
bool communicationLost() const
VehicleLinkManager * vehicleLinkManager()
VehicleGPSFactGroup * gpsFactGroup()
bool isOfflineEditingVehicle() const
void mavlinkMessageReceived(const mavlink_message_t &message)
GPSPositionReport position(const GPSDecodedPosition &source, const GPSIntegrityReport &diagnostic, uint64_t nowUs)
constexpr double metersFromMillimeters(int32_t value)
constexpr double degreesFromE7(int32_t value)
Degrees of a coordinate in 1e-7 degree units, as u-blox and MAVLink send them.
constexpr bool fresh(uint64_t timestampUs, uint64_t nowUs, std::chrono::microseconds lifetime)
Whether a receipt is younger than lifetime.
GPSFixQuality fixQuality(unsigned quality, GPSFixQuality autonomous)
Autonomous GGA does not distinguish 2D/3D; the caller supplies its independently resolved quality.
Receiver-independent data. Unknown metadata remains absent, never a manufactured zero.
QGeoPositionInfo position
std::optional< GPSObservation > projected(PositionUse use) const
The owner separately enforces freshness and session authorization.
quint64 monotonicTimestampUs
GPSAltitudeDatum altitudeDatum
std::optional< bool > receiverFixValid
std::optional< double > horizontalDop