Zigzag line entrance small tools

@BrianTee_Admin, The default right or left turn also has some great potential. Below is the code that I used to force the dubins draw point to the right or left. Basically, it looks along a line a set distance either side of the current abline. It looks for an intersection of this “offset” line and the next ABLine in the mix. Not the next lateral shift, but the next reference line. Once cycle is clicked, it builds a dubins from the current position to the intersection. It locks and drives this line. Below is the stolen code of yours that I modified to do this. It is a hack for sure, you can clean it up much better, but is really a nice feature to be able to click the default turn direction regardless of the angle. However, you have to limit the angles or it just becomes a nasty U-turn.
By the way, taking sneak peaks at the new sticky. I really like what you did with the U-turn. Snap the ABLine early rather than latter. NICE!!

Edit:
My son, who does much of the spraying for my dad, his grandfather, asked about the sticky line, so I can leave the field and come back and it keep the same line? He asked with an excitement. With the raven system and with the current flags, we can mark and return, but keep the ABLine stationary while, filling the tank, or other needs, that might be something to consider.

public void GetNextABLine(vec3 pivot, vec3 steer, int numb)
        {
            double dx, dy;
            isValidTurn = false;


            //if ((mf.secondsSinceStart - lastSecond) > .01)
            //{
            //    lastSecond = mf.secondsSinceStart;

            //move the ABLine over based on the overlap amount set in vehicle
            double widthMinusOverlap = mf.tool.toolWidth - mf.tool.toolOverlap;
            double diffDelta = (Math.Abs(lineArr[numb].heading - abHeading));
            if (diffDelta >= Math.PI) abFixHeadingDelta = Math.Abs(abFixHeadingDelta - glm.twoPI);
            isValidTurn = Math.Abs(diffDelta) >= .42;

            

            //x2-x1
            dx = lineArr[numb].ref2.easting - lineArr[numb].ref1.easting;
            //z2-z1
            dy = lineArr[numb].ref2.northing - lineArr[numb].ref1.northing;

            //how far are we away from the reference line at 90 degrees
            //distanceFromRefLine = ((dy * pivot.easting) - (dx * pivot.northing) + (refABLineP2.easting
            //* refABLineP1.northing) - (refABLineP2.northing * refABLineP1.easting))
            /// Math.Sqrt((dy * dy) + (dx * dx));
            double lookdist = (Math.Max(mf.vehicle.minTurningRadius * 1.5, mf.pn.speed * 0.277777 * 2));
            vec3 ABLOOK = new vec3(pivot.easting + (Math.Sin(mf.fixHeading) * (lookdist)), pivot.northing + (Math.Cos(mf.fixHeading) * (lookdist)), 0);

            double distanceFromRefLine2 = ((dy * ABLOOK.easting) - (dx * ABLOOK.northing) + (lineArr[numb].ref2.easting
                                     * lineArr[numb].ref1.northing) - (lineArr[numb].ref2.northing * lineArr[numb].ref1.easting))
                                         / Math.Sqrt((dy * dy) + (dx * dx));


            
                double dishowManyPathsAway = Math.Round(distanceFromRefLine2 / widthMinusOverlap, 0, MidpointRounding.AwayFromZero);
            


            //depending which way you are going, the offset can be either side
            vec2 point1 = new vec2((Math.Cos(-lineArr[numb].heading) * (widthMinusOverlap * dishowManyPathsAway + (isABSameAsVehicleHeading ? -mf.tool.toolOffset : mf.tool.toolOffset))) + lineArr[numb].ref1.easting,
                (Math.Sin(-lineArr[numb].heading) * ((widthMinusOverlap * dishowManyPathsAway) + (isABSameAsVehicleHeading ? -mf.tool.toolOffset : mf.tool.toolOffset))) + lineArr[numb].ref1.northing);

            //create the new line extent points for current ABLine based on original heading of AB line
            nextABLineP1.easting = point1.easting - (Math.Sin(lineArr[numb].heading) * abLength);
            nextABLineP1.northing = point1.northing - (Math.Cos(lineArr[numb].heading) * abLength);

            nextABLineP2.easting = point1.easting + (Math.Sin(lineArr[numb].heading) * abLength);
            nextABLineP2.northing = point1.northing + (Math.Cos(lineArr[numb].heading) * abLength);

            nextABLineP1.heading = lineArr[numb].heading;
            nextABLineP2.heading = lineArr[numb].heading;

            isNextCurrentSameHeading = Math.PI - Math.Abs(Math.Abs(pivot.heading - abHeading) - Math.PI) < glm.PIBy2;
            vec3 A = currentABLineP1;
            vec3 B = currentABLineP2;
            if (!isNextCurrentSameHeading)
            {
                A = currentABLineP2;
                B = currentABLineP1;
            }
            
            vec3 P = nextABLineP1;
            B -= A;
            P -= A;
            int cross = Convert.ToInt32((B.easting * P.northing) -( B.northing * P.easting));
           
            double cosHeading = Math.Cos(-abHeading);
            double sinHeading = Math.Sin(-abHeading);
                       
            if (isNextCurrentSameHeading)
            {
                cosHeading = cosHeading * -1;
                sinHeading = sinHeading * -1;
            }

            double stag = lookdist;

            if (isRight) stag = -1 * stag;


            double A1 = (currentABLineP2.northing + (sinHeading* (stag))) - (currentABLineP1.northing + (sinHeading * (stag)));
            double B1 = (currentABLineP1.easting+(cosHeading*stag)) - (currentABLineP2.easting + (cosHeading*stag));
            double C1 = (A1 * (currentABLineP1.easting + (cosHeading*stag))) + (B1 * (currentABLineP1.northing + (sinHeading * (stag))));
            double A2 = nextABLineP2.northing - nextABLineP1.northing;
            double B2 = nextABLineP1.easting - nextABLineP2.easting;
            double C2 = (A2 * nextABLineP1.easting) + (B2 * nextABLineP1.northing);


            double delta = A1 * B2 - A2 * B1;

            if (delta == 0)
            {
                isValidTurn = false;
                return;
            }

            double x = (B2 * C1 - B1 * C2) / delta;
            double y = (A1 * C2 - A2 * C1) / delta;
            //isNextCurrentSameHeading = (nextABLineP1.heading - abHeading) < 0;
            if (isRight)
            {
                if (cross > 0) nextPointAB = new vec3(x, y, nextABLineP1.heading);
                else
                {
                    double temphead = nextABLineP1.heading + Math.PI;
                    if (temphead > glm.twoPI) temphead = temphead - glm.twoPI;
                    nextPointAB = new vec3(x, y, temphead);

                }
            }
            else
            {
                if (cross < 0) nextPointAB = new vec3(x, y, nextABLineP1.heading);
                else
                {
                    double temphead = nextABLineP1.heading + Math.PI;
                    if (temphead > glm.twoPI) temphead = temphead - glm.twoPI;
                    nextPointAB = new vec3(x, y, temphead);

                }

            }
           

        }
