Import Lines from Google Earth

Messing around with V5.4. Wondered again if you could draw something in Google Earth and then have AOG show it on the screen. Yes, it is very possible. In the image below, I created a field then opened the field in Google Earth. I drew the curved line and exported it into AOG simular to the way that boundaries are imported. After success with that, I then added this line to the pick points in the ABDraw screen. Asked AOG to build the curve, and WOW… It worked. Brian is a genius. Most of this was copy paste edit.

image

image

image

image

4 Likes

A bit more progress. It now imports each of the lines separate. Each can be selected to build the Curves in the ABDraw. Has a heading issue on the first and last point. Need to work on that. I know that GE is not very accurate sometimes. But may be an easy way to import tile lines or other features that you can save to Google Earth.

image

Tried this to see if it would work. I drew a pattern in GE. No measurements, not accurate, just a test for the concept. Then loaded the field in AOG, Loaded the Graphic, Set the offset to 0 (zero), and then drove to the starting point, clicked curve, and auto tool. This was the result. A little wiggle when it crossed itself. But it worked and worked well.

image
image
image

One more, import boundary from GE, Import graphic from GE. Ask AOG to set the offset to 1000. Drove it then u-turn with one skip. With and accurate kml file, I think it has potential for pre-field entry planning. I realize you can do most of this with boundary, but …

image

Sorry, but had to add this. I can do one part of the field and import a curve run from the field.kml file from the larger field. The actual curve that was driven or created, passed from one field to tractor to another.

image

And by modifying the kml writer in the save file to save the midpoint of an ABLine, I can import any ABLine from any previously saved field as a straight curve.

3 Likes

I’m not sure if the AOG community wants to go this direction, but, I’ve started converting V5 to save and load the ABLines to and from a KML file format in the stead of txt. I see some potential in opening the KML files from other platforms. Below is a link I found to open these files from a browser. I have no idea if the site is secure, or not. but you just drag and drop the file in the screen and it seems to open zoomed to it. AOG field.kml files load just fine.

https://ivanrublev.me/kml/

This is the ABLine.kml file in the above site.

image

First thing is to write the ABLine.KML

public void FileSaveABKML()
        {
            //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;
            myFileName = "ABLines.kml";

            XmlTextWriter kml = new XmlTextWriter(dirField + myFileName, Encoding.UTF8);

            kml.Formatting = Formatting.Indented;
            kml.Indentation = 3;

            kml.WriteStartDocument();
            kml.WriteStartElement("kml", "http://www.opengis.net/kml/2.2");
            kml.WriteStartElement("Document");

            //guidance lines AB
            //kml.WriteStartElement("Folder");
            //kml.WriteElementString("name", "AB_Lines");
            //kml.WriteElementString("visibility", "1");

            string linePts = "";

            for (int i = 0; i < ABLine.lineArr.Count; i++)
            {
                kml.WriteStartElement("Placemark");
                kml.WriteElementString("visibility", "1");

                kml.WriteElementString("name", ABLine.lineArr[i].Name);
                kml.WriteElementString("description", (Math.Round(glm.toDegrees(ABLine.lineArr[i].heading), 1)).ToString());
                kml.WriteStartElement("Style");

                kml.WriteStartElement("LineStyle");
                kml.WriteElementString("color", "ff6699ff");
                kml.WriteElementString("width", "2");
                kml.WriteEndElement(); // <LineStyle>
                kml.WriteEndElement(); //Style

                kml.WriteStartElement("LineString");
                kml.WriteElementString("tessellate", "1");
                kml.WriteStartElement("coordinates");

                linePts = pn.GetLocalToWSG84_KML(ABLine.lineArr[i].ref1.easting, ABLine.lineArr[i].ref1.northing);
                linePts += pn.GetLocalToWSG84_KML(ABLine.lineArr[i].ref2.easting, ABLine.lineArr[i].ref2.northing);

                kml.WriteRaw(linePts);

                kml.WriteEndElement(); // <coordinates>
                kml.WriteEndElement(); // <LineString>

                kml.WriteEndElement(); // <Placemark>

            }
            //kml.WriteEndElement(); // <Folder>   



            //end of document
            kml.WriteEndElement(); // <Document>
            kml.WriteEndElement(); // <kml>

            //The end
            kml.WriteEndDocument();

            kml.Flush();

            //Write the XML to file and close the kml
            kml.Close();
        }
2 Likes

I’m calling this a success.

It is now possible to import any graphic drawn in GE and saved as a KML file. This line can be converted to a curve and driven, or offset and drive the fixed distance from it. At least as well as the software will follow lines that are too sharp.

I’ve completely converted the ABLine files to KML files. Both on the save and open. AOG (the copy that I have worked on) no longer looks for the ABLine.txt. It loads only ABLine.kml. In the ABLine draw window you can open any two point kml line or any larger file that contains multiple two point lines. If more than two points, it simply accepts only the first two. You can load multiple kml files, they add to the number of ABLines you have.

