Pages: [1]   Go Down
Author Topic: Using a compass for Navigation - Control method?  (Read 1048 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: September 09, 2011, 06:26:38 pm by jsmith29 » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 208
Posts: 8860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13742
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

something like this...?

Code:
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 ;
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: