Skip to main content

nyx_space/od/
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
19use crate::dynamics::DynamicsError;
20pub use crate::dynamics::{Dynamics, NyxError};
21use crate::errors::StateError;
22use crate::io::{ConfigError, InputOutputError};
23use crate::linalg::OVector;
24use crate::md::prelude::SpacecraftDynamics;
25use crate::md::trajectory::TrajError;
26use crate::propagators::PropagationError;
27use crate::time::Epoch;
28pub use crate::{State, TimeTagged};
29use anise::almanac::planetary::PlanetaryDataError;
30use anise::errors::AlmanacError;
31use hifitime::Duration;
32use snafu::prelude::Snafu;
33use std::sync::Arc;
34
35pub mod kalman;
36
37/// Provides a range and range rate measuring models.
38mod ground_station;
39pub use ground_station::GroundStation;
40
41/// Provides Estimate handling functionalities.
42pub mod estimate;
43
44/// Provides noise modeling
45pub mod noise;
46
47/// Provides all of the support measurement models
48pub mod msr;
49
50/// Provides all of the functionality to simulate measurements from ground stations
51pub mod simulator;
52
53/// Provides the interfaces to the orbit determination process
54pub mod process;
55
56pub use simulator::TrackingDevice;
57
58/// Provides all state noise compensation functionality
59pub mod snc;
60
61/// Provides the Batch least squares initial state solver.
62pub mod blse;
63
64#[cfg(feature = "premium")]
65pub mod interlink;
66
67#[cfg(feature = "premium")]
68pub mod groundpnt;
69
70/// A helper type for spacecraft orbit determination.
71pub type SpacecraftKalmanOD = self::process::KalmanODProcess<
72    SpacecraftDynamics,
73    nalgebra::Const<2>,
74    nalgebra::Const<3>,
75    GroundStation,
76>;
77
78/// A helper type for spacecraft orbit determination sequentially processing measurements
79pub type SpacecraftKalmanScalarOD = self::process::KalmanODProcess<
80    SpacecraftDynamics,
81    nalgebra::Const<1>,
82    nalgebra::Const<3>,
83    GroundStation,
84>;
85
86/// A helper type for spacecraft to spacecraft orbit determination.
87#[cfg(feature = "premium")]
88pub type InterlinkKalmanOD = self::process::KalmanODProcess<
89    SpacecraftDynamics,
90    nalgebra::Const<2>,
91    nalgebra::Const<3>,
92    interlink::InterlinkTxSpacecraft,
93>;
94
95#[allow(unused_imports)]
96pub mod prelude {
97    pub use super::estimate::*;
98    pub use super::ground_station::*;
99    pub use super::kalman::KalmanVariant;
100    pub use super::kalman::*;
101    pub use super::msr::*;
102    pub use super::noise::{GaussMarkov, StochasticNoise, WhiteNoise};
103    pub use super::process::*;
104    pub use super::simulator::TrackingArcSim;
105    pub use super::simulator::*;
106    pub use super::snc::*;
107    pub use super::*;
108
109    pub use crate::time::{Duration, Epoch, TimeUnits, Unit};
110}
111
112#[derive(Debug, PartialEq, Snafu)]
113#[snafu(visibility(pub(crate)))]
114pub enum ODError {
115    #[snafu(display("during an orbit determination, encountered {source}"))]
116    ODPropError { source: PropagationError },
117    #[snafu(display("during an orbit determination, encountered {source}"))]
118    ODDynamicsError { source: DynamicsError },
119    #[snafu(display("at least {need} measurements required for {action}"))]
120    TooFewMeasurements { need: usize, action: &'static str },
121    #[snafu(display("invalid step size: {step}"))]
122    StepSizeError { step: Duration },
123    #[snafu(display("filter iteration did not converge in {loops} iterations"))]
124    Diverged { loops: usize },
125    #[snafu(display("STM is singular"))]
126    SingularStateTransitionMatrix,
127    #[snafu(display("invalid measurement @ {epoch} = {val}"))]
128    InvalidMeasurement { epoch: Epoch, val: f64 },
129    #[snafu(display("Kalman gain is singular"))]
130    SingularKalmanGain,
131    #[snafu(display("Information matrix is singular"))]
132    SingularInformationMatrix,
133    #[snafu(display("noise matrix is singular"))]
134    SingularNoiseRk,
135    #[snafu(display("{kind} noise not configured"))]
136    NoiseNotConfigured { kind: String },
137    #[snafu(display("measurement sim error: {details}"))]
138    MeasurementSimError { details: String },
139    #[snafu(display("during an OD encountered {source}: {details}"))]
140    ODTrajError { source: TrajError, details: String },
141    #[snafu(display("OD failed because {source}"))]
142    ODConfigError { source: ConfigError },
143    #[snafu(display("OD failed because of an I/O error: {source}"))]
144    ODIOError { source: InputOutputError },
145    #[snafu(display("OD failed due to Almanac: {action} {source}"))]
146    ODAlmanac {
147        #[snafu(source(from(AlmanacError, Box::new)))]
148        source: Box<AlmanacError>,
149        action: &'static str,
150    },
151    #[snafu(display("OD failed due to planetary data in Almanac: {action} {source}"))]
152    ODPlanetaryData {
153        #[snafu(source(from(PlanetaryDataError, Box::new)))]
154        source: Box<PlanetaryDataError>,
155        action: &'static str,
156    },
157    #[snafu(display("not enough residuals to {action}"))]
158    ODNoResiduals { action: &'static str },
159    #[snafu(display("could not {action} OD results: {source}"))]
160    ODStateError {
161        #[snafu(source(from(StateError, Box::new)))]
162        source: Box<StateError>,
163        action: &'static str,
164    },
165    #[snafu(display("Maximum iterations ({max_iter}) reached without convergence"))]
166    ODMaxIterations { max_iter: usize },
167    #[snafu(display("Nyx orbit determination limitation: {action}"))]
168    ODLimitation { action: &'static str },
169}