Specifications

The Enhancement of a Multi-Terrain Mechatron for Autonomous Outdoor Applications
148
Equation 5.3
w
i
: i
th
weighting factor
Median
The median function in MATLAB sorts the data set according to number magnitude
and then selects the centre point as the median value. The median filter is less
sensitive to transients than the mean or weighted mean however it is slower to
respond to valid changes such as obstacles.
Equation 5.4
Selected Method
To effectively remove the transients from the infrared readings a combination of the
mean and median filters have been used to utilize the advantages of each. The 10
samples acquired for each channel are averaged using the mean function before being
entered into a cyclic buffer. The buffer contains the last 10 averaged samples
representing the last 10 control loop cycles using a First In First Out (FIFO) update
strategy. The buffer array is shifted each cycle using the circshift function and shown
in Figure 5.22 thus allowing the new data to be written over the oldest data.
Figure 5.22 Infrared sensor circular buffer shift
The median is calculated for the 10 samples on each channel and this value represents
the current filtered voltage which is then converted to a range. This method was
chosen as any brief transients do not affect the sliding mean value however the
response time is reduced so the number of samples is limited to 10. Depending on the
future implementation, a weighted mean could also be effective if a suitable means of
allocating weighting factors can be determined.
IRSensorData.IRValues = circshift(IRSensorData.IRValues,1);
n
Ew
E
n
i
ii
=
=
1
nnnmed
EEEEEE =
1212/
...,