PID for autonomous boat using gps+mangometer

Hello,
i have a project for my uni for which i build an autonomous rc boat. I am in the stage that i have to develop a PID for it to go from point A to point B without drifting away (steady course) and with a steady speed. Combining that it should also reach the target, we have 3 PID systems. I am using an arduino mega 2560 and a ublox M8N+magnometer module. I use tinygps++ library for the gps and Adafruit_Sensor.h for the magnometer. First question is about the tinygps++ library. Why it has two course functions, gps.courseTo(gpslat, gpslon, newlat, newlon) and gps.course.deg() ? The first one must be the one we need for the pid. Also does the gps.cardinal(course) calculate true or relative bearing? Lastly for the first PID i am thinking that it will calculate the difference between the current course and the changed course (due to drifting) and it will try to make the difference 0. Is my thought right?

In a device I use I use the gps.course.deg() to tell what heading I have. It's in absolute degrees. 0 degrees is a north heading.

For a boat you really need only one PID loop, to control the steering.

When the distance to the target is within a couple of meters, just stop, because that is the limit of the GPS accuracy.

For the heading control loop, most people use the difference between current heading (yaw angle) and bearing (desired heading) as the feedback for the steering PID loop.

This is what I use for a boat with twin screws (see reply #10.) A BNO055 absolute orientation sensor is used to determine the yaw angle, and GPS to determine the current location.

MP4 video of the boat in action

2 Likes

@jremington
Thanks for the entertaining video. If I could buy a ton of time it would surely be an interesting hobby.

I am currently using the difference between the intended course and the current course of the boat so the steering can be more precise when sea has much current (which is often at where i live due to winds). But after some tests, i noticed very strange behavior of the boat. Is it possible to make a pid working with the difference of course because iam thinking that the gps should be very precise and very fast. Ublox NEO-M8N is pretty accurate when connected to 9+ sattelites but how fast can it be? Can i receive the position of the boat many times in a second? What's Max navigation update rate 10 Hz means? Otherwise i will use the difference of heading as you did.

It means it can provide up to 10 position updates a second.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.