# Filter Toolkit

### The Filter Toolkit is available here : https://www.unrealengine.com/marketplace/filter-toolkit

## Quickstart

The filter toolkit is a set of blueprints which can used to process signals. It allows us to get smoother values from a signal, and thus allows us to easily process this signal.

An example of raw signals is what we can get from the accelerometer or from the magnetometer. Using a filter allow us to have more stable values from these inputs. However, it’s not limited to this kind of use case: everytime you have a raw or unstable behavior, and you want to smooth it, then the Filter Toolkit can be used.

*Note: A basic knowledge of signal processing is advised.*

In the Filter Toolkit, all filters are designed as *Actor Components*. To start using them, you just need to add the desired filter as an *Actor* *Component* of the *Actor* whose behavior requires filtering.

Once it’s done, the parameters of the filter can be adjusted in the *Details* panel (when the component is selected).

Now, you’re ready to use the filter: just call the *GetValue* method of the filter, providing your signal as input, and get the filtered output.

More details about the different filters and the way they work is given below.

## Principle of the filters

All the filters in the Filter Toolkit are *ActorComponent*. They must be added to an actor before being used. Every filter proposes a set of parameters.

The only function of all filters is *GetValue* which takes an input (usually a float from a signal) and returns a filtered output.

The state of the filter is changing after each input, so you can’t expect the same result by calling *GetValue* two successive times.

If you are processing a temporal signal, the period between two successive calls of *GetValue* should be constant (the sampling of the input signal is supposed to be regular).

## The filters

### Low-pass threshold filter

If the difference between the current input and the last output is above a threshold (which is a parameter of the filter).

### High-pass threshold filter

If the difference between the current input and the last output is below a threshold (which is a parameter of the filter).

### Derivative filter

The output is the difference between the current input and the previous input.

### Mean filter

The output is the mean of the last N inputs where N is the size of the filter (the only parameter).

A mean filter for vectors is provided: it applies a mean filter on each component of the input vector.

### Median filter

The output is the median of the last N inputs where N is the size of the filter (the only parameter).

### Kernel filter

It works like the mean filter, except that all previous inputs are weighted according to the values in an array (the kernel).

Technically we have:

### Dynamic kernel filter

It works like the kernel filter, excepts that the *GetValue* takes two parameters: the input and the weight of this input. The jernel is then dynamically updated using the provided weights.

### IIR Filter

It is an infinite impulse response filter, according to this definition. The two parameters of this filter are the input kernel (the weights applied to the input) and the output kernel (the weights applied to the output).

## PID controller

The Filter Toolkit also contains a PID controller component. The purpose of the PID controller is to estimate the good input to apply to a system in order to have this system produce a given output. This component takes 4 parameters:

- Target: the desired output
- Kp: the proportional gain applied to the error (the difference between the target and the input)
- Ki: the integration gain applied to the error
- Kd: the derivative gain applied to the error