Grade control

I prefer the Lefebure ntrip Client for sending correction from my android phone to the bluethoot module on the F9P. Is light and have no extra useless stuff.

http://lefebure.com/software/android-ntripclient/

1 Like

Yes, I just changed lat and lon and ran the import. But also wondered if the actual gps would get the view in the window.

I worked on an average elevation of the closest 4 points. I looped the points found the closest point, then, looped again excluding the closest point to find the next closest, then excluding the first two, ect. Then took the average of the four. Fairly smooth. I plan on trying a weighted average based on each distance. If I get it working, Iā€™ll post it here. Currently Iā€™m using it to "drive on the field " elevated at the proper grade. But could be also used when grading between points of different elevations.

1 Like

To find multiples closest points you can make it in one loop, probably less expensive (not tested):

if (ptCnt > 0)
            {
                minDist = 1000000; //original is 1000000
		DistNearPt2 = 1000000;
		DistNearPt3 = 1000000;

                int ptCount = ct.ptList.Count - 1;

                //find the closest point to current fix
                for (int t = 0; t < ptCount; t++)
                {
                    double dist = ((pn.easting - ct.ptList[t].easting) * (pn.easting - ct.ptList[t].easting))
                                    + ((pn.northing - ct.ptList[t].northing) * (pn.northing - ct.ptList[t].northing));

           if (dist < DistNearPt3) 
			{
			if (dist < DistNearPt2)
				{
				if (dist < minDist)
					{ 
					DistNearPt3 = DistNearPt2;
			 		closePoint3 = closePoint2;
					DistNearPt2 = minDist;
			 		closePoint2 = closestPoint; 
					minDist = dist;
			 		closestPoint = t; 
					}
				else 
					{ 
					DistNearPt3 = DistNearPt2;
			 		closePoint3 = closePoint2;
					DistNearPt2 = dist;
			 		closePoint2 = t; 
					}
				}
			else 
				{ 
				DistNearPt3 = dist;
			 	closePoint3 = t; 
				}
			}
           }

Your side view window with the look ahead is very nice. Does it show all point ahead and behind? Or just ahead? Can we set a fixed view distance ahead and behind? It would be nice to use the lastpast value to show the actual blade work while driving!

1 Like

Code does look simpler. I tried the reverse order and realized that if the points were out of ascending order it may or may not work. Even with the loops, I did your error and like to have never found the problem. (MinDist had to be reset each time.)

It steps from where you are in the current heading a given number of steps. Each step is distance multiplied by the for loop counter. So I just started at a negative counter. That gave me some points behind me to see what was happening. The blade height is shown at the bottom of the yellow bar. I did not change that. But I did change the current elevation setting to be the blade movement. So if it is set to zero, it rides the ground, negative it cuts, positive it is lifted. My thinking is that once a survey point is cut, that elevation no longer exist. Then, if cutting and if over a survey point, set the current elevation to the blade height.

1 Like

Here is the weighted average working. The yellow ā€œsticksā€ are just indicators for what four points are being used for the weighted average. As you can see the field rises in the right of the picture. The four points it is following are green. This simply means that it is below the average elevation. In this picture the current elevation is 106.335 while the average (just under the autosteer button) is 108.2.) The yellow bar in the bottom view is showing your position along the look ahead path. The black dot at the base is riding right on grade. The red bar to the right says the blade is too low to stay with the fill line. That is correct, blade elevation in the simulator is set to zero (on the ground). This area is requiring fill.

image

Turns out there are as many ways to get the weighted average of contours as you want to look for. This is just a simple inverted average. The code below, just find your four distances and their elevations. Iā€™d end up putting all of this in a routine. Send it the list, it returns the weighted average elevation.

The code for the weighted average:

 if (sim.isSimOn) 
                {
                    
                    double currentAltitude = (ct.ptList[cltPoint].altitude);
                    double toole = Properties.Vehicle.Default.setVehicle_toolWidth;
                    if (minidistA <= toole / 2 | minidistB <= toole / 2 | minidistC <= toole / 2 | minidistD <= toole / 2)
                    {
                        //if the blade is over the point just set the altitude to the point,
                        //gets rid of the division by zero error.
                        currentAltitude = (ct.ptList[cltPoint].altitude);
                    }
                    else
                    {
                        //Weighted Average
                        double sumofmindist = 1 / minidistA + 1 / minidistB + 1 / minidistC + 1 / minidistD;
                        currentAltitude = (((ct.ptList[cltPoint].altitude/minidistA)) + ((ct.ptList[cltPointB].altitude/minidistB)) +
                            ((ct.ptList[cltPointC].altitude/minidistC)) + ((ct.ptList[cltPointD].altitude/minidistD))) / sumofmindist;
                    }
                    
                    
                    sim.altitude = currentAltitude + Properties.Vehicle.Default.setVehicle_antennaHeight + ct.cutValue;
                    
                }

