Skip to content

Commit 0b8c6e6

Browse files
Ensure Cr is always a correct value
1 parent 69ff04f commit 0b8c6e6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/cosmic/spacecraft.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl State for Spacecraft {
497497
self.orbit.epoch = epoch;
498498
self.orbit.radius_km = radius_km;
499499
self.orbit.velocity_km_s = vel_km_s;
500-
self.srp.cr = sc_state[6];
500+
self.srp.cr = sc_state[6].clamp(0.0, 2.0);
501501
self.drag.cd = sc_state[7];
502502
self.fuel_mass_kg = sc_state[8];
503503
}
@@ -788,7 +788,7 @@ impl Add<OVector<f64, Const<9>>> for Spacecraft {
788788

789789
self.orbit.radius_km += radius_km;
790790
self.orbit.velocity_km_s += vel_km_s;
791-
self.srp.cr += other[6];
791+
self.srp.cr = (self.srp.cr + other[6]).clamp(0.0, 2.0);
792792
self.drag.cd += other[7];
793793
self.fuel_mass_kg += other[8];
794794

tests/orbit_determination/spacecraft.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,8 @@ fn od_val_sc_srp_estimation(
446446
assert!(delta.rmag_km() < 1e-3, "More than 1 meter error");
447447
assert!(delta.vmag_km_s() < 1e-6, "More than 1 millimeter/s error");
448448
assert!(
449-
(est.state().srp.cr - truth_cr).abs() < 0.377,
450-
"Cr estimation did not decrease"
449+
(est.state().srp.cr - truth_cr).abs() < 0.038,
450+
"Cr estimation worst than expected"
451451
);
452452

453453
for (no, est) in odp.estimates.iter().enumerate() {

0 commit comments

Comments
 (0)