As we know KML files do not need the Offsets. Therefore, they can be transferred from one tractor to another, regardless of the field. New or smaller fields can be opened and the same ABLines can be imported. Curves driven in one tractor can be saved and sent to another.

And all of it can be viewed real time if saved to a server and opened in a web browser.

image
image

6 Likes

Hello Kent, how do they do this? I have a robot and I want to create the path it will go by drawing myself, not with an alien. (paint etc.)

1 Like

There is software out there that will take a picture and convert it to lines. We had a plasma table years ago that would do this.

If you can draw the path with the correct radius at the turns, and get that into a kml file. This will drive it. Currently only forward. No reverse yet.

1 Like

You are right, I also built a cnc router once, working with G-codes, it could engrave vector images, it’s a matter of converting the x-y-z coordinates to kml file.

If you can output the x,y coordinates (lat, long)in a txt file, then easy enough to read in AOG or convert to kml, or both.

1 Like

Conversion completed for ABLine, CurvedLines, and Boundary. It looks for the kml file first, if there is not one or it is corrupt, it loads the txt file. When it saves, it saves individual ABLine, curve, and Boundary kml files. These are the files it loads from. These can be transferred from field to field, or task to task, regardless of the offsets or original coordinates.

Edit: Have now completed flags, and sections. Sections were complicated. Once I figured out that @BrianTee_Admin went in a circle defining the kml sections, and AOG does crisscross, then it made more sense. A typo on my part recorded the sections twice and double the applied area. Right now it just paints a black section regardless how it was recorded, but simple enough to get that right. Should now be able to send sections from one field to the other since it is all in lat and lon. Still lack recorded path, contour, headland and tram. Currently, contour, headland, and tram do not have an associated KML writer. I’ve written the record path.kml, Just updating progress.

Question for @BrianTee_Admin , Where would be the best place to timestamp the sections? The KML can keep up with that information fairly simple along with other conditions if we had them.

1 Like

like add a time to every section triangle? That’s a lot of data.

Or each patch list would be sufficient.

Edit: @BrianTee_Admin Got it. I added a time stamp to the Vec3. By default it sets it as Now. Then when writing the KML all it has to do is read the first and last and come up with the start and stop time. Loading that date back into AOG might be a bit more of a challenge. But if all we care about is the first and last then it can simply only edit the stamp for the incoming first and last.

public struct vec3
    {
        public double easting;
        public double northing;
        public double heading;
        public DateTime now;

        public vec3(double easting, double northing, double heading)
        {
            this.easting = easting;
            this.northing = northing;
            this.heading = heading;
            this.now = DateTime.Now;
        }

        public vec3(vec3 v)
        {
            easting = v.easting;
            northing = v.northing;
            heading = v.heading;
            this.now = DateTime.Now;
        }

image

Sections were complicated. I do repeat. I thought that I had it. Found out it was displaying correctly but after opening the field several times, the left points creep forward. and the right points creep back. I got that fixed. Still complicated.

So I’ve been able to apply sections in one field. Exit that field, build a new field, and then replace the new field section with the old field sections and it loads and paints it fine. Question now is, can two tractors running two different AOG systems, save the sections to a virtual server, and both know what the other tractor sprayed or planted?? And navigate around it?? I think, maybe.

For a 150 ha field, that is an incredible amount of extra data to save date/time for every patch.

Early estimates:
Sections kml file with time stamp about double the Sections txt file.

Leave the time stamp off saves 10% of the kml file size.

Not sure if or how it affects the inter workings of AOG. It only calls it when saving the kml file. I’ve set that into the 1 minute timer with the other section saver. Setting GE to auto update, you can watch it update and paint the field.

One way to reduce the kml file size is to increase the patch list size to a greater value than 36. At 10 kph it is about every 20 secs. Might be able to set that 36 to a variable of the field size. Or if I can figure out how to combine the patch lists when writing the kml file to a larger group, that would save some space as well.

We lose a lot of data that we could be gathering when we close a field. Not sure the kml file is the way to store it. I don’t know enough about database, but that may be the better way.

Edit: 6Ha (15acres) is 1 mb in the timestamp kml. 4m tool, 10 to 15 kmh (6 to 9mph). About 850 kb without time stamp, and between 310 and 350 KB for the txt only file. So if the math holds true, 150 Ha would be about 25 mb.

After 12 Ha
Just shy of two mb
160kb per Ha timer kml
60kb per Ha txt.
140kb per Ha plain kml

Did you have to modify anything to get aog to not close the kml curve
? When I try to pick the 2 points to draw an ab curve it is only selecting the outer boundry.
V5.2. Thanks
20210710_060055

Yes, when you load the form, it needs to load that line in the array, then you can select it. It is a software modification. It is not anything you can select. Maybe a feature for later.

1 Like