estimator_diff
A differentiation-based filter.
This estimator is originally from Chris McKinnon. It was adapted to work with similarly to the new estimators for backwards compatability.
The filter itself is the pure function diff_correct, which the DiffFilter class jits. Quaternions are scalar last and all rotations use scipy's Rotation.
DiffData
¶
State of the differentiation-based filter.
create_empty(batch_shape=())
classmethod
¶
Create the initial state.
Source code in drone_estimators/estimator_diff.py
DiffFilter(filter_parameters, batch_shape=(), jit=True)
¶
Bases: object
Vicon state estimation and filtering.
Parameters¶
filter_parameters : sequence of floats The 5 time constants of the low pass filters, see DiffSettings batch_shape : tuple of ints The batch dimensions, e.g., (n_drones,). All arrays have leading batch dimensions. jit : bool If the filter should be jit compiled with jax.
Create the filter and compile the correction step if jit is enabled.
Source code in drone_estimators/estimator_diff.py
correct(pos, quat, mask=None)
¶
This function is not part of the original filter and only for compatability.
If given, only batch elements where mask is True are corrected.
Source code in drone_estimators/estimator_diff.py
predict(dt)
¶
This function is not part of the original filter and only for compatability.
Source code in drone_estimators/estimator_diff.py
set_state(pos, quat)
¶
This function is not part of the original filter and only for compatability.
Source code in drone_estimators/estimator_diff.py
DiffSettings
¶
Time constants of the low pass filters.
compute_numerical_derivatives(data, pos, quat, dt)
¶
Compute velocity, acceleration, and angular velocity from consecutive measurements.
Source code in drone_estimators/estimator_diff.py
diff_correct(data, settings, pos, quat, dt, mask=None)
¶
Correct the estimate with a new measurement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DiffData
|
The current state of the estimator. |
required |
settings
|
DiffSettings
|
The filter time constants. |
required |
pos
|
Array
|
The measured position. |
required |
quat
|
Array
|
The measured orientation. |
required |
dt
|
float
|
The time since the last correction. |
required |
mask
|
Array | None
|
Optional, only batch elements where mask is True are corrected. |
None
|
Returns:
| Type | Description |
|---|---|
DiffData
|
The corrected state. |
Source code in drone_estimators/estimator_diff.py
low_pass_filter(data, settings, pos, quat, dt)
¶
Move the predicted state towards the measurements and their numerical derivatives.
Each quantity moves by the fraction 1 - exp(-dt / tau) of its difference to the measurement.
Source code in drone_estimators/estimator_diff.py
prior_update(data, dt)
¶
Predict the state assuming constant acceleration and angular velocity.