diff --git a/src/Vehicle/TrajectoryPoints.cc b/src/Vehicle/TrajectoryPoints.cc index aa3e719c67941875e79a617dde5f3cdea588d126..4dd7f47a0c805923f262c7f985ea3b017041c94c 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->updateFlightDistance(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..544de646959a1345cf0997f9357f40f743e2b746 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::updateFlightDistance(double distance) +{ + _flightDistanceFact.setRawValue(_flightDistanceFact.rawValue().toDouble() + distance); +} + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 10595d92534e9b1f8b7454d2d0387cc0efe25b39..20adf3cb761b8c72b595d35eab3efbf94c18581e 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -805,6 +805,8 @@ public: JoystickModeMax } JoystickMode_t; + void updateFlightDistance(double distance); + int joystickMode(void); void setJoystickMode(int mode);