nyx_space/od/kalman/
mod.rs

1/*
2    Nyx, blazing fast astrodynamics
3    Copyright (C) 2018-onwards Christopher Rabotin <christopher.rabotin@gmail.com>
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Affero General Public License as published
7    by the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
17*/
18
19pub use crate::errors::NyxError;
20use crate::linalg::allocator::Allocator;
21use crate::linalg::{DefaultAllocator, DimName};
22pub use crate::od::estimate::{Estimate, KfEstimate, Residual};
23pub use crate::od::snc::ProcessNoise;
24use crate::od::State;
25pub use crate::time::{Epoch, Unit};
26
27pub mod filtering;
28pub mod initializers;
29
30/// Defines both a Classical and an Extended Kalman filter (CKF and EKF)
31/// T: Type of state
32/// A: Acceleration size (for SNC)
33/// M: Measurement size (used for the sensitivity matrix)
34#[derive(Debug, Clone)]
35#[allow(clippy::upper_case_acronyms)]
36pub struct KalmanFilter<T, A>
37where
38    A: DimName,
39    T: State,
40    DefaultAllocator: Allocator<<T as State>::Size>
41        + Allocator<<T as State>::VecLength>
42        + Allocator<A>
43        + Allocator<<T as State>::Size, <T as State>::Size>
44        + Allocator<A, A>
45        + Allocator<<T as State>::Size, A>
46        + Allocator<A, <T as State>::Size>,
47    <DefaultAllocator as Allocator<<T as State>::Size>>::Buffer<f64>: Copy,
48    <DefaultAllocator as Allocator<<T as State>::Size, <T as State>::Size>>::Buffer<f64>: Copy,
49{
50    /// The previous estimate used in the KF computations.
51    pub prev_estimate: KfEstimate<T>,
52    /// A sets of process noise (usually noted Q), must be ordered chronologically
53    pub process_noise: Vec<ProcessNoise<A>>,
54    /// The variant of this Kalman filter.
55    pub variant: KalmanVariant,
56    pub prev_used_snc: usize,
57}
58
59#[derive(Copy, Clone, Debug, Default, PartialEq)]
60pub enum KalmanVariant {
61    /// Configures the filter as a standard Extended Kalman Filter (EKF) update,
62    /// updating the full reference state in the process' propagator at each measurement update.
63    #[default]
64    ReferenceUpdate,
65    /// Tracks the state deviation (formerly called Classical Kalman Filter (CKF)) and does not update the reference in the process' propagator.
66    DeviationTracking,
67}