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::Spacecraft;
20use crate::cosmic::AstroError;
21use crate::dynamics::guidance::GuidanceError;
22use crate::propagators::PropagationError;
23use snafu::prelude::*;
24
25pub mod prelude {
26    pub use super::{
27        StateParameter, Trajectory,
28        targeter::*,
29        trajectory::{ExportCfg, Interpolatable, Traj},
30    };
31    pub use crate::Spacecraft;
32    pub use crate::cosmic::{BPlane, BPlaneTarget, GuidanceMode, try_achieve_b_plane};
33    pub use crate::dynamics::{
34        Drag, GravityField, OrbitalDynamics, PointMasses, SolarPressure, SpacecraftDynamics,
35    };
36    pub use crate::dynamics::{Dynamics, NyxError};
37    pub use crate::io::gravity::GravityFieldData;
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::{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(
87        "correction is ineffective at {action}: value at previous iteration {prev_val}, current value: {cur_val}"
88    ))]
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 {
102        #[snafu(source(from(PropagationError, Box::new)))]
103        source: Box<PropagationError>,
104    },
105    #[snafu(display("during an optimization, encountered {source}"))]
106    TargetingTrajError { source: TrajError },
107    #[snafu(display("during an optimization targets are too close"))]
108    TargetsTooClose,
109}