In our investigation of Kalman filtering we explored several different methods of applying the filter to the segbot.  The signals we were interested in for this stage of the investigation were the tilt and tilt rate from the two accelerometers on board the robot. Tilt rate is measured by an Analog Devices ADXL103 Accelerometer.  Tilt rate can be numerically integrated to approximate tilt for purposes of controlling the robot.  Pure tilt is measured by an Analog Devices ADXRS300 Gyro.

 

Each sensor has good and bad characteristics for our application.  The integrated accelerometer signal is quick, accurate, and not very noisy.  Due to a constant small but non-zero reading on the accelerometer even when the robot is not rotating, the integrated tilt signal drifts quite noticeably.  The gyro signal does not drift from its zero noticeably but updates much more slowly than the accelerometer.  Noise and spikes in the raw gyro signal necessitate a filter to prevent these characteristics from reaching the controller.  On the segbot, this filtering is accomplished by an RC network attached to the gyro.

 

A logical way to use these two sensors in concert is to low pass filter the gyro signal, high pass filter the integrated accelerometer signal, and add the two together.  The resulting signal has a lot of the positive characteristics of either sensor and little of the negative characteristics.  This kind of signal conditioning is known as a complimentary filter.

 

Kalman filters can be employed to replicate the results of the complimentary filter or to further condition the output of the complimentary filter.

 

As a demonstration of the effectiveness of Kalman filtering we simulated Professor Sreenivas' example of two simple noisy signals, one based on the integration of the first:

 

The flat line is integrated to give the curve above it.  The line can be thought of as velocity and the curve as position.

 

Above are the original signals.

The blue position signal is an integration of the yellow velocity, with noise added.

 

 

Here we see position and velocity signals without noise.

Plotting directly on top of the noiseless signals are the Kalman estimates of those signals.

These estimates were derived by a system who knew only the noisy signals and the system of

equations that relate the two.

 

A Simulink simulation of the above signals and the Kalman filter can be found in the code section.

 

 

 

 

 

 

 

 

 

The simulations below both make use of simulated noisy gyro and accelerometer readings:

 

The true tilt angle of the segbot is the yellow curve.

The blue is the drifting, integrated, noisy accelerometer signal.

The purple is the true tilt angle through a low pass filter which mimics

the behavior of the tilt sensor with noise added.

 

 

 

 

 

 

 

 

A simple Kalman filter is applied directly to the noisy output of the simulated system of a gyro, accelerometer, and complimentary filter.

 

The true signal is included in yellow.

The purple curve is the complimentary filter of the sensors.

The blue curve shows the estimate of the accelerometer drift produced by

the Kalman filter subtracted from the accelerometer reading.

 

The effectiveness of this filter can be shown by summing the square of the error between the Kalman filtered signal and the complimentary filtered signal.  This simulation gives a complimentary filter error of 0.00389 versus a Kalman filter error of 0.001819.  A moderate but not insignificant improvement.

 

 

 

 

 

 

 

 

 

A Kalman filter including the relationships between the signals it estimates is shown below. 

 

The blue curve plots the filtered tilt.

The red curve is a running estimate of the offset of the gyro signal.

 

 

The squared error of this result:  0.002881.  Again, a slight but not insignificant improvement over the complimentary filtered signal (with squared error of 0.00389.)

 

 

 

 

 

 

 

All above plots were produced in Simulink.  Files to create these simulations can be found in the code section.

 

Kalman filtering can also be applied to other useful state variables such as position, or orientation.  The four wheel robots of the mechatronics lab could be improved by filtering the rate gyro signal they use to determine orientation.  An object mapping or avoidance system could apply these principals to better determine the location of the objects.  Multiple state variables from different sensors or pieces of knowledge can be compared to produce refined estimates of  each.  For more information, uses and background on Kalman filtering see The Kalman Filter by Greg Welch and Gary Bishop.