PID is all very well (wikipedia tells me that it was developed watching helmsmen working) but I suspect that it won't be sufficient, at least in simple form.
Distance from the rhumb line (cross track) is Important as @J-M-L points out but you likely don't need it to be zero because trying to achieve that will probably lead to constant changes in power settings and a zigzag.
Also, when you get close to the end point, the priority changes. The bearing will vary more rapidly and be less important. If there is a subsequent waypoint, then you need to decide when to aim for it instead.
If you're racing, you will need to be certain that you have passed the mark on the correct side.
So although the PID may be part of your solution, I doubt that it can be all of it.
@J-M-L It seems sensown as I try to monitor the XTE.
@jremington The boat I have is a bait boat. I am sport fishing - catch and release. I attach the set to the boat and go out to the lake 300m. Where I drop my kit. It is important that it is a straight line due to the underwater vegetation.
If I swim in a curve, then if I were to roll the set then it would work like a net, i.e. I would grab all the vegetation with me to straighten the line
I do not know if I understand well. I'm at point A somewhere between the From point and the GoTo point. Point A is not on a perfect line so I calculate the distance from this line how far I am from it, i.e. XTE
If XTE <0 the boat is on the left side of the line and if XTE> 0 the boat is on the right side. So if I am at point A, I should correct the boat's movement to the left (the right engine works harder to make a left turn) until XTE = 0.
I took the liberty of copying some of your code @J-M-L because I would like to make sure I understand it correctly.
I'm sorry I haven't tested it unfortunately I have covid-19 and I have to sit in the house. In addition, it is winter for me and I have nowhere to test it too much because all the lakes are frozen. I have one tank at the power plant, but it's a trip for the whole day. How will I test this tp I will come back with feedback. I just wanted to confirm whether my way of thinking is good. Thank you for your help and I'll be back in a while;)
If you desire to move in a straight line then you should never end up at point A in the first place, that is the whole point. Corrections well before then would disallow it.
Yes, I know now that the boat is drifting because it does not keep an even line from the From point to the GoTo point.
Therefore, what @ J-M-L gave me, I have to calculate XTE to check if the boat stays straight or deviates from the course. At least that's how I understand it. In about 2-3 weeks I should be on the water so I will test my theoretical knowledge with practice
I still have this theoretical question. Is it possible to set a course and go straight without a magnetometer using only GPS ???
Because from this code I can see that it would be possible because I have the DTK angle and I also have CTG, so theoretically the program could calculate based on the coordinates.
GPS like this: