#![allow(non_snake_case)]
use nalgebra::{allocator::Allocator, DefaultAllocator, Dim, OMatrix, OVector, RealField};
use crate::noise::CorrelatedNoise;
pub trait Estimator<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D>,
{
fn state<'e>(&self) -> Result<OVector<N, D>, &'e str>;
}
pub trait FunctionalPredictor<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D, D> + Allocator<D>,
{
fn predict(
&mut self,
f: impl Fn(&OVector<N, D>) -> OVector<N, D>,
noise: &CorrelatedNoise<N, D>,
) -> Result<(), &str>;
}
pub trait FunctionalObserver<N: RealField, D: Dim, ZD: Dim>
where
DefaultAllocator:
Allocator<ZD, D> + Allocator<ZD, ZD> + Allocator<D> + Allocator<ZD>,
{
fn observe(
&mut self,
z: &OVector<N, ZD>,
h: impl Fn(&OVector<N, D>) -> OVector<N, ZD>,
noise: &CorrelatedNoise<N, ZD>,
) -> Result<(), &str>;
}
#[derive(PartialEq, Clone)]
pub struct KalmanState<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D, D> + Allocator<D>,
{
pub x: OVector<N, D>,
pub X: OMatrix<N, D, D>,
}
#[derive(PartialEq, Clone)]
pub struct InformationState<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D, D> + Allocator<D>,
{
pub i: OVector<N, D>,
pub I: OMatrix<N, D, D>,
}
pub trait KalmanEstimator<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D, D> + Allocator<D>,
{
fn kalman_state<'e>(&self) -> Result<KalmanState<N, D>, &'e str>;
}
pub trait ExtendedLinearPredictor<N: RealField, D: Dim>
where
DefaultAllocator: Allocator<D, D> + Allocator<D>,
{
fn predict<'e>(
&mut self,
x_pred: &OVector<N, D>,
Fx: &OMatrix<N, D, D>, noise: &CorrelatedNoise<N, D>,
) -> Result<(), &'e str>;
}
pub trait ExtendedLinearObserver<N: RealField, D: Dim, ZD: Dim>
where
DefaultAllocator: Allocator<ZD, D> + Allocator<ZD, ZD> + Allocator<ZD>,
{
fn observe_innovation<'e>(
&mut self,
s: &OVector<N, ZD>,
Hx: &OMatrix<N, ZD, D>, noise: &CorrelatedNoise<N, ZD>,
) -> Result<(), &'e str>;
}