From e5b88df6d3e95cf803923abf0bd82481562d4a49 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Thu, 23 Jan 2020 14:47:34 -0400 Subject: [PATCH] CP - Update flight distance from within the new TrajectoryPoints handler. This was lost when moving the handling the the trajectory points from within the vehicle. --- src/Vehicle/TrajectoryPoints.cc | 5 ++++- src/Vehicle/Vehicle.cc | 5 +++++ src/Vehicle/Vehicle.h | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Vehicle/TrajectoryPoints.cc b/src/Vehicle/TrajectoryPoints.cc index aa3e719c6..339d7bbe2 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 19db8e2e2..1232e2f74 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 10595d925..6b8769d5f 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); -- 2.22.0