Low Pass Filter
Due to time constraints, instead of working on a 2D Kalman Filter for filtering sensor data, we decided to use a software based Low Pass Filter to filter out the noises. We have implemented the following formula in Python as follows:
𝑠𝑚𝑜𝑜𝑡h𝑒𝑑𝑉𝑎𝑙𝑢𝑒 = (𝑠𝑒𝑛𝑠𝑜𝑟_𝑟𝑒𝑎𝑑𝑖𝑛𝑔 ∗ (1 − 𝑓𝑖𝑙𝑡𝑒𝑟𝑉𝑎𝑙𝑢𝑒)) + (𝑠𝑚𝑜𝑜𝑡h𝑒𝑑𝑉𝑎𝑙𝑢𝑒 ∗ 𝑓𝑖𝑙𝑡𝑒𝑟𝑉𝑎𝑙𝑢𝑒)
For each instance, the live sensor readings are recorded in a .csv file in the Raspberry Pi and is transferred to a laptop for further analysis in Microsoft Excel. To increase the accuracy of the experiment, we fed in at least 100 data points. The sensor can produce 15-20 data points per second. However, only a subset of values are shown in the table below. The graphical analysis will give a much clearer idea about the effectiveness of the filter.
With the above data plotted into a graph,
The filter has proven to be effective. However, to improve on the equation, the filterValue used must be properly determined. By experimenting with different filterValues and analysing the graphs, we determined the effective value, which is within the range of 0-1, with 1 being the noisiest values output.
When filterValue = 0.9,
It can be observed that the filtered curve (orange) deviates greatly from the actual values. The filterValue used is too high.
When filterValue = 0.7,
It can be noted that with a filterValue that is slightly higher than 0.5, the orange line starts travelling in line with the raw distances, represented by the blue line but with reduced spikes. This value is acceptable, but it can be improved further.
When filterValue = 0.5,
Based on observation, this is the best set of data that we have obtained. The filtered values do not deviate too far from the actual values, while reducing the spikes. Hence, filterValue = 0.5 is chosen as the optimum.
However, let’s take a look when filterValue gets much lower.
Now, the filtered values started to take the shape of the raw distance values. This setup is hence rendered useless as minimal filtering is done. Hence, we stick with the filterValue of 0.5.