From 599421b98d1c5a9ae157220d5ad046eb28c1006f Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Sat, 4 Mar 2017 17:13:16 -0800 Subject: [PATCH] Fix incorrect loiter point rotate on landing heading fact change --- src/MissionManager/FixedWingLandingComplexItem.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MissionManager/FixedWingLandingComplexItem.cc b/src/MissionManager/FixedWingLandingComplexItem.cc index ffccbcf03..0ef549d8a 100644 --- a/src/MissionManager/FixedWingLandingComplexItem.cc +++ b/src/MissionManager/FixedWingLandingComplexItem.cc @@ -227,10 +227,15 @@ void FixedWingLandingComplexItem::_recalcLoiterCoordFromFacts(void) convertGeoToNed(_landingCoordinate, tangentOrigin, &north, &east, &down); + // Heading is from loiter to land, so we need to rotate angle 180 degrees and go the opposite direction + double heading = _landingHeadingFact.rawValue().toDouble(); + heading += 180.0; + heading *= -1.0; + QPointF originPoint(east, north); north += _loiterToLandDistanceFact.rawValue().toDouble(); QPointF loiterPoint(east, north); - QPointF rotatedLoiterPoint = _rotatePoint(loiterPoint, originPoint, _landingHeadingFact.rawValue().toDouble()); + QPointF rotatedLoiterPoint = _rotatePoint(loiterPoint, originPoint, heading); convertNedToGeo(rotatedLoiterPoint.y(), rotatedLoiterPoint.x(), down, tangentOrigin, &_loiterCoordinate); -- 2.22.0