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

Cartesian state's add_unchecked does not set the frame correctly #250

Closed
ChristopherRabotin opened this issue May 28, 2024 · 0 comments · Fixed by #258
Closed

Cartesian state's add_unchecked does not set the frame correctly #250

ChristopherRabotin opened this issue May 28, 2024 · 0 comments · Fixed by #258
Labels
Kind: bug Something isn't working Status: WIP

Comments

@ChristopherRabotin
Copy link
Member

Bug report

Describe the bug

As part of nyx-space/nyx#86, I'm testing the spacecraft trajectory conversions. In the traj_spacecraft test, I convert a spacecraft propagated in the EME2000 frame to the Moon frame and back again into the EME2000 frame. The returned value is obviously wrong indicating that the round-trip frame translation in Earth/Moon J2000 adds E-M vector.

left: Spacecraft { orbit: CartesianState { radius_km: [[-7273.342668443073, 253.99072179207016, 0.022164871880207732]], velocity_km_s: [[-0.2582852231926599, -7.396321042416258, -0.0006454507752619773]], epoch: 2021-01-01T12:00:00 UTC, frame: Frame { ephemeris_id: 399, orientation_id: 1, mu_km3_s2: Some(398600.435436096), shape: Some(Ellipsoid { semi_major_equatorial_radius_km: 6378.14, semi_minor_equatorial_radius_km: 6378.14, polar_radius_km: 6356.75 }) } }, dry_mass_kg: 300.0, fuel_mass_kg: 67.0, srp: SrpConfig { area_m2: 0.0, cr: 1.8 }, drag: DragConfig { area_m2: 0.0, cd: 2.2 }, thruster: Some(Thruster { thrust_N: 0.089, isp_s: 1650.0 }), mode: Thrust, stm: None }

right: Spacecraft { orbit: CartesianState { radius_km: [[234377.09135147667, -262800.33219000406, -143205.15698775538]], velocity_km_s: [[0.5099871196829026, -6.7531442107201975, 0.21484133260643304]], epoch: 2021-01-01T12:00:00 UTC, frame: Frame { ephemeris_id: 399, orientation_id: 1, mu_km3_s2: Some(398600.435436096), shape: Some(Ellipsoid { semi_major_equatorial_radius_km: 6378.14, semi_minor_equatorial_radius_km: 6378.14, polar_radius_km: 6356.75 }) } }, dry_mass_kg: 300.0, fuel_mass_kg: 67.0, srp: SrpConfig { area_m2: 0.0, cr: 1.8 }, drag: DragConfig { area_m2: 0.0, cd: 2.2 }, thruster: Some(Thruster { thrust_N: 0.089, isp_s: 1650.0 }), mode: Thrust, stm: None }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After some digging, it was quickly obvious that the add_unchecked function does not set the frame. Therefore, a round trip using translate_to or transform_to will be incorrect!

To Reproduce

  1. Checkout the Nyx repo on the correct branch
  2. Run cargo test --release traj_spacecraft
  3. Test fails

Expected behavior

Round trip conversions should always work all the time.

Platform

Linux, Rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind: bug Something isn't working Status: WIP
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant