nyx_space/od/process/
initializers.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
19use super::solution::kalman::KalmanVariant;
20use crate::linalg::allocator::Allocator;
21use crate::linalg::{DefaultAllocator, DimName};
22use crate::md::trajectory::Interpolatable;
23pub use crate::od::snc::*;
24pub use crate::od::*;
25use crate::propagators::Propagator;
26use anise::prelude::Almanac;
27use hifitime::Unit;
28use msr::sensitivity::TrackerSensitivity;
29use std::collections::BTreeMap;
30use std::marker::PhantomData;
31use std::ops::Add;
32
33use super::{KalmanODProcess, ResidRejectCrit};
34
35impl<
36        D: Dynamics,
37        MsrSize: DimName,
38        Accel: DimName,
39        Trk: TrackerSensitivity<D::StateType, D::StateType>,
40    > KalmanODProcess<D, MsrSize, Accel, Trk>
41where
42    D::StateType:
43        Interpolatable + Add<OVector<f64, <D::StateType as State>::Size>, Output = D::StateType>,
44    <DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
45    <DefaultAllocator as Allocator<<D::StateType as State>::Size>>::Buffer<f64>: Copy,
46    <DefaultAllocator as Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>>::Buffer<f64>: Copy,
47    DefaultAllocator: Allocator<<D::StateType as State>::Size>
48        + Allocator<<D::StateType as State>::VecLength>
49        + Allocator<MsrSize>
50        + Allocator<MsrSize, <D::StateType as State>::Size>
51        + Allocator<<D::StateType as State>::Size, MsrSize>
52        + Allocator<MsrSize, MsrSize>
53        + Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
54        + Allocator<Accel>
55        + Allocator<Accel, Accel>
56        + Allocator<<D::StateType as State>::Size, Accel>
57        + Allocator<Accel, <D::StateType as State>::Size>
58        + Allocator<nalgebra::Const<1>, MsrSize>,
59{
60    /// Initialize a new Kalman sequential filter for the orbit determination process,
61    /// setting the max step of the STM to one minute, and the measurement epoch precision to 1 microsecond.
62    pub fn new(
63        prop: Propagator<D>,
64        kf_variant: KalmanVariant,
65        resid_crit: Option<ResidRejectCrit>,
66        devices: BTreeMap<String, Trk>,
67        almanac: Arc<Almanac>,
68    ) -> Self {
69        Self {
70            prop,
71            kf_variant,
72            devices,
73            resid_crit,
74            process_noise: vec![],
75            max_step: Unit::Minute * 1,
76            epoch_precision: Unit::Microsecond * 1,
77            almanac,
78            _msr_size: PhantomData::<MsrSize>,
79        }
80    }
81
82    /// Set (or replaces) the existing process noise configuration.
83    pub fn from_process_noise(
84        prop: Propagator<D>,
85        kf_variant: KalmanVariant,
86        devices: BTreeMap<String, Trk>,
87        resid_crit: Option<ResidRejectCrit>,
88        process_noise: ProcessNoise<Accel>,
89        almanac: Arc<Almanac>,
90    ) -> Self {
91        let mut me = Self::new(
92            prop,
93            kf_variant,
94            resid_crit,
95            devices,
96            almanac
97        );
98        me.process_noise.push(process_noise);
99        me
100    }
101
102    /// Set (or replaces) the existing process noise configuration.
103    pub fn with_process_noise(mut self, process_noise: ProcessNoise<Accel>) -> Self {
104        self.process_noise.clear();
105        self.process_noise.push(process_noise);
106        self
107    }
108
109    /// Pushes the provided process noise to the list the existing process noise configurations.
110    pub fn and_with_process_noise(mut self, process_noise: ProcessNoise<Accel>) -> Self {
111        self.process_noise.push(process_noise);
112        self
113    }
114}