Skip to content
/ ccma Public

Curvature Corrected Moving Average: An accurate and model-free path smoothing algorithm.

License

Notifications You must be signed in to change notification settings

UniBwTAS/ccma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt text

❞The allure of methods guided solely by data.❞—ChatGPT

alt text

The Curvature Corrected Moving Average (CCMA) is a model-free, general-purpose smoothing algorithm designed for 2D/3D paths. It addresses the phenomenon of the inwards bending phenomenon in curves that commonly occurs with conventional moving average filters. The CCMA method employs a symmetric filtering. However, due to its symmetric approach, it primarily serves as accurate smoothing rather than state estimation.

The implementation offers a user-friendly experience (see minimal working examle), making it remarkably easy to apply filtering to given points represented as a numpy array. Users can effortlessly choose from different kernels, including truncated normal, hanning, uniform, or the sophisticated Pascal's triangle kernel (default).

Furthermore, the implementation provides different boundary behaviors—padding, wrapping, decreasing filtering width, or using no boundary strategy at all. This adaptability ensures that the implementation caters to a wide range of scenarios and preferences.

While the code itself may not provide a complete understanding, further details and insights can be found in this informative article or the original paper.

If you use the CCMA, please consider citing the original paper:

@inproceedings{Steinecker23,
  title={A Simple and Model-Free Path Filtering Algorithm for Smoothing and Accuracy},
  author={Steinecker, Thomas and Wuensche, Hans-Joachim},
  booktitle={2023 IEEE Intelligent Vehicles Symposium (IV)},
  pages={1--7},
  year={2023},
  organization={IEEE}
}

Quick Links

Minimal Working Example

import numpy as np
from ccma import CCMA

# Create noisy points on an unit circle
n = 50
noise = np.random.normal(0, 0.05, (n, 2))
points = np.array([np.cos(np.linspace(0, 2*np.pi, n)),
                   np.sin(np.linspace(0, 2*np.pi, n))]).T
noisy_points = points + noise

# Create ccma-object and smooth points by using padding (default) and Pascal's Triangle kernel/weights (default)
ccma = CCMA(w_ma=5, w_cc=3)
smoothed_points = ccma.filter(noisy_points)

Installation

To effortlessly install CCMA, utilize the following pip command:

pip3 install git+https://github.com/UniBwTAS/ccma.git#egg=ccma

or

python3 -m pip install git+https://github.com/UniBwTAS/ccma.git#egg=ccma

After a successful installation, ensure the correctness of the setup by following these steps:

  1. Open a new terminal window.

  2. Launch the Python shell:

    python
  3. Verify the installation by importing the CCMA module:

    >>> import ccma
  4. Confirm the version number to ensure a successful installation:

    >>> ccma.__version__
    "1.0.0"

HowTo Guide

Further information can be found in the HowTo Guide.

CCMA for Path Interpolation

The CCMA was designed for smoothing noisy paths; however, due to its advantageous characteristics and simple usage, we believe that it can serve many more applications, such as path interpolation. In the figure below, it becomes apparent that the CCMA, unlike the MA, reduces both overall and maximum errors. In the list of provided examples you can find an exemplary implementation of path interpolation.

alt text

Splines vs. CCMA

Splines are commonly chosen for interpolation and smoothing; however, local changes may have global impacts, leading to unexpected or undesired behavior. In contrast, the CCMA is specifically designed to be influenced only by local changes, making it a robust and predictable option. The figure below illustrates this distinction. On the left, it is evident that the CCMA is affected only in the vicinity of the outlier, while the P-Spline oscillates over its entire length. In the right plot, an additional outlier is introduced, once again affecting the CCMA locally. Conversely, the P-Spline undergoes a significant global shape change, with the previous peak increasing and the subsequent oscillations becoming more vivid.

Another noteworthy aspect is the possibility of combining the CCMA and B-Splines. This results in a continuous function, but the output is more predictable and intuitive compared to P-Splines. In the figure below, the CCMA was applied first, and the outcome was utilized for B-Spline generation. An illustrative example can also be found in the list of examples.

alt text

Interactive Example for Better Understanding

The most effective way to learn a new concept is through interaction. That's why we've incorporated an interactive example where you can experiment with different kernels and their parameters. Additionally, you have the flexibility to adjust the noise and density of the path. Finally, you can zoom in and move around, facilitating a more profound understanding. We hope you find this tool helpful.

alt text

Further Research Ideas

We believe that the CCMA can serve as a foundation for many extensions in similar or unexpected applications, as its profound methodology can already impress with good results despite its simplicity. In the following, we want to outline a few additional possible research topics related to the CCMA:

  • Improved Boundary Strategies
  • Generalization to Higher-Dimensional Data-Points
  • Generalization for Surfaces
  • Reformulation for Time-Series Data
  • Data-Driven Kernels

Star History

Star History Chart