Using a compass for Navigation - Control method?

I want to navigate a boat based on input from a compass. I am trying to figure out which control method would be best, proportional or PID. With either method, I am also trying to figure out the best way to handle the error calculation of the actual heading vs. the desired heading since the compass is 0-360°. The problem is that 0° and 360° are essentially the same point and they keep repeating from 0 to 360. I have done alot of research on using a PID loop with feedback values that repeat itself and alot of people say that it isn't really suited for that. I would appreciate anyone's thoughts on what the best way to do this would be.

Given the desired heading it should be easy enough to calculate an error term in the range -180 to +180.

If simple proportional control gives too much of a dead band (error term too low to cause a correction but too high to be on course) you can change to a PI control. If the heading oscillates, you can go to PID control.

One thing you should be aware of is that your course (direction of travel) will not necessarily be the same as your heading (direction the boat is pointing). If there is a side force (current or wind) then the boat will drift sideways relative to the heading.

Given the desired heading it should be easy enough to calculate an error term in the range -180 to +180.

Can you clarify this?

Thanks

something like this...?

compass = readCompass();  // 0..360;
heading = H;                       // 0..360;

error = heading - compass;  // or compass - heading if you want the sign inverted

// mapping to -179 .. 180 
if (error <= -180) error = 360 - error;
if (error > 180) error = -360 + error ;