Subject
- Posted on
auto heading
- 02-06-2007
February 6, 2007, 10:27 am
Hi to all,
I'm new to this newsgroup and to the robotics too :-)
I have a boat with three motors: one on the rear and two on both
sides. These two are on-off type, so I can turn on or turn off but I
can't change the speed.
The boat has an electronic compass and a gyro on-board.
Well, I need to implement an auto heading feature. One can set the hdg
via an RS485 link and the microcontroller on the boat should rotate
the boat itself and should maintain the track also in presence of wind
or other "noises".
I have some questions:
1) How should I use the data provided from both compass and gyro?
2) What kind of algorithm is more suitable for this application? PI,
PID, other.....
Thank you,
Marco / iw2nzm
I'm new to this newsgroup and to the robotics too :-)
I have a boat with three motors: one on the rear and two on both
sides. These two are on-off type, so I can turn on or turn off but I
can't change the speed.
The boat has an electronic compass and a gyro on-board.
Well, I need to implement an auto heading feature. One can set the hdg
via an RS485 link and the microcontroller on the boat should rotate
the boat itself and should maintain the track also in presence of wind
or other "noises".
I have some questions:
1) How should I use the data provided from both compass and gyro?
2) What kind of algorithm is more suitable for this application? PI,
PID, other.....
Thank you,
Marco / iw2nzm
Re: auto heading
To keep things simple, start by just using the compass with a low-pass
filter to reduce the noise. If you need better results, the Kalman
filter would be a good next choice.
Basically, the compass gives a stable long-term estimate of your heading
but its either noisy or unresponsive to quick motion. The gyro provides
good short-term info, but they tend to drift over time.
Its hard to say without more info. That said, water provides plenty of
damping, so I doubt you'd need a derivative control term. You could
probably get away with manually tuning a PI control that drives a
low-frequency (~0.5Hz) PWM on your motors (assuming you don't have a
proper PWM controller for them). A well-chosen integral control might
even suffice (no P term).
To explore the control more throughly, you could generate "Bode plots"
by applying constant-period control signals to the motors. For example,
measure the time delay (phase) and angular change (amplitude) to a
series of [right 1s], [left 1s] commands. Then repeat for 2s, 4s, ...
pulses. Also repeat at a few fixed forward velocities (stopped, nominal
cruise, fastest). Plotting this information for a few different
settings reveals significant information about the system dynamics.
Basic things to look for:
- a good PWM frequency will be slightly less than what causes a
"significant turn"
- keep the proportional gain low enough that "the phase does not exceed
180 degrees" (i.e. the delay is less than 1s in the 1s pulse sequence)
I've rambled enough.
- Daniel
Re: auto heading
Does "the gyro tends to drift" mean that after some time I get an angular
velocity also if I go straight? If so, how one should use gyros? Or
better... where can I find some literature on this concept?
Well, I guess you're right. I'll try first this way.
It's a good idea!
I think I have to select the "good" PWM frequency once I set output at 50%.
So I will get a "significant turn" at 50%, over this I can rotate faster
and below I can make fine movements. Am I right?
Of course, otherwise it's prone to oscillate....
I thank you very much!!!!
Marco / iw2nzm
Re: auto heading
Since the compass measures the earth's magnetic field, it will always
point in "the right general direction" (assuming there is no
interference from iron, other magnets, or electrical circuits).
The gyro, on the other hand, does not have an external reference. Any
miscalibration will cause its internal reference to rotate slowly. Over
time, it will "drift" and the internal angular reference will show
increasing deviation from an external reference. Observe this by
leaving the gyro in a fixed position and watching its output. Really
good units (e.g. submarine equipment) don't drift much at all (they can
measure the angular precession of the earth turning), but I've never had
the benefit of using one. The cheap stuff I've used drifted at rates
around 1 degree per minute, depending on the temperature.
To mix the gyro and compass measurements, start with a fixed-gain filter
like
H[t] = (1-a-b)*H[t-T] + a*CH[t] + b*(GH[t]-GH[t-T])
where
t - current time
T - sampling interval (assuming both sensors are measured at the same time)
H - heading (H[t-T] is the previously calculated heading)
CH - compass heading
GH - gyro heading (GH[t-T] is the previous measurement)
a,b - weighting coefficients where 0 <= a,b <= 1
If you had an accelerometer instead of a gyro, then it would give the
angular velocity AV instead of GH; simply replace b*(GH[t]-GH[t-T]) with
b*AV[t]*T.
This implements a low-pass filter and lets you adjust the weight of each
sensor individually. If a sensor is noisy, set its coefficient low so
its effect on the filter is slowed; relatively noise-free sensors can
have coefficients nearer to 1 for quicker response. Just guessing, I'd
pick a=0.1 and b=0.6.
Actually, it should be b=1... That might not be the best filter; the
following feels better
H[t] = (1-a)*(H[t-T] + (GH[t]-GH[t-T])) + a*CH[t]
Here, I assume the gyro is perfect over short periods of time and use
the compass in a low-pass filter to correct drift over time.
The Kalman filter uses the same style filter equation (designer's
choice) to determine the heading, but its uses a few other filters to
estimate optimum values for the weights. See this site for a good
introduction.
http://www.cs.unc.edu/~welch/kalman/
With a little more thought and experimentation, I'm sure you'll find
something that works well.
- Daniel
Site Timeline
- » AD: SoundGin Sound Synthesizer Development Board Now Available
- — Next thread in » General Robotics Forum
-

- » Futaba Square Plugs
- — Previous thread in » General Robotics Forum
-

- » evoMUSART 2013: First CFP (with correct dates)
- — Newest thread in » General Robotics Forum
-

- » Próba ciśnieniowa zbiornika: bezpi eczeństwo
- — The site's Newest Thread. Posted in » Engineering Science (Polish)
-