Cuts with the red down line:

image

Fill with the green up line:

image

One other step. It now cuts if the blade is down. If you run over a survey marker, it makes that the new survey elevation. In this picture, Iā€™ve effectively cut a ditch right down the middle of the field. You can see the effects in the profile at the bottom of the picture. Cutting well below the fill line. If you drive over it and the blade is down, it will cut. Probably should be on a switch. Now to set the auto blade!!!

image

Worked on setting the blade. Did not change much, and right now it fills and cuts assuming the blade is full. But did learn something that may benefit someone else. If you are cutting a single pass, the closest points on either side is not nearly as important as what is before you and behind you. The weighted averages will over correct your current point. It did do a really good job when the sides are close to the current point. But when you get to cutting deep or filling high based on the points on either side. it really begins to over correct. But notice how flat the grade is in the profile view in the picture at the bottom. Within the short forward and the short rear it is fairly level.

image

2 Likes

For the record, yes, the accuracy of altitude had to be set to high precision to get more digits on the NMEA messages. I had been playing with gpsd on linux, and gpsd switches the f9p into ubx mode where the altitude is high precision from the beginning.

Now, I wonder if there is an app out there which can use an rtk-f9p on a mobile pole as a laser level. Iā€™d like to sample some kind of reference point and then walk about and check the level at arbitrary points. It is probably not as accurate as a real laser level, but the one I have has such a narrow band and the range is limited. Iā€™d actually just like to walk about in the field (which can be too large for the laser) and do some quick measurements while thinking and planning.

1 Like

I did that with opengrade. With the antenna on a steel dish and my tablet.
For the height precision, it pretty good, the sand I levelled with opengrade in automatic mode with the rtk base 5km away was all within +/- 10 mm when I measured with a laser.
But near the buildings (against the wall) it was several centimetres off even if it was showing an ā€œrtk fixā€

2 Likes

Wow, you guys have been up to something here :star_struck: Iā€™ve been meanwhile busy soldering cables for the yield meter antenna (my fingers are 5x the required size to assemble Deutsch IMC connectorsā€¦) and grain dryer remote monitoring. Learned all too much about setting reverse proxies to get a computer safely to the internetā€¦

@Pat for the survey format, .ags is pretty straightforward and all the markers etc work one to one with the output as well. Itā€™s just to decide whether to go just for lon/lat in the file and do the easting/northing conversion internally for opengrade. Or the second option that just use the contour.txt format as THE format and have several import/export options.

I think we get rid of the conversion issues using ags since then itā€™s open grade doing the conversion both ways.

@KentStuff I added you as a contributor to the repo weā€™ve been working on with opengrade in github.

1 Like

Iā€™m now getting the grade average from the four closest points on the look ahead/behind line. If driving with a line of points, it is just taking the weighted average from where you have been and where you are going. It does not overshoot due to the sides. Did a nice job cutting the field survey points to the cut elevation. Ran three rows of point in the transvers direction of the order of the points. Each pass cut or filled to a max blade range. Multiple passes cuts less and less until it is just a centimeter either side of the cut/fill line. I did not take a screen shot of it before I closed it. Mine reads the agd file and writes to the txt file. That way I do not make any modifications to the original data. For simulation this is fine. Real world, if you cut that field the survey points are the new txt file. This would need to be written back to the agd file, simple enough, but just havenā€™t done it. The problem with the look ahead/behind became what point is that in the main file. So I wrote a routine to fine that x,y in what list. I think it needs a close enough to the same because equals never equals. Since the look ahead/behind list is built by copying the points, it does a really good job, but I could see where it could be a problem. Here is that routine if anyone want to give it a try or make a close enough modification to it.

public int GetContourPt(double _easting, double _northing, List<CContourPt> _ptList)
        {
            int alfa = 0;
            int ptCount = _ptList.Count - 1;
            for (int t = 0; t < ptCount; t++)
            {
                
                if (_ptList[t].easting == _easting&& _ptList[t].northing==_northing)
                {
                        alfa = t;
                        return alfa;
                }
                
            }
            return alfa;
                
        }

I was able to get a copy of the contour.txt after the cut. Here it is. Not sure how yours will display, but maybe you can see the three rows that were brought to grade.

Contour - Copy.txt (21.6 KB)

Managed to get this open and screen shot of it. You can see how flat it is running in the bottom profile view. And yes it is showing dead on with the blade in the right up or down bar. Pretty cool.

image

3 Likes

Are you going to post your code.

1 Like

Code is fairly messy just trying to add certain thing to see if it works. Iā€™ll get it posted, but right now working on ā€œsurveyingā€ in AOG and then import the file to Open grade. In the picture below, I drove the boundary while recording the survey points at pivot point, then set up an ABLine and let AOG drive with the u-turns and all. It is dropping a survey point at every tool width of distance from the last point. This all saves upon exit and opened in Opengrade. Changed the file name to survey.txt and it loads right up. I did set the simulator elevation in AOG to 108 about average of the field we have been playing with. It brought the whole field in white, which is average.

image

Bumped out the timing on the boundary to match the tool width as well.
New field same concept. The AOG file is a little behind the Opengrade while I was screen capturing.
image
image

2 Likes

Iā€™m just wondering why not sample at a higher rate when performing the survey. Then do some low pass filtering to reach the sample grid that Opengrade prefers.

Iā€™ve collected data at the full GNSS receiver rate (just to avoid changing the normal rate settings) and it improves accuracy even if the sampling rate is only increased along the driven path.

In any case, very impressive results from all of you working with Opengrade!

1 Like

Absolutely. Opengradeā€™s sampling is fairly close. I was just wondering if you could. My first success was at the standard section rate. But I wanted to see the individual points. AOG has most of this built in. It runs in the background and just does not store the information. There is an elevation file that is created at the close of the field. Slight mods in the code and this is the file that contour in open grade would read. This is the reader that needs to be added or changed in OpenGrade.

           fileAndDirectory = fieldsDirectory + currentFieldDirectory + "\\Elevation.txt";
            if (!File.Exists(fileAndDirectory))
            {
                var form = new FormTimedMessage(4000, "Missing Elevation File", "But Field is Loaded");
                form.Show();
                //return;
            }

            /*
                May-14-17  -->  7:42:47 PM
                Points in Patch followed by easting, heading, northing, altitude
                $ContourDir
                cdert_May14
                $Offsets
                533631,5927279,12
                19
                2.866,2.575,-4.07,0             
             */
            else
            {
                int verts = File.ReadLines(fileAndDirectory).Count() - 9;
                using (StreamReader reader = new StreamReader(fileAndDirectory))
                {
                    try
                    {
                        //read the lines and skip them
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();
                        line = reader.ReadLine();


                        while (!reader.EndOfStream)
                        {
                            //read how many vertices in the following patch
                            
                            //CContourPt vecFix = new vec4(0, 0, 0, 0);

                            for (int v = 0; v < verts; v++)
                            {
                                line = reader.ReadLine();
                                string[] words = line.Split(',');

                                CContourPt point = new CContourPt(
                                    double.Parse(words[0], CultureInfo.InvariantCulture),
                                    0,
                                    double.Parse(words[1], CultureInfo.InvariantCulture),
                                    double.Parse(words[2], CultureInfo.InvariantCulture),
                                    double.Parse(words[3], CultureInfo.InvariantCulture),
                                    double.Parse(words[4], CultureInfo.InvariantCulture),
                                    -1,
                                    -1,
                                    -1);

                                ct.ptList.Add(point);
                            }
                        }

                    }
                    catch (Exception e)
                    {
                        WriteErrorLog("Loading Contour file" + e.ToString());

                        var form = new FormTimedMessage(4000, "Contour File is Corrupt", "But Field is Loaded");
                        form.Show();

                    }


                    //calc mins maxes
                    CalculateMinMaxZoom();
                    CalculateTotalCutFillLabels();
                }
            }

AOG
FormGPS about line 64 isLogElevation needs to be set to true.
and about line 2000, in the filesave items. Add

FileSaveElevation();
2 Likes

I have AOG displaying the survey points. I drove a boundary and then started an ABLine with the auto u-turn. I did not complete the whole field as I ran into my U-turn. But, closed the field and saved the points. I then copied this survey.txt into the Opengrade field and open it. Both show the same thing except Iā€™m driving the opposite direction. So that part works. Now, I added a text writer that should write the .ags file. Since I do not have OptiSurface, I was wondering if someone could open this file and see what it looks like. @Pat or @nut or someone might could post it back here and see if it actually works.

