Skip to content

Commit

Permalink
Refined Guidance
Browse files Browse the repository at this point in the history
Bnd alarm, no tab side, lineWidth
  • Loading branch information
farmerbriantee committed Oct 22, 2019
1 parent 344c77e commit 891f3e8
Show file tree
Hide file tree
Showing 49 changed files with 2,959 additions and 3,363 deletions.
26 changes: 14 additions & 12 deletions SourceCode/GPS/AgOpenGPS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,6 @@
<Compile Include="Classes\CSequence.cs" />
<Compile Include="Classes\CTurn.cs" />
<Compile Include="Classes\CTurnLines.cs" />
<Compile Include="Forms\FormABPick.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\FormABPick.Designer.cs">
<DependentUpon>FormABPick.cs</DependentUpon>
</Compile>
<Compile Include="Forms\FormNumeric.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -389,9 +383,6 @@
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Forms\FormABPick.resx">
<DependentUpon>FormABPick.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\FormNumeric.resx">
<DependentUpon>FormNumeric.cs</DependentUpon>
</EmbeddedResource>
Expand Down Expand Up @@ -559,6 +550,19 @@
<Content Include="AppIcon.ico" />
<Content Include="AppIcon64.ico" />
<Content Include="aChangeLog.txt" />
<None Include="Resources\Alarm10.wav" />
<None Include="btnImages\ABLineCycle.png" />
<None Include="btnImages\displayMenu.png" />
<None Include="btnImages\fileMenu.png" />
<None Include="btnImages\ABLineTurnOff.png" />
<None Include="btnImages\CurveTurnOff.png" />
<None Include="btnImages\SwitchOff.png" />
<None Include="btnImages\SwitchOn.png" />
<None Include="btnImages\AddNew.png" />
<None Include="btnImages\FileNewAndGo.png" />
<Content Include="Dependencies\Audio\Boundary.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Dependencies\YouTurnShapes\SemiCircle.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -718,9 +722,7 @@
</Content>
<Content Include="ALicense.txt" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
38 changes: 21 additions & 17 deletions SourceCode/GPS/Classes/CABCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CABCurve
public vec2 refPoint1 = new vec2(1, 1), refPoint2 = new vec2(2, 2);

public bool isSameWay;
public double refHeading;
public double refHeading, moveDistance;
public double deltaOfRefAndAveHeadings;

//generated box for finding closest point
Expand Down Expand Up @@ -51,6 +51,10 @@ public class CABCurve
//the list of points of curve to drive on
public List<vec3> curList = new List<vec3>();

public List<CCurveLines> curveArr = new List<CCurveLines>();
public int numCurveLines, numCurveLineSelected;


