diff --git a/src/Vehicle/TrajectoryPoints.cc b/src/Vehicle/TrajectoryPoints.cc index aa3e719c67941875e79a617dde5f3cdea588d126..339d7bbe2ddb7c7c8efdad22028f4e6c2e54ab40 100644 --- a/src/Vehicle/TrajectoryPoints.cc +++ b/src/Vehicle/TrajectoryPoints.cc @@ -23,7 +23,10 @@ void TrajectoryPoints::_vehicleCoordinateChanged(QGeoCoordinate coordinate) // Fewer points means higher performance of map display. if (_lastPoint.isValid()) { - if (_lastPoint.distanceTo(coordinate) > _distanceTolerance) { + double distance = _lastPoint.distanceTo(coordinate); + if (distance > _distanceTolerance) { + //-- Update flight distance + _vehicle->updateFlightDisance(distance); // Vehicle has moved far enough from previous point for an update double newAzimuth = _lastPoint.azimuthTo(coordinate); if (qIsNaN(_lastAzimuth) || qAbs(newAzimuth - _lastAzimuth) > _azimuthTolerance) { diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 19db8e2e2477c16f047d33b05b9acd7ce526ecab..1232e2f741db797757c90f86945c127cd039d29b 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -4244,6 +4244,11 @@ void Vehicle::_handleObstacleDistance(const mavlink_message_t& message) _objectAvoidance->update(&o); } +void Vehicle::updateFlightDisance(double distance) +{ + _flightDistanceFact.setRawValue(_flightDistanceFact.rawValue().toDouble() + distance); +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 10595d92534e9b1f8b7454d2d0387cc0efe25b39..6b8769d5fc0dea5373a9a381fcb364b47ec13b01 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -805,6 +805,8 @@ public: JoystickModeMax } JoystickMode_t; + void updateFlightDisance(double distance); + int joystickMode(void); void setJoystickMode(int mode);