Skip to main content

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