public CABCurve(FormGPS _f)
{
//constructor
Expand Down Expand Up @@ -116,13 +120,10 @@ public void CalculateTurnHeadings()
refList.CopyTo(arr);
refList.Clear();

//first point needs last, first, second points
vec3 pt3 = arr[0];

//middle points
for (int i = 1; i < cnt; i++)
{
pt3 = arr[i];
vec3 pt3 = arr[i];
pt3.heading = Math.Atan2(arr[i + 1].easting - arr[i - 1].easting, arr[i + 1].northing - arr[i - 1].northing);
if (pt3.heading < 0) pt3.heading += glm.twoPI;
refList.Add(pt3);
Expand Down Expand Up @@ -155,8 +156,6 @@ public void SaveSmoothAsRefList()

public void GetCurrentCurveLine(vec3 pivot, vec3 steer)
{
//determine closest point
double minDistance = 9999999;
int ptCount = refList.Count;
int ptCnt = ptCount - 1;
if (ptCount < 5) return;
Expand Down Expand Up @@ -195,7 +194,8 @@ public void GetCurrentCurveLine(vec3 pivot, vec3 steer)
double dist = ((pivot.easting - refList[closestRefIndex].easting) * (pivot.easting - refList[closestRefIndex].easting))
+ ((pivot.northing - refList[closestRefIndex].northing) * (pivot.northing - refList[closestRefIndex].northing));

minDistance = Math.Sqrt(dist);
//determine closest point
double minDistance = Math.Sqrt(dist);

//grab the heading at the closest point
refHeading = refList[closestRefIndex].heading;
Expand Down Expand Up @@ -244,7 +244,7 @@ public void GetCurrentCurveLine(vec3 pivot, vec3 steer)
curveNumber = howManyPathsAway;
if (distanceFromRefLine < 0) curveNumber = -curveNumber;

double toolOffset = mf.vehicle.toolOffset;
//double toolOffset = mf.vehicle.toolOffset;

//build the current line
curList?.Clear();
Expand Down Expand Up @@ -399,7 +399,6 @@ public void GetCurrentCurveLine(vec3 pivot, vec3 steer)
if (Math.Abs(dx) < Double.Epsilon && Math.Abs(dz) < Double.Epsilon) return;

//abHeading = Math.Atan2(dz, dx);
double abHeading = curList[A].heading;

//how far from current AB Line is fix
distanceFromCurrentLine = ((dz * pivot.easting) - (dx * pivot.northing) + (curList[B].easting
Expand Down Expand Up @@ -649,8 +648,6 @@ public void MoveABCurve(double dist)

public bool PointOnLine(vec3 pt1, vec3 pt2, vec3 pt)
{
bool isValid = false;

var r = new vec2(0, 0);
if (pt1.northing == pt2.northing && pt1.easting == pt2.easting) { pt1.northing -= 0.00001; }

Expand All @@ -670,8 +667,7 @@ public bool PointOnLine(vec3 pt1, vec3 pt2, vec3 pt)

miny = Math.Min(pt1.easting, pt2.easting);
maxy = Math.Max(pt1.easting, pt2.easting);

return isValid = r.northing >= minx && r.northing <= maxx && (r.easting >= miny && r.easting <= maxy);
return _ = r.northing >= minx && r.northing <= maxx && (r.easting >= miny && r.easting <= maxy);
}

//add extensons
Expand Down Expand Up @@ -712,7 +708,7 @@ public void DrawCurve()
int ptCount = refList.Count;
if (refList.Count == 0) return;

GL.LineWidth(2);
GL.LineWidth(mf.ABLine.lineWidth);
GL.Color3(0.30f, 0.692f, 0.60f);
GL.Begin(PrimitiveType.LineStrip);
for (int h = 0; h < ptCount; h++) GL.Vertex3(refList[h].easting, refList[h].northing, 0);
Expand All @@ -733,7 +729,7 @@ public void DrawCurve()
ptCount = smooList.Count;
if (smooList.Count == 0) return;

GL.LineWidth(2);
GL.LineWidth(mf.ABLine.lineWidth);
GL.Color3(0.930f, 0.92f, 0.260f);
GL.Begin(PrimitiveType.Lines);
for (int h = 0; h < ptCount; h++) GL.Vertex3(smooList[h].easting, smooList[h].northing, 0);
Expand Down Expand Up @@ -797,7 +793,7 @@ public void DrawCurve()
if (mf.yt.isYouTurnTriggered)
{
GL.Color3(0.95f, 0.95f, 0.25f);
GL.LineWidth(4);
GL.LineWidth(mf.ABLine.lineWidth);
ptCount = mf.yt.ytList.Count;
if (ptCount > 0)
{
Expand All @@ -815,4 +811,12 @@ public void DrawCurve()
GL.PointSize(1.0f);
}
}

public class CCurveLines
{
public List<vec3> curvePts = new List<vec3>();
public double aveHeading = 3;
public string Name = "aa";
}

}
77 changes: 47 additions & 30 deletions SourceCode/GPS/Classes/CABLine.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using OpenTK.Graphics.OpenGL;
using System;
using System.Collections.Generic;

namespace AgOpenGPS
{
Expand All @@ -17,7 +18,11 @@ public class CABLine
//pure pursuit values
public vec2 goalPointAB = new vec2(0, 0);

public double howManyPathsAway;
//List of all available ABLines
public List<CABLines> lineArr = new List<CABLines>();
public int numABLines, numABLineSelected;

public double howManyPathsAway, moveDistance;
public bool isABLineBeingSet;
public bool isABLineSet, isABLineLoaded;
public bool isABSameAsVehicleHeading = true;
Expand All @@ -41,6 +46,7 @@ public class CABLine
public vec2 refPoint2 = new vec2(0.3, 0.3);
public double snapDistance;
public double steerAngleAB;
public float lineWidth;

//tramlines
//Color tramColor = Color.YellowGreen;
Expand All @@ -52,6 +58,7 @@ public CABLine(FormGPS _f)
//constructor
mf = _f;
isOnTramLine = true;
lineWidth = Properties.Settings.Default.setDisplay_lineWidth;
}

public void DeleteAB()
Expand Down Expand Up @@ -100,7 +107,7 @@ public void DrawABLines()
GL.Disable(EnableCap.LineStipple);

//draw current AB Line
GL.LineWidth(3);
GL.LineWidth(lineWidth);
GL.Begin(PrimitiveType.Lines);
GL.Color3(0.9f, 0.0f, 0.0f);

Expand Down Expand Up @@ -138,7 +145,7 @@ public void DrawABLines()
double toolWidth = mf.vehicle.toolWidth - mf.vehicle.toolOverlap;

GL.Color3(0.0f, 0.90f, 0.50f);
GL.LineWidth(1);
GL.LineWidth(1*Properties.Settings.Default.setDisplay_lineWidth/10);
GL.Begin(PrimitiveType.Lines);

//precalculate sin cos
Expand Down Expand Up @@ -210,32 +217,32 @@ public void DrawABLines()
if (mf.isPureDisplayOn && !mf.isStanleyUsed)
{
//draw the guidance circle
const int numSegments = 100;
{
if (ppRadiusAB < 50 && ppRadiusAB > -50 && mf.isPureDisplayOn)
{
GL.Color3(0.95f, 0.30f, 0.950f);
double theta = glm.twoPI / numSegments;
double c = Math.Cos(theta);//precalculate the sine and cosine
double s = Math.Sin(theta);

double x = ppRadiusAB;//we start at angle = 0
double y = 0;
GL.LineWidth(1);
GL.Begin(PrimitiveType.LineLoop);
for (int ii = 0; ii < numSegments; ii++)
{
//output vertex
GL.Vertex3(x + radiusPointAB.easting, y + radiusPointAB.northing, 0.0);

//apply the rotation matrix
double t = x;
x = (c * x) - (s * y);
y = (s * t) + (c * y);
}
GL.End();
}
}
//const int numSegments = 100;
//{
// if (ppRadiusAB < 50 && ppRadiusAB > -50 && mf.isPureDisplayOn)
// {
// GL.Color3(0.95f, 0.30f, 0.950f);
// double theta = glm.twoPI / numSegments;
// double c = Math.Cos(theta);//precalculate the sine and cosine
// double s = Math.Sin(theta);

// double x = ppRadiusAB;//we start at angle = 0
// double y = 0;
// GL.LineWidth(1);
// GL.Begin(PrimitiveType.LineLoop);
// for (int ii = 0; ii < numSegments; ii++)
// {
// //output vertex
// GL.Vertex3(x + radiusPointAB.easting, y + radiusPointAB.northing, 0.0);

// //apply the rotation matrix
// double t = x;
// x = (c * x) - (s * y);
// y = (s * t) + (c * y);
// }
// GL.End();
// }
//}

//Draw lookahead Point
GL.PointSize(8.0f);
Expand All @@ -252,7 +259,7 @@ public void DrawABLines()
if (mf.yt.isRecordingCustomYouTurn)
{
GL.Color3(0.05f, 0.05f, 0.95f);
GL.PointSize(4.0f);
GL.PointSize(2.0f);
int ptCount = mf.yt.youFileList.Count;
if (ptCount > 1)
{
Expand Down Expand Up @@ -649,4 +656,14 @@ public void SnapABLine()
refPoint2.northing = refABLineP2.northing;
}
}

public class CABLines
{
public vec2 ref1 = new vec2();
public vec2 ref2 = new vec2();
public vec2 origin = new vec2();
public double heading = 0;
public string Name = "aa";
}

}
Loading

0 comments on commit 891f3e8

Please sign in to comment.