2 Likes

What was 4.6 :rofl: :rofl: :rofl: :rofl:

on the past with the flag menu there is switch to go direcly on the line ( Brian remove it because no time for this) but it can also an idea to link to your request …

This is what we currently use. But holding the ABLine there, that was what he suggested. With sticky, it may do this without additional programming. In the simulator it is not possible to drive somewhere else with autosteer on, but it is in the field.

Still on the TODO list!!

But you can set a flag, or turn on record Path and it will drive you back. Just having the ABLine on doesn’t take you to the right spot

1 Like

Brian, all the team ,

need to repeat again wonderfull all progress that you can do to improve and listen each other

thanks a lot ! Farmer helping farmer !

1 Like

Brian

i do test this afternoon with 5.1.7 Sticky version not so far 5.2 i guess …

the job is to rake hay around 8km/h

the input on the line are now very smooth with sticky version !

I have two kind of field
-A big and quite square that opportunity to activate all to have 90 automatic job with Uturn, head land / hydraulic lift engaged evry thing works pretty good !

  • Few small field : that i use adaptative line,
    it is not easy to set or i do a mistake
    is there any information to activate correctly with normal step?

also it will be dificult to generate new line to appears and select
if you have any advise that you can tell us

Please explain what you mean by adaptative line?

sorry
on help page we call it “contour”

