Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orbit determination constant biases + measurement ambiguity and moduli #398

Merged
merged 13 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nyx-space"
build = "build.rs"
version = "2.0.0"
version = "2.1.0"
ChristopherRabotin marked this conversation as resolved.
Show resolved Hide resolved
edition = "2021"
authors = ["Christopher Rabotin <[email protected]>"]
description = "A high-fidelity space mission toolkit, with orbit propagation, estimation and some systems engineering"
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ For Python projects, get started by installing the library via `pip`: `pip insta

Nyx is provided under the [AGPLv3 License](./LICENSE). By using this software, you assume responsibility for adhering to the license. Refer to [the pricing page](https://nyxspace.com/pricing/?utm_source=readme-price) for an FAQ on the AGPLv3 license. Notably, any software that incorporates, links to, or depends on Nyx must also be released under the AGPLv3 license, even if you distribute an unmodified version of Nyx.

# Versioning

Nyx mostly adheres to SemVer. New patch versions should be rare. Updated dependencies trigger a new minor version. _However_ new fields in structures and new behavior may also be added with minor releases, but the public facing initializers and functions should not significantly change (but may still change).

Major releases are for dramatic changes.


[cratesio-image]: https://img.shields.io/crates/v/nyx-space.svg
[cratesio]: https://crates.io/crates/nyx-space
Expand Down
2 changes: 2 additions & 0 deletions data/tests/config/high-prec-network.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
range_noise_model:
tau: 12 h 159 ms
process_noise: 5.0e-3 # 5 m
constant: 0

doppler_noise_model:
tau: 11 h 59 min
process_noise: 50.0e-6 # 5 cm/s
constant: 0
4 changes: 4 additions & 0 deletions data/tests/config/many_ground_stations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
bias:
tau: 24 h
process_noise: 5.0e-3 # 5 m
constant: 0
doppler_km_s:
bias:
tau: 24 h
process_noise: 50.0e-6 # 5 cm/s
constant: 0
light_time_correction: false
latitude_deg: 2.3522
longitude_deg: 48.8566
Expand All @@ -37,10 +39,12 @@
bias:
tau: 24 h
process_noise: 5.0e-3 # 5 m
constant: 0
doppler_km_s:
bias:
tau: 24 h
process_noise: 50.0e-6 # 5 cm/s
constant: 0
light_time_correction: false
measurement_types:
- range_km
Expand Down
2 changes: 2 additions & 0 deletions data/tests/config/one_ground_station.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ stochastic_noises:
bias:
tau: 24 h
process_noise: 5.0e-3 # 5 m
constant: 0
doppler_km_s:
bias:
tau: 24 h
process_noise: 50.0e-6 # 5 cm/s
constant: 0
light_time_correction: false
measurement_types:
- range_km
Expand Down
3 changes: 2 additions & 1 deletion src/dynamics/guidance/ruggiero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

use anise::prelude::Almanac;
use serde::{Deserialize, Serialize};
use snafu::ResultExt;

use super::{
Expand All @@ -32,7 +33,7 @@ use std::fmt;
use std::sync::Arc;

/// Ruggiero defines the closed loop guidance law from IEPC 2011-102
#[derive(Copy, Clone, Default)]
#[derive(Copy, Clone, Default, Serialize, Deserialize)]
pub struct Ruggiero {
/// Stores the objectives
pub objectives: [Option<Objective>; 5],
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub mod cosmic;
/// Utility functions shared by different modules, and which may be useful to engineers.
pub mod utils;

mod errors;
pub mod errors;
/// Nyx will (almost) never panic and functions which may fail will return an error.
pub use self::errors::NyxError;

Expand Down
3 changes: 2 additions & 1 deletion src/mc/dispersion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
*/

use crate::md::StateParameter;
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;

/// A dispersions configuration, allows specifying min/max bounds (by default, they are not set)
#[derive(Copy, Clone, TypedBuilder)]
#[derive(Copy, Clone, TypedBuilder, Serialize, Deserialize)]
pub struct StateDispersion {
pub param: StateParameter,
#[builder(default, setter(strip_option))]
Expand Down
7 changes: 4 additions & 3 deletions src/md/events/details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ use crate::md::prelude::{Interpolatable, Traj};
use crate::md::EventEvaluator;
use crate::time::Duration;
use core::fmt;
use serde::{Deserialize, Serialize};
use std::sync::Arc;

/// Enumerates the possible edges of an event in a trajectory.
///
/// `EventEdge` is used to describe the nature of a trajectory event, particularly in terms of its temporal dynamics relative to a specified condition or threshold. This enum helps in distinguishing whether the event is occurring at a rising edge, a falling edge, or if the edge is unclear due to insufficient data or ambiguous conditions.
#[derive(Copy, Clone, Debug, PartialEq)]
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum EventEdge {
/// Represents a rising edge of the event. This indicates that the event is transitioning from a lower to a higher evaluation of the event. For example, in the context of elevation, a rising edge would indicate an increase in elevation from a lower angle.
Rising,
Expand Down Expand Up @@ -73,14 +74,14 @@ where
{
/// Generates detailed information about an event at a specific epoch in a trajectory.
///
/// This takes an `Epoch` as an input and returns a `Result<Self, NyxError>`.
/// This takes an `Epoch` as an input and returns a `Result<Self, EventError>`.
/// It is designed to determine the state of a trajectory at a given epoch, evaluate the specific event at that state, and ascertain the nature of the event (rising, falling, or unclear).
/// The initialization intelligently determines the edge type of the event by comparing the event's value at the current, previous, and next epochs.
/// It ensures robust event characterization in trajectories.
///
/// # Returns
/// - `Ok(EventDetails<S>)` if the state at the given epoch can be determined and the event details are successfully evaluated.
/// - `Err(NyxError)` if there is an error in retrieving the state at the specified epoch.
/// - `Err(EventError)` if there is an error in retrieving the state at the specified epoch.
///
pub fn new<E: EventEvaluator<S>>(
state: S,
Expand Down
16 changes: 8 additions & 8 deletions src/md/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use crate::State;
use anise::prelude::{Almanac, Frame};
use anise::structure::planetocentric::ellipsoid::Ellipsoid;
use serde::{Deserialize, Serialize};

use std::default::Default;
use std::fmt;
Expand Down Expand Up @@ -59,15 +60,14 @@
}

/// Defines a state parameter event finder
#[derive(Clone, Debug)]

#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub struct Event {
/// The state parameter
pub parameter: StateParameter,
/// The desired self.desired_value, must be in the same units as the state parameter
pub desired_value: f64,
/// The time precision after which the solver will report that it cannot find any more precise
pub epoch_precision: Unit,
/// The duration precision after which the solver will report that it cannot find any more precise
pub epoch_precision: Duration,
/// The precision on the desired value
pub value_precision: f64,
/// An optional frame in which to search this -- it IS recommended to convert the whole trajectory instead of searching in a given frame!
Expand Down Expand Up @@ -133,12 +133,12 @@
parameter: StateParameter,
desired_value: f64,
value_precision: f64,
epoch_precision: Unit,
unit_precision: Unit,
) -> Self {
Self {
parameter,
desired_value,
epoch_precision,
epoch_precision: 1 * unit_precision,
value_precision,
obs_frame: None,
}
Expand Down Expand Up @@ -166,7 +166,7 @@
Self {
parameter,
desired_value,
epoch_precision: Unit::Millisecond,
epoch_precision: Unit::Millisecond * 1,

Check warning on line 169 in src/md/events/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/md/events/mod.rs#L169

Added line #L169 was not covered by tests
value_precision: 1e-3,
obs_frame: Some(target_frame),
}
Expand All @@ -179,7 +179,7 @@
parameter: StateParameter::Periapsis,
desired_value: 0.0,
value_precision: 1e-3,
epoch_precision: Unit::Second,
epoch_precision: Unit::Second * 1,

Check warning on line 182 in src/md/events/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/md/events/mod.rs#L182

Added line #L182 was not covered by tests
obs_frame: None,
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/md/objective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

use super::StateParameter;
use crate::{errors::StateError, Spacecraft, State};
use serde::{Deserialize, Serialize};
use std::fmt;

/// Defines a state parameter event finder
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub struct Objective {
/// The state parameter to target
pub parameter: StateParameter,
Expand Down
16 changes: 16 additions & 0 deletions src/od/ground_station/trk_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,20 @@ impl TrackingDevice<Spacecraft> for GroundStation {
})?
.covariance(epoch))
}

fn measurement_bias(&self, msr_type: MeasurementType, _epoch: Epoch) -> Result<f64, ODError> {
let stochastics = self.stochastic_noises.as_ref().unwrap();

if let Some(gm) = stochastics
.get(&msr_type)
.ok_or(ODError::NoiseNotConfigured {
kind: format!("{msr_type:?}"),
})?
.bias
{
Ok(gm.constant)
} else {
Ok(0.0)
}
}
}
20 changes: 19 additions & 1 deletion src/od/msr/measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
use std::fmt;

/// A type-agnostic simultaneous measurement storage structure. Allows storing any number of simultaneous measurement of a given taker.
#[derive(Clone, Debug, PartialEq)]
///
/// Note that two measurements are considered equal if the tracker and epoch match exactly, and if both have the same measurement types,
/// and those measurements are equal to within 1e-10 (this allows for some leeway in TDM producers).
#[derive(Clone, Debug)]
pub struct Measurement {
/// Tracker alias which made this measurement
pub tracker: String,
Expand Down Expand Up @@ -58,6 +61,7 @@
where
DefaultAllocator: Allocator<S>,
{
// Consider adding a modulo modifier here, any bias should be configured by each ground station.
let mut obs = OVector::zeros();
for (i, t) in types.iter().enumerate() {
if let Some(msr_value) = self.data.get(t) {
Expand Down Expand Up @@ -91,3 +95,17 @@
write!(f, "{} measured {} on {}", self.tracker, msrs, self.epoch)
}
}

impl PartialEq for Measurement {
fn eq(&self, other: &Self) -> bool {
self.tracker == other.tracker
&& self.epoch == other.epoch
&& self.data.iter().all(|(key, &value)| {
if let Some(&other_value) = other.data.get(key) {
(value - other_value).abs() < 1e-12
ChristopherRabotin marked this conversation as resolved.
Show resolved Hide resolved
} else {
false

Check warning on line 107 in src/od/msr/measurement.rs

View check run for this annotation

Codecov / codecov/patch

src/od/msr/measurement.rs#L107

Added line #L107 was not covered by tests
}
})
}
}
Loading
Loading