From e1ea901a1e2a7470ecf422f808ffba14436c5352 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Fri, 27 Dec 2024 17:49:49 -0700 Subject: [PATCH 1/5] Add serde to underlying spacecraft data and quaternion --- anise/src/frames/frameuid.rs | 7 ++--- anise/src/math/rotation/quaternion.rs | 3 +- anise/src/structure/spacecraft/drag.rs | 3 +- anise/src/structure/spacecraft/inertia.rs | 3 +- anise/src/structure/spacecraft/mass.rs | 35 ++++++++++++----------- anise/src/structure/spacecraft/mod.rs | 2 ++ anise/src/structure/spacecraft/srp.rs | 3 +- 7 files changed, 31 insertions(+), 25 deletions(-) diff --git a/anise/src/frames/frameuid.rs b/anise/src/frames/frameuid.rs index b9e7d5f2..6fdfb6d1 100644 --- a/anise/src/frames/frameuid.rs +++ b/anise/src/frames/frameuid.rs @@ -8,6 +8,8 @@ * Documentation: https://nyxspace.com/ */ +use serde::{Deserialize, Serialize}; + use crate::{ constants::{ celestial_objects::celestial_name_from_id, orientations::orientation_name_from_id, @@ -20,10 +22,7 @@ pub use super::Frame; /// A unique frame reference that only contains enough information to build the actual Frame object. /// It cannot be used for any computations, is it be used in any structure apart from error structures. -/// -/// # Usage note -/// You should almost always prefer Frame over FrameRef unless you will -#[derive(Copy, Clone, Debug, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct FrameUid { pub ephemeris_id: NaifId, pub orientation_id: NaifId, diff --git a/anise/src/math/rotation/quaternion.rs b/anise/src/math/rotation/quaternion.rs index 3d07cb84..b125e1eb 100644 --- a/anise/src/math/rotation/quaternion.rs +++ b/anise/src/math/rotation/quaternion.rs @@ -16,6 +16,7 @@ use core::fmt; use core::ops::Mul; use der::{Decode, Encode, Reader, Writer}; use nalgebra::Matrix4x3; +use serde::{Deserialize, Serialize}; use snafu::ensure; use super::EPSILON_RAD; @@ -54,7 +55,7 @@ pub type Quaternion = EulerParameter; /// /// # Usage /// Importantly, ANISE prevents the composition of two Euler Parameters if the frames do not match. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub struct EulerParameter { pub w: f64, pub x: f64, diff --git a/anise/src/structure/spacecraft/drag.rs b/anise/src/structure/spacecraft/drag.rs index 491bd7a8..7a77c17b 100644 --- a/anise/src/structure/spacecraft/drag.rs +++ b/anise/src/structure/spacecraft/drag.rs @@ -8,8 +8,9 @@ * Documentation: https://nyxspace.com/ */ use der::{Decode, Encode, Reader, Writer}; +use serde_derive::{Deserialize, Serialize}; -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct DragData { /// Atmospheric drag area in m^2 pub area_m2: f64, diff --git a/anise/src/structure/spacecraft/inertia.rs b/anise/src/structure/spacecraft/inertia.rs index fbf7275b..3556ba4b 100644 --- a/anise/src/structure/spacecraft/inertia.rs +++ b/anise/src/structure/spacecraft/inertia.rs @@ -9,11 +9,12 @@ */ use der::{Decode, Encode, Reader, Writer}; use nalgebra::Matrix3; +use serde_derive::{Deserialize, Serialize}; use crate::NaifId; /// Inertial tensor definition -#[derive(Copy, Clone, Debug, Default, PartialEq)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct Inertia { /// Inertia tensor reference frame hash pub orientation_id: NaifId, diff --git a/anise/src/structure/spacecraft/mass.rs b/anise/src/structure/spacecraft/mass.rs index 716ee34d..686fdfd4 100644 --- a/anise/src/structure/spacecraft/mass.rs +++ b/anise/src/structure/spacecraft/mass.rs @@ -8,16 +8,17 @@ * Documentation: https://nyxspace.com/ */ use der::{Decode, Encode, Reader, Writer}; +use serde_derive::{Deserialize, Serialize}; -/// Defines a spacecraft mass a the sum of the dry (structural) mass and the fuel mass, both in kilogram -#[derive(Copy, Clone, Default, Debug, PartialEq)] +/// Defines a spacecraft mass a the sum of the dry (structural) mass and the propellant mass, both in kilogram +#[derive(Copy, Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct Mass { /// Structural mass of the spacecraft in kg pub dry_mass_kg: f64, - /// Usable fuel mass of the spacecraft in kg - pub usable_fuel_mass_kg: f64, - /// Unusable fuel mass of the spacecraft in kg - pub unusable_fuel_mass_kg: f64, + /// Usable propellant mass of the spacecraft in kg + pub usable_prop_mass_kg: f64, + /// Unusable propellant mass of the spacecraft in kg + pub unusable_prop_mass_kg: f64, } impl Mass { @@ -25,27 +26,27 @@ impl Mass { pub fn from_dry_and_fuel_masses(dry_mass_kg: f64, fuel_mass_kg: f64) -> Self { Self { dry_mass_kg, - usable_fuel_mass_kg: fuel_mass_kg, - unusable_fuel_mass_kg: 0.0, + usable_prop_mass_kg: fuel_mass_kg, + unusable_prop_mass_kg: 0.0, } } /// Returns the total mass in kg pub fn total_mass_kg(&self) -> f64 { - self.dry_mass_kg + self.usable_fuel_mass_kg + self.unusable_fuel_mass_kg + self.dry_mass_kg + self.usable_prop_mass_kg + self.unusable_prop_mass_kg } } impl Encode for Mass { fn encoded_len(&self) -> der::Result { self.dry_mass_kg.encoded_len()? - + self.usable_fuel_mass_kg.encoded_len()? - + self.unusable_fuel_mass_kg.encoded_len()? + + self.usable_prop_mass_kg.encoded_len()? + + self.unusable_prop_mass_kg.encoded_len()? } fn encode(&self, encoder: &mut impl Writer) -> der::Result<()> { self.dry_mass_kg.encode(encoder)?; - self.usable_fuel_mass_kg.encode(encoder)?; - self.unusable_fuel_mass_kg.encode(encoder) + self.usable_prop_mass_kg.encode(encoder)?; + self.unusable_prop_mass_kg.encode(encoder) } } @@ -53,8 +54,8 @@ impl<'a> Decode<'a> for Mass { fn decode>(decoder: &mut R) -> der::Result { Ok(Self { dry_mass_kg: decoder.decode()?, - usable_fuel_mass_kg: decoder.decode()?, - unusable_fuel_mass_kg: decoder.decode()?, + usable_prop_mass_kg: decoder.decode()?, + unusable_prop_mass_kg: decoder.decode()?, }) } } @@ -78,8 +79,8 @@ mod mass_ut { fn example_repr() { let repr = Mass { dry_mass_kg: 50.0, - usable_fuel_mass_kg: 15.7, - unusable_fuel_mass_kg: 0.3, + usable_prop_mass_kg: 15.7, + unusable_prop_mass_kg: 0.3, }; let mut buf = vec![]; diff --git a/anise/src/structure/spacecraft/mod.rs b/anise/src/structure/spacecraft/mod.rs index 85522d82..187e5e9e 100644 --- a/anise/src/structure/spacecraft/mod.rs +++ b/anise/src/structure/spacecraft/mod.rs @@ -22,6 +22,8 @@ pub use mass::Mass; pub use srp::SRPData; /// Spacecraft constants can store the same spacecraft constant data as the CCSDS Orbit Parameter Message (OPM) and CCSDS Attitude Parameter Messages (APM) +/// +/// Note: Spacecraft does not implement `serde` because the name is a fixed size string, which can't be serde'd trivially. #[derive(Clone, Default, Debug, PartialEq)] pub struct SpacecraftData { /// Name is used as the input for the hashing function diff --git a/anise/src/structure/spacecraft/srp.rs b/anise/src/structure/spacecraft/srp.rs index 53bdddf1..abf741ef 100644 --- a/anise/src/structure/spacecraft/srp.rs +++ b/anise/src/structure/spacecraft/srp.rs @@ -8,8 +8,9 @@ * Documentation: https://nyxspace.com/ */ use der::{Decode, Encode, Reader, Writer}; +use serde_derive::{Deserialize, Serialize}; -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct SRPData { /// Solar radiation pressure area in m^2 pub area_m2: f64, From a875225315f8c23fe55a0d5fbf124523f430e63a Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Fri, 27 Dec 2024 17:59:36 -0700 Subject: [PATCH 2/5] Add serde to spacecraft data by removing unused name. Name is moved to LUT of the dataset if needed. --- anise/src/structure/dataset/mod.rs | 4 ---- anise/src/structure/spacecraft/mod.rs | 30 ++++++--------------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/anise/src/structure/dataset/mod.rs b/anise/src/structure/dataset/mod.rs index 793dc795..4e91d80b 100644 --- a/anise/src/structure/dataset/mod.rs +++ b/anise/src/structure/dataset/mod.rs @@ -545,7 +545,6 @@ mod dataset_ut { fn spacecraft_constants_lookup() { // Build some data first. let full_sc = SpacecraftData { - name: "full spacecraft".try_into().unwrap(), srp_data: Some(SRPData { area_m2: 2.0, coeff_reflectivity: 1.8, @@ -563,7 +562,6 @@ mod dataset_ut { drag_data: Some(DragData::default()), }; let srp_sc = SpacecraftData { - name: "SRP only spacecraft".try_into().unwrap(), srp_data: Some(SRPData::default()), ..Default::default() }; @@ -690,7 +688,6 @@ mod dataset_ut { fn spacecraft_constants_lookup_builder() { // Build some data first. let full_sc = SpacecraftData { - name: "full spacecraft".try_into().unwrap(), srp_data: Some(SRPData { area_m2: 2.0, coeff_reflectivity: 1.8, @@ -708,7 +705,6 @@ mod dataset_ut { drag_data: Some(DragData::default()), }; let srp_sc = SpacecraftData { - name: "SRP only spacecraft".try_into().unwrap(), srp_data: Some(SRPData::default()), ..Default::default() }; diff --git a/anise/src/structure/spacecraft/mod.rs b/anise/src/structure/spacecraft/mod.rs index 187e5e9e..dc179864 100644 --- a/anise/src/structure/spacecraft/mod.rs +++ b/anise/src/structure/spacecraft/mod.rs @@ -7,8 +7,8 @@ * * Documentation: https://nyxspace.com/ */ -use der::{asn1::Utf8StringRef, Decode, Encode, Reader, Writer}; -use heapless::String; +use der::{Decode, Encode, Reader, Writer}; +use serde::{Deserialize, Serialize}; mod drag; mod inertia; @@ -21,13 +21,9 @@ pub use inertia::Inertia; pub use mass::Mass; pub use srp::SRPData; -/// Spacecraft constants can store the same spacecraft constant data as the CCSDS Orbit Parameter Message (OPM) and CCSDS Attitude Parameter Messages (APM) -/// -/// Note: Spacecraft does not implement `serde` because the name is a fixed size string, which can't be serde'd trivially. -#[derive(Clone, Default, Debug, PartialEq)] +/// Spacecraft constants can store the some of the spacecraft constant data as the CCSDS Orbit Parameter Message (OPM) and CCSDS Attitude Parameter Messages (APM) +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct SpacecraftData { - /// Name is used as the input for the hashing function - pub name: String<32>, /// Mass of the spacecraft in kg pub mass_kg: Option, /// Solar radiation pressure data @@ -73,8 +69,7 @@ impl SpacecraftData { impl Encode for SpacecraftData { fn encoded_len(&self) -> der::Result { let available_flags = self.available_data(); - Utf8StringRef::new(&self.name)?.encoded_len()? - + available_flags.encoded_len()? + available_flags.encoded_len()? + self.mass_kg.encoded_len()? + self.srp_data.encoded_len()? + self.drag_data.encoded_len()? @@ -82,7 +77,6 @@ impl Encode for SpacecraftData { } fn encode(&self, encoder: &mut impl Writer) -> der::Result<()> { - Utf8StringRef::new(&self.name)?.encode(encoder)?; self.available_data().encode(encoder)?; self.mass_kg.encode(encoder)?; self.srp_data.encode(encoder)?; @@ -93,8 +87,6 @@ impl Encode for SpacecraftData { impl<'a> Decode<'a> for SpacecraftData { fn decode>(decoder: &mut R) -> der::Result { - let name = decoder.decode::()?.as_str(); - let data_flags: u8 = decoder.decode()?; let mass_kg = if data_flags & (1 << 0) != 0 { @@ -122,7 +114,6 @@ impl<'a> Decode<'a> for SpacecraftData { }; Ok(Self { - name: name[..name.len().min(32)].try_into().unwrap(), mass_kg, srp_data, drag_data, @@ -137,10 +128,7 @@ mod spacecraft_constants_ut { #[test] fn sc_min_repr() { - let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), - ..Default::default() - }; + let repr = SpacecraftData::default(); let mut buf = vec![]; repr.encode_to_vec(&mut buf).unwrap(); @@ -153,7 +141,6 @@ mod spacecraft_constants_ut { #[test] fn sc_with_srp_only() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), srp_data: Some(SRPData::default()), ..Default::default() }; @@ -169,7 +156,6 @@ mod spacecraft_constants_ut { #[test] fn sc_with_drag_only() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), drag_data: Some(DragData::default()), ..Default::default() }; @@ -185,7 +171,6 @@ mod spacecraft_constants_ut { #[test] fn sc_with_mass_only() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), mass_kg: Some(Mass::default()), ..Default::default() }; @@ -201,7 +186,6 @@ mod spacecraft_constants_ut { #[test] fn sc_with_inertial_only() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), inertia: Some(Inertia::default()), ..Default::default() }; @@ -217,7 +201,6 @@ mod spacecraft_constants_ut { #[test] fn sc_with_srp_mass_inertia() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), srp_data: Some(SRPData { area_m2: 2.0, coeff_reflectivity: 1.8, @@ -246,7 +229,6 @@ mod spacecraft_constants_ut { #[test] fn sc_full() { let repr = SpacecraftData { - name: "demo spacecraft".try_into().unwrap(), srp_data: Some(SRPData { area_m2: 2.0, coeff_reflectivity: 1.8, From 0dd9ce1fc095ce12ba7998c382a3467eb197f308 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 29 Dec 2024 00:16:10 -0700 Subject: [PATCH 3/5] Update ANISE to 0.5.2 Add units to function parameters, Update GUI to egui 0.30 --- Cargo.toml | 4 +- anise-gui/Cargo.toml | 8 +-- anise/src/astro/orbit.rs | 106 +++++++++++++++++--------------- anise/src/errors.rs | 4 +- anise/tests/orientations/mod.rs | 5 +- 5 files changed, 66 insertions(+), 61 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 565addf8..a564e8b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["anise", "anise-cli", "anise-gui", "anise-py"] [workspace.package] -version = "0.5.1" +version = "0.5.2" edition = "2021" authors = ["Christopher Rabotin "] description = "ANISE provides a toolkit and files for Attitude, Navigation, Instrument, Spacecraft, and Ephemeris data. It's a modern replacement of NAIF SPICE file." @@ -45,7 +45,7 @@ pyo3-log = "0.12" numpy = "0.23" ndarray = ">= 0.15, < 0.17" -anise = { version = "0.5.1", path = "anise", default-features = false } +anise = { version = "0.5.2", path = "anise", default-features = false } [profile.bench] debug = true diff --git a/anise-gui/Cargo.toml b/anise-gui/Cargo.toml index 75ffbdc5..25e802a7 100644 --- a/anise-gui/Cargo.toml +++ b/anise-gui/Cargo.toml @@ -15,11 +15,11 @@ hifitime = { workspace = true } log = { workspace = true } bytes = { workspace = true } pretty_env_logger = { workspace = true } -eframe = { version = "0.29" } -egui = { version = "0.29" } -egui_extras = { version = "0.29", features = ["datepicker", "http", "image"] } +eframe = { version = "0.30" } +egui = { version = "0.30" } +egui_extras = { version = "0.30", features = ["datepicker", "http", "image"] } rfd = { version = "0.15.0" } -egui_logger = "0.6.1" +egui_logger = "0.6.2" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen-futures = "0.4" diff --git a/anise/src/astro/orbit.rs b/anise/src/astro/orbit.rs index e638a282..da2db388 100644 --- a/anise/src/astro/orbit.rs +++ b/anise/src/astro/orbit.rs @@ -54,12 +54,12 @@ impl Orbit { /// One should expect these errors to be on the order of 1e-12. #[allow(clippy::too_many_arguments)] pub fn try_keplerian( - sma: f64, + sma_km: f64, ecc: f64, - inc: f64, - raan: f64, - aop: f64, - ta: f64, + inc_deg: f64, + raan_deg: f64, + aop_deg: f64, + ta_deg: f64, epoch: Epoch, frame: Frame, ) -> PhysicsResult { @@ -74,14 +74,14 @@ impl Orbit { } else { ecc }; - let sma = if ecc > 1.0 && sma > 0.0 { + let sma = if ecc > 1.0 && sma_km > 0.0 { warn!("eccentricity > 1 (hyperbolic) BUT SMA > 0 (elliptical): sign of SMA changed"); - sma * -1.0 - } else if ecc < 1.0 && sma < 0.0 { + sma_km * -1.0 + } else if ecc < 1.0 && sma_km < 0.0 { warn!("eccentricity < 1 (elliptical) BUT SMA < 0 (hyperbolic): sign of SMA changed"); - sma * -1.0 + sma_km * -1.0 } else { - sma + sma_km }; if (sma * (1.0 - ecc)).abs() < 1e-3 { // GMAT errors below one meter. Let's warn for below that, but not panic, might be useful for landing scenarios? @@ -92,14 +92,14 @@ impl Orbit { ParabolicEccentricitySnafu { limit: ECC_EPSILON } ); if ecc > 1.0 { - let ta_deg = between_0_360(ta); + let ta_deg = between_0_360(ta_deg); ensure!( ta_deg <= (PI - (1.0 / ecc).acos()).to_degrees(), HyperbolicTrueAnomalySnafu { ta_deg } ); } ensure!( - (1.0 + ecc * ta.to_radians().cos()).is_finite(), + (1.0 + ecc * ta_deg.to_radians().cos()).is_finite(), InfiniteValueSnafu { action: "computing radius of orbit" } @@ -109,28 +109,28 @@ impl Orbit { // The conversion algorithm itself comes from GMAT's StateConversionUtil::ComputeKeplToCart // NOTE: GMAT supports mean anomaly instead of true anomaly, but only for backward compatibility reasons // so it isn't supported here. - let inc = inc.to_radians(); - let raan = raan.to_radians(); - let aop = aop.to_radians(); - let ta = ta.to_radians(); - let p = sma * (1.0 - ecc.powi(2)); + let inc_rad = inc_deg.to_radians(); + let raan_rad = raan_deg.to_radians(); + let aop_rad = aop_deg.to_radians(); + let ta_rad = ta_deg.to_radians(); + let p_km = sma * (1.0 - ecc.powi(2)); - ensure!(p.abs() >= f64::EPSILON, ParabolicSemiParamSnafu { p }); + ensure!(p_km.abs() >= f64::EPSILON, ParabolicSemiParamSnafu { p_km }); // NOTE: At this point GMAT computes 1+ecc**2 and checks whether it's very small. // It then reports that the radius may be too large. We've effectively already done // this check above (and panicked if needed), so it isn't repeated here. - let radius = p / (1.0 + ecc * ta.cos()); - let (sin_aop_ta, cos_aop_ta) = (aop + ta).sin_cos(); - let (sin_inc, cos_inc) = inc.sin_cos(); - let (sin_raan, cos_raan) = raan.sin_cos(); - let (sin_aop, cos_aop) = aop.sin_cos(); + let radius = p_km / (1.0 + ecc * ta_rad.cos()); + let (sin_aop_ta, cos_aop_ta) = (aop_rad + ta_rad).sin_cos(); + let (sin_inc, cos_inc) = inc_rad.sin_cos(); + let (sin_raan, cos_raan) = raan_rad.sin_cos(); + let (sin_aop, cos_aop) = aop_rad.sin_cos(); let x = radius * (cos_aop_ta * cos_raan - cos_inc * sin_aop_ta * sin_raan); let y = radius * (cos_aop_ta * sin_raan + cos_inc * sin_aop_ta * cos_raan); let z = radius * sin_aop_ta * sin_inc; - let sqrt_gm_p = (mu_km3_s2 / p).sqrt(); - let cos_ta_ecc = ta.cos() + ecc; - let sin_ta = ta.sin(); + let sqrt_gm_p = (mu_km3_s2 / p_km).sqrt(); + let cos_ta_ecc = ta_rad.cos() + ecc; + let sin_ta = ta_rad.sin(); let vx = sqrt_gm_p * cos_ta_ecc * (-sin_aop * cos_raan - cos_inc * sin_raan * cos_aop) - sqrt_gm_p * sin_ta * (cos_aop * cos_raan - cos_inc * sin_raan * sin_aop); @@ -149,31 +149,31 @@ impl Orbit { /// Attempts to create a new Orbit from the provided radii of apoapsis and periapsis, in kilometers #[allow(clippy::too_many_arguments)] pub fn try_keplerian_apsis_radii( - r_a: f64, - r_p: f64, - inc: f64, - raan: f64, - aop: f64, - ta: f64, + r_a_km: f64, + r_p_km: f64, + inc_deg: f64, + raan_deg: f64, + aop_deg: f64, + ta_deg: f64, epoch: Epoch, frame: Frame, ) -> PhysicsResult { ensure!( - r_a > f64::EPSILON, + r_a_km > f64::EPSILON, RadiusSnafu { action: "radius of apoapsis is negative" } ); ensure!( - r_p > f64::EPSILON, + r_p_km > f64::EPSILON, RadiusSnafu { action: "radius of periapsis is negative" } ); // The two checks above ensure that sma > 0 - let sma = (r_a + r_p) / 2.0; - let ecc = r_a / sma - 1.0; - Self::try_keplerian(sma, ecc, inc, raan, aop, ta, epoch, frame) + let sma = (r_a_km + r_p_km) / 2.0; + let ecc = r_a_km / sma - 1.0; + Self::try_keplerian(sma, ecc, inc_deg, raan_deg, aop_deg, ta_deg, epoch, frame) } /// Attempts to create a new Orbit around the provided frame from the borrowed state vector @@ -196,31 +196,37 @@ impl Orbit { /// One should expect these errors to be on the order of 1e-12. #[allow(clippy::too_many_arguments)] pub fn keplerian( - sma: f64, + sma_km: f64, ecc: f64, - inc: f64, - raan: f64, - aop: f64, - ta: f64, + inc_deg: f64, + raan_deg: f64, + aop_deg: f64, + ta_deg: f64, epoch: Epoch, frame: Frame, ) -> Self { - Self::try_keplerian(sma, ecc, inc, raan, aop, ta, epoch, frame).unwrap() + Self::try_keplerian( + sma_km, ecc, inc_deg, raan_deg, aop_deg, ta_deg, epoch, frame, + ) + .unwrap() } /// Creates a new Orbit from the provided radii of apoapsis and periapsis, in kilometers #[allow(clippy::too_many_arguments)] pub fn keplerian_apsis_radii( - r_a: f64, - r_p: f64, - inc: f64, - raan: f64, - aop: f64, - ta: f64, + r_a_km: f64, + r_p_km: f64, + inc_deg: f64, + raan_deg: f64, + aop_deg: f64, + ta_deg: f64, epoch: Epoch, frame: Frame, ) -> Self { - Self::try_keplerian_apsis_radii(r_a, r_p, inc, raan, aop, ta, epoch, frame).unwrap() + Self::try_keplerian_apsis_radii( + r_a_km, r_p_km, inc_deg, raan_deg, aop_deg, ta_deg, epoch, frame, + ) + .unwrap() } /// Initializes a new orbit from the Keplerian orbital elements using the mean anomaly instead of the true anomaly. diff --git a/anise/src/errors.rs b/anise/src/errors.rs index ac06182a..fab29e14 100644 --- a/anise/src/errors.rs +++ b/anise/src/errors.rs @@ -191,8 +191,8 @@ pub enum PhysicsError { }, #[snafu(display("parabolic orbits are physically impossible and the eccentricity calculated to be within {limit:e} of 1.0"))] ParabolicEccentricity { limit: f64 }, - #[snafu(display("parabolic orbits are physically impossible and the semilatus rectum (semi-parameter) calculated to be {p}"))] - ParabolicSemiParam { p: f64 }, + #[snafu(display("parabolic orbits are physically impossible and the semilatus rectum (semi-parameter) calculated to be {p_km} km"))] + ParabolicSemiParam { p_km: f64 }, #[snafu(display("hyperbolic true anomaly is physically impossible: {ta_deg} deg"))] HyperbolicTrueAnomaly { ta_deg: f64 }, #[snafu(display("calculation requires hyperbolic orbit, but its eccentricity is {ecc}"))] diff --git a/anise/tests/orientations/mod.rs b/anise/tests/orientations/mod.rs index a7e493bb..d7da2ebf 100644 --- a/anise/tests/orientations/mod.rs +++ b/anise/tests/orientations/mod.rs @@ -2,11 +2,10 @@ use std::path::PathBuf; use anise::constants::frames::{ EARTH_ITRF93, EARTH_J2000, EME2000, IAU_JUPITER_FRAME, IAU_MOON_FRAME, - JUPITER_BARYCENTER_J2000, MOON_J2000, MOON_ME_DE440_ME421_FRAME, MOON_PA_DE421_FRAME, - MOON_PA_DE440_FRAME, MOON_PA_FRAME, + JUPITER_BARYCENTER_J2000, MOON_J2000, MOON_ME_DE440_ME421_FRAME, MOON_PA_DE440_FRAME, }; use anise::constants::orientations::{ - ECLIPJ2000, IAU_JUPITER, IAU_MOON, ITRF93, J2000, MOON_PA_DE421, MOON_PA_DE440, + ECLIPJ2000, IAU_JUPITER, IAU_MOON, ITRF93, J2000, MOON_PA_DE440, }; use anise::math::rotation::DCM; use anise::math::Matrix3; From 615a39bc5dfeecc09c1b45a0f6c0a8aeddf71a09 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 29 Dec 2024 00:20:58 -0700 Subject: [PATCH 4/5] Add `0x` in front of CRC32 number, and fix checksum of moon_fk_de440.epa --- anise/src/almanac/metaload/metaalmanac.rs | 2 +- anise/src/almanac/metaload/metafile.rs | 4 ++-- data/latest.dhall | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/anise/src/almanac/metaload/metaalmanac.rs b/anise/src/almanac/metaload/metaalmanac.rs index d21b0e4e..6ffcc1a2 100644 --- a/anise/src/almanac/metaload/metaalmanac.rs +++ b/anise/src/almanac/metaload/metaalmanac.rs @@ -267,7 +267,7 @@ impl Default for MetaAlmanac { .join("v0.5/moon_fk_de440.epa") .unwrap() .to_string(), - crc32: Some(0x6f0ad74c), + crc32: Some(0x21633903), }, MetaFile { uri: nyx_cloud_stor diff --git a/anise/src/almanac/metaload/metafile.rs b/anise/src/almanac/metaload/metafile.rs index 7378ca7e..0fdc4e02 100644 --- a/anise/src/almanac/metaload/metafile.rs +++ b/anise/src/almanac/metaload/metafile.rs @@ -147,7 +147,7 @@ impl MetaFile { self.uri = dest_path_s; return Ok(()); } else { - info!("Discarding cached {dest_path_s} - CRC32 differ (got {computed_crc32:x}, expected {crc32:x})"); + info!("Discarding cached {dest_path_s} - CRC32 differ (got 0x{computed_crc32:x}, expected 0x{crc32:x})"); } } } @@ -206,7 +206,7 @@ impl MetaFile { file.write_all(&bytes).unwrap(); info!( - "Saved {url} to {} (CRC32 = {crc32:x})", + "Saved {url} to {} (CRC32 = 0x{crc32:x})", dest_path.to_str().unwrap() ); diff --git a/data/latest.dhall b/data/latest.dhall index 5ad76c57..cc66b4a3 100644 --- a/data/latest.dhall +++ b/data/latest.dhall @@ -6,7 +6,7 @@ , { crc32 = Some 0x8213b6e9 , uri = "http://public-data.nyxspace.com/anise/v0.5/pck11.pca" } - , { crc32 = Some 0x6f0ad74c + , { crc32 = Some 0x21633903 , uri = "http://public-data.nyxspace.com/anise/v0.5/moon_fk_de440.epa" } , { crc32 = Some 0xcde5ca7d From fe512a55373fd3d3c4a2610cf829fae3a019a05b Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sun, 29 Dec 2024 00:29:37 -0700 Subject: [PATCH 5/5] Fix test_from_dhall --- anise/src/almanac/metaload/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anise/src/almanac/metaload/mod.rs b/anise/src/almanac/metaload/mod.rs index e84a28dc..6aa4223d 100644 --- a/anise/src/almanac/metaload/mod.rs +++ b/anise/src/almanac/metaload/mod.rs @@ -144,7 +144,7 @@ mod meta_test { , { crc32 = Some 0x8213b6e9 , uri = "http://public-data.nyxspace.com/anise/v0.5/pck11.pca" } - , { crc32 = Some 0x6f0ad74c + , { crc32 = Some 0x21633903 , uri = "http://public-data.nyxspace.com/anise/v0.5/moon_fk_de440.epa" } , { crc32 = Some 0xcde5ca7d