So I can connect the
test vehicle and its accelerometer to the PC, now to do
something with the data. Accelerometers are devices for
measuring the strength of the Earth’s gravitational field in
different axes, which means that with some arithmetic you can
extract the orientation on the accelerometer and whatever it is
attached to. Ever wondered how an iPhone knows when it is
turned on its side, well it uses an accelerometer to sense its
orientation. I am using the LIS302DL triple-axis accelerometer;
there is a tutorial on how to use it here.
"Measuring Tilt using a Three Axis
Solution In order to define
the angles of the accelerometer in three dimensions the
pitch, roll and theta are sensed using all three outputs
of the accelerometer. Pitch (?) is defined as the angle
of the X-axis relative to ground. Roll (f) is defined as
the angle of the Y-axis relative to the ground. Theta (?)
is the angle of the Z axis relative to
gravity."
Once the equations
were established for calculating the orientation I could
extract the angles and display the result. I wanted to
show the orientation being tracked in real time with a
simple intuitive animation. I chose a basic artificial
horizon type animated display; it’s simple and clear to
understand.
The raw
measurements from the accelerometer were already being
inputted into MATLAB; all that was needed was some more
code to initialise the figure and to update the figure
each time new data was received. I took the roll angle
value and used that to alter the “angle of bank” on the
figure. The pitch angle is also available but that
visualisation will be included at a later
point.
Video
All the movements
I am making need to be reasonably slow, this is because
an accelerometer can also sense dynamic acceleration.
Image that an accelerometer is held perfectly flat, but
it is accelerating in a straight line, the accelerometer
will detect the dynamic acceleration and will give a
false reading of its orientation. At this point you need
to bring in other sensors taking other measurements and
fuse the data together to get a more accurate
picture.
Usually gyros are
used with accelerometers; gyros are devices which measure
the angular velocity about an axis. The gyro will read
non zero during a rotation and will be zero once it stops
rotating, you can then obtain a value for the angle by
integrating the angular velocity over time. However gyros
have “drift” which is that they are constantly
accumulating errors, so eventually you have no idea which
way you are pointing. This is where you use the
accelerometer to correct the gyro drift, but we know that
the accelerometer can be corrupted by sensing dynamic
acceleration too…. So for that reason the average value
from the accelerometer over a period of time is used to
correct the gyros.
That is one method
to fuse sensors others include using a Kalman filter
which estimates the state of a system from
noisy/inaccurate measurements. It’s a recursive filter
using statistical modelling to remove the noise from the
signal/output.The Kalman filter is not a
light topic; it took a good couple of weeks and a lot of
reading to get to a point where I had a very general
understanding of how and why it worked. But once you
reach a certain level the actual algorithms you implement
are not too difficult. If you are interested in the
filter for your own work then here are some documents
that I found useful during my research.
An excellent
introduction to the filter. Including MATLAB
code for you to observe for yourself how the filter
operates.
An academic
paper covering some of the mathematics behind
the
filter.
What I
leaned about Kalman filtering so far should be useful,
because the work from ATB1 will lead onto experimentation
with stability and
control.
You can see
that this can be a very complex topic, and we are
beginning to venture into the world of Autopilots and
inertial measurement systems (IMS). Again if you would
like to know more about autopilots or gyros and
accelerometers then DIYdrones.com is an excellent
place to do so. As well as general browsing of the site,
here are some specific links to discussions on this
topic.