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};
22use crate::od::State;
23pub use crate::od::estimate::{Estimate, KfEstimate, Residual};
24pub use crate::od::snc::ProcessNoise;
25pub use crate::time::{Epoch, Unit};
26
27pub mod filtering;
28pub mod initializers;
29
30#[cfg(feature = "python")]
31use pyo3::prelude::*;
32
33/// Defines both a Classical and an Extended Kalman filter (CKF and EKF)
34/// T: Type of state
35/// A: Acceleration size (for SNC)
36/// M: Measurement size (used for the sensitivity matrix)
37#[derive(Debug, Clone)]
38#[allow(clippy::upper_case_acronyms)]
39pub struct KalmanFilter<T, A>
40where
41 A: DimName,
42 T: State,
43 DefaultAllocator: Allocator<<T as State>::Size>
44 + Allocator<<T as State>::VecLength>
45 + Allocator<A>
46 + Allocator<<T as State>::Size, <T as State>::Size>
47 + Allocator<A, A>
48 + Allocator<<T as State>::Size, A>
49 + Allocator<A, <T as State>::Size>,
50 <DefaultAllocator as Allocator<<T as State>::Size>>::Buffer<f64>: Copy,
51 <DefaultAllocator as Allocator<<T as State>::Size, <T as State>::Size>>::Buffer<f64>: Copy,
52{
53 /// The previous estimate used in the KF computations.
54 pub prev_estimate: KfEstimate<T>,
55 /// A sets of process noise (usually noted Q), must be ordered chronologically
56 pub process_noise: Vec<ProcessNoise<A>>,
57 /// The variant of this Kalman filter.
58 pub variant: KalmanVariant,
59 pub prev_used_snc: usize,
60}
61
62#[derive(Copy, Clone, Debug, Default, PartialEq)]
63#[cfg_attr(feature = "python", pyclass(from_py_object))]
64pub enum KalmanVariant {
65 /// Configures the filter as a standard Extended Kalman Filter (EKF) update,
66 /// updating the full reference state in the process' propagator at each measurement update.
67 #[default]
68 ReferenceUpdate,
69 /// Tracks the state deviation (formerly called Classical Kalman Filter (CKF)) and does not update the reference in the process' propagator.
70 DeviationTracking,
71}