Skip to content

Commit

Permalink
fix stanley ab
Browse files Browse the repository at this point in the history
  • Loading branch information
farmerbriantee committed Apr 5, 2024
1 parent 7e83332 commit 5780ef3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SourceCode/GPS/Classes/CGuidance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void DoSteerAngleCalc()
/// <param name="isValid"></param>
public void StanleyGuidanceABLine(vec3 curPtA, vec3 curPtB, vec3 pivot, vec3 steer)
{
//get the steer distance from currently active AB segment /////////// steer ////////////
//get the pivot distance from currently active AB segment /////////// Pivot ////////////
double dx = curPtB.easting - curPtA.easting;
double dy = curPtB.northing - curPtA.northing;
if (Math.Abs(dx) < Double.Epsilon && Math.Abs(dy) < Double.Epsilon) return;
Expand All @@ -128,16 +128,16 @@ public void StanleyGuidanceABLine(vec3 curPtA, vec3 curPtB, vec3 pivot, vec3 ste
mf.yt.dxAB = dx; mf.yt.dyAB = dy;

//how far from current AB Line is fix
distanceFromCurrentLinePivot = ((dy * steer.easting) - (dx * steer.northing) + (curPtB.easting
distanceFromCurrentLinePivot = ((dy * pivot.easting) - (dx * pivot.northing) + (curPtB.easting
* curPtA.northing) - (curPtB.northing * curPtA.easting))
/ Math.Sqrt((dy * dy) + (dx * dx));

if (!mf.ABLine.isHeadingSameWay)
distanceFromCurrentLinePivot *= -1.0;

mf.ABLine.distanceFromCurrentLinePivot = distanceFromCurrentLinePivot;
double U = (((steer.easting - curPtA.easting) * dx)
+ ((steer.northing - curPtA.northing) * dy))
double U = (((pivot.easting - curPtA.easting) * dx)
+ ((pivot.northing - curPtA.northing) * dy))
/ ((dx * dx) + (dy * dy));

rEastPivot = curPtA.easting + (U * dx);
Expand Down

0 comments on commit 5780ef3

Please sign in to comment.