Skip to content

Commit

Permalink
Merge pull request #269 from farmerbriantee/Jaap
Browse files Browse the repository at this point in the history
Jaap
  • Loading branch information
farmerbriantee authored Jul 7, 2022
2 parents b4bf4cb + ea909b4 commit 6842b61
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 58 deletions.
2 changes: 1 addition & 1 deletion SourceCode/AgIO/Source/Forms/FormLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private void FormLoop_FormClosing(object sender, FormClosingEventArgs e)
{
Settings.Default.setPort_wasGPSConnected = wasGPSConnectedLastRun;
Settings.Default.setPort_wasIMUConnected = wasIMUConnectedLastRun;
Settings.Default.setPort_wasSteerModuleConnected = wasRtcmConnectedLastRun;
Settings.Default.setPort_wasSteerModuleConnected = wasSteerModuleConnectedLastRun;
Settings.Default.setPort_wasMachineModuleConnected = wasMachineModuleConnectedLastRun;
Settings.Default.setPort_wasRtcmConnected = wasRtcmConnectedLastRun;

Expand Down
56 changes: 25 additions & 31 deletions SourceCode/GPS/Classes/CContour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CContour

public double distanceFromCurrentLinePivot;

private int A, B, C, stripNum, lastLockPt = int.MaxValue, backSpacing = 30;
private int A, B, C, stripNum, lastLockPt = int.MaxValue;

public double abFixHeadingDelta, abHeading;

Expand Down Expand Up @@ -285,6 +285,7 @@ public void SetLockToLine()
//}
#endregion
private double lastSecond;
int pt = 0;
public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)
{
if (ctList.Count == 0)
Expand All @@ -293,7 +294,7 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)
}
else
{
if ((mf.secondsSinceStart - lastSecond) < 1.5) return;
if ((mf.secondsSinceStart - lastSecond) < 2) return;
}

lastSecond = mf.secondsSinceStart;
Expand All @@ -303,7 +304,6 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)

double toolContourDistance = (mf.tool.toolWidth * 3 + Math.Abs(mf.tool.toolOffset));

int pt = 0;

//check if no strips yet, return
int stripCount = stripList.Count;
Expand All @@ -316,8 +316,8 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)
double cosH = Math.Cos(pivot.heading) * 0.2;


double sin2HL = Math.Sin(pivot.heading + glm.PIBy2) * 1;
double cos2HL = Math.Cos(pivot.heading + glm.PIBy2) * 1;
double sin2HL = Math.Sin(pivot.heading + glm.PIBy2);
double cos2HL = Math.Cos(pivot.heading + glm.PIBy2);

boxA.easting = pivot.easting - sin2HL+ sinH;
boxA.northing = pivot.northing - cos2HL+cosH;
Expand All @@ -335,7 +335,7 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)
ptCount = stripList[s].Count;
if (ptCount == 0) continue;
double dist;
for (p = 0; p < ptCount; p += 6)
for (p = 0; p < ptCount; p += 3)
{
//if (s == stripCount - 1)
{
Expand Down Expand Up @@ -374,23 +374,23 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)
//no points in the box, exit
ptCount = stripList[stripNum].Count;

start = lastLockPt - 20; if (start < 0) start = 0;
stop = lastLockPt + 20; if (stop > ptCount) stop = ptCount;

if (ptCount < 2 )
{
ctList.Clear();
isLocked = false;
return;
}

start = lastLockPt - 20; if (start < 0) start = 0;
stop = lastLockPt + 20; if (stop > ptCount) stop = ptCount;

//determine closest point
minDistance = double.MaxValue;

//if being built, start high, keep from guiding latest points made
//int currentStripBox = 0;
//if (stripNum == stripCount) currentStripBox = 10;
for (int i = start; i < stop; i++)
for (int i = start; i < stop; i+=3)
{
double dist = ((pivot.easting - stripList[stripNum][i].easting) * (pivot.easting - stripList[stripNum][i].easting))
+ ((pivot.northing - stripList[stripNum][i].northing) * (pivot.northing - stripList[stripNum][i].northing));
Expand Down Expand Up @@ -449,34 +449,26 @@ public void BuildContourGuidanceLine(vec3 pivot, vec3 steer)

double howManyPathsAway = 0;

if (Math.Abs(distanceFromRefLine) > mf.tool.halfToolWidth)
if (Math.Abs(distanceFromRefLine) > mf.tool.halfToolWidth
|| Math.Abs(mf.tool.toolOffset) > mf.tool.halfToolWidth)
{
//beside what is done
if (RefDist < 0) howManyPathsAway = -1;
else howManyPathsAway = 1;
}
else
{
if (Math.Abs(mf.tool.toolOffset) > mf.tool.halfToolWidth)
{
if (RefDist < 0) howManyPathsAway = -1;
else howManyPathsAway = 1;
}

else
{
//driving on what is done
howManyPathsAway = 0;
}
//driving on what is done
howManyPathsAway = 0;
}

if (howManyPathsAway >= -1 && howManyPathsAway <= 1)
{
ctList.Clear();

//don't guide behind yourself
if (stripNum == stripList.Count-1 && howManyPathsAway == 0)
return;
//if (stripNum == stripList.Count-1 && howManyPathsAway == 0)
//return;

//make the new guidance line list called guideList
ptCount = stripList[stripNum].Count;
Expand Down Expand Up @@ -844,7 +836,9 @@ public void StartContourLine(vec3 pivot)
//Add current position to stripList
public void AddPoint(vec3 pivot)
{
ptList.Add(new vec3(pivot.easting, pivot.northing, pivot.heading));
ptList.Add(new vec3(pivot.easting + Math.Cos(pivot.heading) * mf.tool.toolOffset,
pivot.northing - Math.Sin(pivot.heading) * mf.tool.toolOffset,
pivot.heading));
}

//End the strip
Expand Down Expand Up @@ -975,7 +969,7 @@ public void DrawContourLine()
//Draw the captured ref strip, red if locked
if (isLocked)
{
GL.Color3(0.983f, 0.2f, 0.20f);
GL.Color3(0.983f, 0.92f, 0.420f);
GL.LineWidth(4);
}
else
Expand Down Expand Up @@ -1034,11 +1028,11 @@ public void DrawContourLine()
// for (int i = 0; i < ptCount; i++) GL.Vertex3(conList[i].x, conList[i].z, 0);
// GL.End();

// GL.Color3(0.35f, 0.30f, 0.90f);
// GL.PointSize(6.0f);
// GL.Begin(PrimitiveType.Points);
// GL.Vertex3(conList[closestRefPoint].x, conList[closestRefPoint].z, 0);
// GL.End();
GL.Color3(0.35f, 0.30f, 0.90f);
GL.PointSize(6.0f);
GL.Begin(PrimitiveType.Points);
GL.Vertex3(stripList[stripNum][pt].easting, stripList[stripNum][pt].northing, 0);
GL.End();
//}

if (mf.isPureDisplayOn && distanceFromCurrentLinePivot != 32000 && !mf.isStanleyUsed)
Expand Down
52 changes: 26 additions & 26 deletions SourceCode/GPS/Forms/Position.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6842b61

Please sign in to comment.