Here is the file. Just drop the .txt at the end of it.

Survey.ags.txt (7.6 KB)

Here is the picture of the fields in both AOG and Opengrade:

AOG_to_OpenGrade

2 Likes

Hi
I donā€™t have optisuface yet but will buy in the next days, my field will be ready to survey in about two weeks.

I made something similar! I make the survey directly in opengrade so I donā€™t have an inclination correction, so itā€™s only good for flat fields.(good for me for this year)
My .ags file is similar but i make a benchmark point at the beginning and i output 9 numbers after the lat/lon instead of 7. I think the 7th number make approximately centimetre accuracy so it good enough for the survey.
Mine make a point at each 3 meters.
Iā€™m planning to run opengrade while balling and I hope to have a nice file at the end!

I can now open the agd file if I manually delete all the lines that are not 3GRD and i think it make the easting/northing correctly.
So my opengrade is maybe ready to grade with an optisuface design file!
At least to test , lot of graphical design still need to be done. I would like to eventually have the @KentStuff side elevation view, something to implement next winter.

the code is here if someone want look at it, itā€™s still a mess, itā€™s on development

3 Likes

I donā€™t know how other field editing software works, but my thinking is to slice the field at certain spacings, edit that slice and then move to the next. AOG has the pick ABLINE form that would be nice for that. Currently working on editing the profile view with the same procedure that was done originally, but using the lookahead list. Problem is that this list is always changing based on heading.

Concerning the manual delete all non 3GRD points, I actually made AOG write 2PER if it was made with the boundary on. I added a comment to each point in the pt list and by default set them to 3GRD.

Iā€™ll post the .ags writer that I added to AOG. Simple enough to do the same thing for Opengrade. I set the space based on tool width because it is easy to change and it could match the ABLine in each direction if wanted.

3 Likes

@KentStuff tested the ags in optisurface, loads fine and the boundary works as well!

image

5 Likes

I modified my code there was an error in my lat/lon converter.
it is in CContour.cs line 796

 public void designList2ptList()

@nut do you have to use credit to open and edit the file or only when exporting a design file? Is there a minimum credit for small fields?

1 Like

No, the credits are only needed when you export the design. The minimum it uses is around 6 hectares if I recall correctly. And you need the credits only once for a given survey, so you can modify and export as many times as you like.

2 Likes

I believe I have uploaded the AOGSurvey to the github. Did I mention, ā€œIā€™ll never understand github.ā€

Anyway, the Survey button is at the bottom left. Click it when you want to survey. If building a boundary start at the beginning. It takes just a second to start but it seams to work. When closing the field, it writes three different files. Elevation.txt (the default from the original, does not account for the antenna height), Survey.txt (Compatible with OpenGrade), and Survey.ags (Should be able to open with Optisurface.) Note: elevation logs everything. The two Survey files only log when survey button is on. Step distance is the tool width.

image

https://github.com/KentStuff/AOGSurvey

Here is the .ags writer in AOG. The SPt. must be changed to ct. in opengrade.

public void FileSaveSurvey_ags()
        {
            //get the directory and make sure it exists, create if not
            string dirField = fieldsDirectory + currentFieldDirectory + "\\";

            string directoryName = Path.GetDirectoryName(dirField);
            if ((directoryName.Length > 0) && (!Directory.Exists(directoryName)))
            { Directory.CreateDirectory(directoryName); }

            string myFileName = "Survey.ags";

            //write out the file
            using (StreamWriter writer = new StreamWriter(dirField + myFileName))
            {
                                
                writer.WriteLine("Latitude, Longitude, Elevation, Comment");

                //make sure there is something to save
                if (SPt.ptList.Count() > 0)
                {
                    int count2 = SPt.ptList.Count;

                    
                    for (int i = 0; i < count2; i++)
                    {
                        writer.WriteLine(Math.Round(SPt.ptList[i].latitude, 7).ToString(CultureInfo.InvariantCulture) + ", " +
                            Math.Round(SPt.ptList[i].longitude, 7).ToString(CultureInfo.InvariantCulture) + ", " +
                            Math.Round(SPt.ptList[i].altitude, 3).ToString(CultureInfo.InvariantCulture) + ", " +
                            SPt.ptList[i].comment);
                    }
                }
            }
            //set saving flag off
            isSavingFile = false;
        }
4 Likes