utils.data_utils
This module contains functions to compute derivatives using State Variable Filters.
derivatives_svf(data)
¶
Apply a State Variable Filter (SVF) to compute smoothed signals and their time derivatives.
Filters position, attitude (RPY), and command signals with separate
corner frequencies (6 Hz for translation, 8 Hz for rotation) and computes
up to third-order time derivatives. All output keys are prefixed with
"SVF_".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Array]
|
Dict produced by preprocessing. Must contain |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
The same dict with the following |
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
Source code in drone_models/utils/data_utils.py
preprocessing(data)
¶
Applies preprocessing to collected data.
The preprocessing includes outlier detection and interpolation, normalizing orientation (assuming hover at start), calculating rpy from quaternions, and calculating rotational error
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Array]
|
The raw data dictionary containing time [s], pos [m], quat, cmd_rpy [rad], cmd_f [N]. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Array]
|
The same dict with the following keys added or modified: |
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
dict[str, Array]
|
|
Source code in drone_models/utils/data_utils.py
state_variable_filter(y, t, f_c=1, N_deriv=2)
¶
A state variable filter that low pass filters the signal and computes the derivatives.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
Array
|
The signal to be filtered. Can be 1D (signal_length) or 2D (batch_size, signal_length). |
required |
t
|
Array
|
The time values for the signal. Optimally fixed sampling frequency. |
required |
f_c
|
float
|
Corner frequency of the filter in Hz. Defaults to 1. |
1
|
N_deriv
|
int
|
Number of derivatives to be computed. Defaults to 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
Array |
Array
|
The filtered signal and its derivatives. Shape (batch_size, N_deriv+1, signal_length). |