Savitzky-Golay Filter

Used to smooth out the centerline for Raceline Optimization.

from scipy.signal import savgol_filter
 
def smooth_centerline(data, window_size=11, poly_order=3):
    x_smooth = savgol_filter(data['x'], window_size, poly_order)
    y_smooth = savgol_filter(data['y'], window_size, poly_order)
    return pd.DataFrame({'x': x_smooth, 'y': y_smooth})
 
# Smoothing the centerline data
smooth_data = smooth_centerline(data)

Alternatives

  • Moving average filter: It is a simple low-pass filter that replaces each data point with the average of a window of adjacent points. Moving average filters are easy to implement and can effectively reduce noise in the signal.
  • Gaussian filter: It is a low-pass filter that applies a Gaussian kernel to the data. The Gaussian filter is particularly useful when the noise in the signal is Gaussian, and it can effectively reduce the noise without distorting the signal.
  • Median filter: It is a non-linear filter that replaces each data point with the median of a window of adjacent points. Median filters are particularly useful in removing outliers and impulsive noise from the signal.
  • Wavelet filter: It is a multi-resolution filter that uses wavelet transforms to decompose the signal into different frequency bands. Wavelet filters can effectively reduce noise while preserving the sharp features of the signal.
  • Kalman Filter