Hello,
I have a very quick question that I believe is best explained by this screenshot:
I have my distance sensor (TFMINI-S) pointed blankly at a wall.
It correctly reads 310cm over and over.
raw_dist is the sensor reading dist is the smoothed reading (using the default smoothing example code from IDE)
As you can see from the image, there is a moment where the sensor reads 359.
This only happens once every few minute, and it is always just a singular stray reading.
Other than this noise the sensor is very consistent and overall extremely low noise.
I think the best way to deal with this stray reading is some software smoothing?
However the smoothing algorithm (simple averaging of prev 5 values) is not quite suited for this purpose. It spits out 322 which is a large enough jump for my code to trigger other things.
What I really want is an algorithm that ignores 359 completely.
Any advice how to do this properly?
Thank you!!!!
Parker
using arduino mkr zero
with dynamixel shield
my code is across 10 tabs so not sure how to upload it!
won't let me use .zip
I would use multiple samples and find the median (the one in the middle when samples are sorted). That throws away outliers that are high or low. There is a "MedianFilterLib" to help.
For stuff like this, I've used a delta filter concept similar to what Perry Bebbington suggested. A reading is only considered valid if it within a certain delta from the previous reading, or within a delta from the average of, e.g., the last 10 readings.
The problem is that this behavior is stateful, so it's possible to get caught up in the state where you only accept bad readings. Occasionally you may need to sanity check all the values you're holding.