nyx_space/md/
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::cosmic::AstroError;
20use crate::dynamics::guidance::GuidanceError;
21use crate::errors::NyxError;
22use crate::propagators::PropagationError;
23use crate::Spacecraft;
24use snafu::prelude::*;
25
26pub mod prelude {
27    pub use super::{
28        targeter::*,
29        trajectory::{ExportCfg, Interpolatable, Traj},
30        Event, StateParameter, Trajectory,
31    };
32    pub use crate::cosmic::{try_achieve_b_plane, BPlane, BPlaneTarget, GuidanceMode, OrbitDual};
33    pub use crate::dynamics::{
34        Drag, Harmonics, OrbitalDynamics, PointMasses, SolarPressure, SpacecraftDynamics,
35    };
36    pub use crate::dynamics::{Dynamics, NyxError};
37    pub use crate::io::gravity::HarmonicsMem;
38    pub use crate::md::objective::Objective;
39    pub use crate::propagators::{IntegratorOptions, Propagator};
40    pub use crate::time::{Duration, Epoch, TimeUnits, Unit};
41    pub use crate::Spacecraft;
42    pub use crate::{State, TimeTagged};
43
44    pub use anise::prelude::*;
45    pub use std::sync::Arc;
46}
47
48pub mod trajectory;
49
50pub(crate) mod events;
51pub use events::{Event, EventEvaluator};
52
53pub mod objective;
54pub mod opti;
55pub use opti::targeter;
56pub type Trajectory = trajectory::Traj<Spacecraft>;
57
58mod param;
59pub use param::StateParameter;
60
61pub use opti::target_variable::{Variable, Vary};
62
63use self::trajectory::TrajError;
64
65#[allow(clippy::result_large_err)]
66#[derive(Debug, Snafu)]
67#[snafu(visibility(pub(crate)))]
68pub enum TargetingError {
69    #[snafu(display(
70        "The variables to be adjusted lead to an under-determined of the problem for the targeter"
71    ))]
72    UnderdeterminedProblem,
73    /// Raised if the variables of the problem are incorrectly configured
74    #[snafu(display("Incorrectly configured variable: {msg}"))]
75    VariableError { msg: String },
76    /// Raised in case of a targeting frame error
77    #[snafu(display("Frame error in targeter: {msg}"))]
78    FrameError { msg: String },
79    /// Raised if the targeted was configured with a variable that isn't supported (e.g. a maneuver alpha variable in the multiple shooting)
80    #[snafu(display("Unsupported variable in problem: {var}"))]
81    UnsupportedVariable { var: String },
82    #[snafu(display("Verification of targeting solution failed: {msg}"))]
83    Verification { msg: String },
84    #[snafu(display("astro error during targeting: {source}"))]
85    Astro { source: AstroError },
86    #[snafu(display("targeting aborted, too many iterations"))]
87    TooManyIterations,
88    #[snafu(display("correction is ineffective at {action}: value at previous iteration {prev_val}, current value: {cur_val}"))]
89    CorrectionIneffective {
90        prev_val: f64,
91        cur_val: f64,
92        action: &'static str,
93    },
94    #[snafu(display("encountered a guidance error: {source}"))]
95    GuidanceError { source: GuidanceError },
96    #[snafu(display("not a finite burn"))]
97    NotFinite,
98    #[snafu(display("Jacobian is signular"))]
99    SingularJacobian,
100    #[snafu(display("propagation error during targeting: {source}"))]
101    PropError { source: PropagationError },
102    #[snafu(display("during an optimization, encountered {source}"))]
103    TargetingTrajError { source: TrajError },
104    #[snafu(display("during an optimization targets are too close"))]
105    TargetsTooClose,
106}