I have an object that is moving towards target point and I want to determine when it will reach or pass through it. I receive points in real time, which represent the current location of the object.
Naive approach: For each received point:
- Calculate distance between current and target points.
- As the object approaches the target, the distance decreases. If current distance is greater than previous distance, I consider that it has reached the target. It's good enough for me.
The problem is that the point can sometimes fluctuate a bit. It can increase and then decrease again (noise), even if it has not yet reached the target. But because of this fluctuation, my algorithm detects a false positive because the current distance is greater than the previous one.
I could probably change the code to get more points and check if it really started to increase or if it was just a spike. I wonder if I should try this approach or use some kind of noise filters, smoothing algorithm or any other approach?
The image shows false positives and true positives. When a real upward trend begins, I know that the object has reached the target point. My idea to get rid of false positives is to fit the curve (eg using curve_fit
from python). After that I can find when positive slope begins which tells me when object reached target.