Skild AI robot sensors can produce isolated spikes caused by vibration or transmission noise. Implement a causal median filter that replaces a reading when it differs too much from the recent filtered signal.
Given a list of numeric readings, an odd window_size, and an absolute threshold, process readings from left to right:
window_size output values.threshold, output the median. Otherwise, output the current reading.Return a list containing the filtered values in their original order.
readings, a list of integers or floating-point numbers; window_size, a positive odd integer; and threshold, a nonnegative number.readings.def filter_sensor_stream(readings, window_size, threshold):