image

1 Like

In the attached image, the only available contours to follow are purple. This may seem strange, but AOG does not build contour list if running an ABLine or a Curve. It is only built when recording path or in free drive. This is important when trying to select a line or get close to a line to select it. You know there is a line there to follow, but why will it not pick up. Question to as is how was that strip created.

image

ok for AB line or curve
but in this contour mode

or the procedure
-first activate contour mode
-second activate section
-drive a nd try to approch the activate area and normally it work
but it is very slow and not easy to understand when and how…,

Exactly! Sometimes it works great, Sometimes you can drive along a line for several seconds before it will pick it up. If you cycle the section off and on, it will reset, then Sometimes it will pick up.

1 Like

a link for a video of screen in reality that i take this sunday when raking with contour mode

In CContour about line 296 we have the following:

 //if making a new strip ignore it or it will win always
            if (mf.sectionCounter > 0) stripCount--;
            if (stripCount < 1) return;

It keeps building contours but will not pick the latest one. If the complete section has not cycled off, then it is the latest contour and will skip it. When you cycled the tool off, it started a new contour and then was able to pick the last one. I’m not sure how to fix it, but I do know why it did what it did in the video.

1 Like

I’ve broken the contour into max count of 36. That helps. Then you need not look at the closest two lines. And for some reason, if it runs across a line that is 90 degrees or so it drops the line. I got rid of the last second counter. That helps. Still not clean, randomly it will not record the contour line, randomly it will just drop the line it is following.

Edit:
Some progress:
The search for new line stays active all the time. But, it only looks for lines 3 behind and 3 ahead of the current line. Every 36 points on a contour line it is broken into a new line. If a line is not found, it starts a counter, after 10 times of no line, it assumes there is no recent line and scans all the lines. This has eliminated the 90 degree jump and picking up lines from a separate pass. Now, if the 90 degree pass is with the last three, it will pick it up. In the picture below, it is making circles based on an original circle. The green line is the current line it is using, the other purple lines are all the lines it could be using.

image
Started in a rough circle, Then cut across and made a few loops.
then asked it to drive the perimeter. In this photo it has ran for an extened time at 61.6 km/h. Simulator only of course. But, I’ve worked much of the bugs out.

image

Last Edit:
I’m calling this a partial success. I drove the perimeter of the field and then hit auto steer after one round. Just some minor glitches when the tractor could not steer the increasingly tightening corners. But the contour works very well and will stick the line.

image

Summary of changes:
If autosteer is on, only look for the closest 6 lines.
Remove the last second delay.
Remove the start and end point for each line segment.
Break contours into smaller (36) pieces.
Draw the contours and turn the one that is reference to green. (This really helps to know when you have a fix on the correct line.)
All pivot references are to the guidenceLookPoint.
Get rid of the sharp angle break.
Set how many paths away to 1 and -1 regardless of where you are in the field. You only need to be 1 path away from any line.

5 Likes

Thanks @KentStuff to investigate and improve the code !

Here is the program to try the contour. The (dirty) source code is also in the same github. This was based on the sticky branch of Brian’s a week ago. The two files that changed are the ccontour and the position designer. The changes to the position designer was to break the contour into smaller sections. Most of the changes are in the contour file.

Give it a try, if it works well for everyone, it may be worth adding into the code.

AgOpenGPS_v5.zip

3 Likes

Kent

thanks to do this proposal

Sorry i have no time and no task to really test this update ,
I just use the simulator but i think it is out of reality and i cannot conclude

Do you have the source up to date on your github?