Skip to content

Commit c5bd169

Browse files
Clean up documentation
1 parent c2845b4 commit c5bd169

File tree

6 files changed

+60
-22
lines changed

6 files changed

+60
-22
lines changed

Diff for: src/md/events/details.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ use core::fmt;
2727
/// Enumerates the possible edges of an event in a trajectory.
2828
///
2929
/// `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.
30-
///
31-
/// # Variants
32-
/// - `Rising` - 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.
33-
/// - `Falling` - Represents a falling edge of the event. This is the opposite of the rising edge, indicating a transition from a higher to a lower value of the event evaluator. For example, if tracking the elevation of an object, a falling edge would signify a
3430
#[derive(Copy, Clone, Debug, PartialEq)]
3531
pub enum EventEdge {
32+
/// 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.
3633
Rising,
34+
/// Represents a falling edge of the event. This is the opposite of the rising edge, indicating a transition from a higher to a lower value of the event evaluator. For example, if tracking the elevation of an object, a falling edge would signify a
3735
Falling,
36+
/// If the edge cannot be clearly defined, it will be marked as unclear. This happens if the event is at a saddle point and the epoch precision is too large to find the exact slope.
3837
Unclear,
3938
}
4039

@@ -44,11 +43,6 @@ pub enum EventEdge {
4443
///
4544
/// # Generics
4645
/// S: Interpolatable - A type that represents the state of the trajectory. This type must implement the `Interpolatable` trait, ensuring that it can be interpolated and manipulated according to the trajectory's requirements.
47-
///
48-
/// # Fields
49-
/// - `state: S` -
50-
/// - `edge: EventEdge` -
51-
/// - `value: f64` - The numerical evaluation of the event for the returned state.
5246
#[derive(Clone, Debug, PartialEq)]
5347
pub struct EventDetails<S: Interpolatable>
5448
where

Diff for: src/od/simulator/arc.rs

+52-7
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ where
5858
pub trajectory: Traj<MsrIn>,
5959
/// Configuration of each device
6060
pub configs: HashMap<String, TrkConfig>,
61-
/// Set to true to allow for overlapping measurements (enabled by default),
62-
/// i.e. if N ground stations are available at a given epoch, generate N measurements not just one.
63-
pub allow_overlap: bool,
6461
/// Random number generator used for this tracking arc, ensures repeatability
6562
rng: Pcg64Mcg,
6663
/// Greatest common denominator time series that allows this arc to meet all of the conditions.
@@ -131,7 +128,6 @@ where
131128
devices: devices_map,
132129
trajectory,
133130
configs,
134-
allow_overlap: false,
135131
rng,
136132
time_series,
137133
_msr_in: PhantomData,
@@ -290,7 +286,10 @@ impl TrackingArcSim<Orbit, RangeDoppler, GroundStation> {
290286
/// 3. Find when the vehicle trajectory has an elevation less than zero (i.e. disappears below the horizon), after that initial epoch
291287
/// 4. Repeat 2, 3 until the end of the trajectory
292288
/// 5. Build each of these as "tracking strands" for this tracking device.
293-
/// 6. THEN REMOVE OVERLAPPING MEASUREMENTS - ALGO TBD
289+
/// 6. Organize all of the built tracking strands chronologically.
290+
/// 7. Iterate through all of the strands:
291+
/// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand.
292+
/// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand.
294293
pub fn generate_schedule(
295294
&self,
296295
cosm: Arc<Cosm>,
@@ -438,7 +437,10 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
438437
/// 3. Find when the vehicle trajectory has an elevation less than zero (i.e. disappears below the horizon), after that initial epoch
439438
/// 4. Repeat 2, 3 until the end of the trajectory
440439
/// 5. Build each of these as "tracking strands" for this tracking device.
441-
/// 6. THEN REMOVE OVERLAPPING MEASUREMENTS - ALGO TBD
440+
/// 6. Organize all of the built tracking strands chronologically.
441+
/// 7. Iterate through all of the strands:
442+
/// 7.a. if that tracker is marked as `Greedy` and it ends after the start of the next strand, change the start date of the next strand.
443+
/// 7.b. if that tracker is marked as `Eager` and it ends after the start of the next strand, change the end date of the current strand.
442444
pub fn generate_schedule(
443445
&self,
444446
cosm: Arc<Cosm>,
@@ -513,7 +515,50 @@ impl TrackingArcSim<Spacecraft, RangeDoppler, GroundStation> {
513515
}
514516
}
515517
}
516-
// todo!("remove overlaps")
518+
519+
// Build all of the strands, remembering which tracker they come from.
520+
let mut cfg_as_vec = Vec::new();
521+
for (name, cfg) in &built_cfg {
522+
for (ii, strand) in cfg.strands.as_ref().unwrap().iter().enumerate() {
523+
cfg_as_vec.push((name.clone(), ii, *strand));
524+
}
525+
}
526+
// Iterate through the strands by chronological order. Cannot use maps because we change types.
527+
cfg_as_vec.sort_by_key(|(_, _, strand)| strand.start);
528+
for (ii, (this_name, this_pos, this_strand)) in
529+
cfg_as_vec.iter().take(cfg_as_vec.len() - 1).enumerate()
530+
{
531+
// Grab the config
532+
if let Some(config) = self.configs[this_name].scheduler.as_ref() {
533+
// Grab the next strand, chronologically
534+
if let Some((next_name, next_pos, next_strand)) = cfg_as_vec.get(ii + 1) {
535+
if config.handoff == Handoff::Greedy && this_strand.end >= next_strand.start {
536+
// Modify the built configurations to change the start time of the next strand because the current one is greedy.
537+
let next_config = built_cfg.get_mut(next_name).unwrap();
538+
let new_start = this_strand.end + next_config.sampling;
539+
next_config.strands.as_mut().unwrap()[*next_pos].start = new_start;
540+
info!(
541+
"{this_name} configured as {:?}, so {next_name} now starts on {new_start}",
542+
config.handoff
543+
);
544+
} else if config.handoff == Handoff::Eager
545+
&& this_strand.end >= next_strand.start
546+
{
547+
let this_config = built_cfg.get_mut(this_name).unwrap();
548+
let new_end = next_strand.start - this_config.sampling;
549+
this_config.strands.as_mut().unwrap()[*this_pos].end = new_end;
550+
info!(
551+
"{this_name} now hands off to {next_name} on {new_end} because it's configured as {:?}",
552+
config.handoff
553+
);
554+
}
555+
} else {
556+
// Reached the end
557+
break;
558+
}
559+
}
560+
}
561+
517562
Ok(built_cfg)
518563
}
519564

Diff for: src/od/simulator/scheduler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ mod scheduler_ut {
172172
let serialized = serde_yaml::to_string(&scheduler).unwrap();
173173
assert_eq!(
174174
serialized,
175-
"handoff: Eager\ncadence: !Intermittent\n on: 12 min\n off: 17 h 5 min\nmin_samples: 10\nsample_alignment: null\n"
175+
"handoff: Eager\ncadence: !Intermittent\n on: 12 min\n off: 17 h 5 min\nmin_samples: 10\nsample_alignment: 1 s\n"
176176
);
177177
let deserd: Scheduler = serde_yaml::from_str(&serialized).unwrap();
178178
assert_eq!(deserd, scheduler);

Diff for: src/od/simulator/trkconfig.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ mod trkconfig_ut {
213213
println!("{serialized}");
214214
let deserd: TrkConfig = serde_yaml::from_str(&serialized).unwrap();
215215
assert_eq!(deserd, cfg);
216-
assert_eq!(cfg.scheduler.unwrap(), Scheduler::default());
216+
assert_eq!(
217+
cfg.scheduler.unwrap(),
218+
Scheduler::builder().min_samples(10).build()
219+
);
217220
assert!(cfg.strands.is_none());
218221

219222
// Specify an intermittent schedule and a specific start epoch.

Diff for: src/python/orbit_determination/arc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ impl GroundTrackingArcSim {
4646
trajectory: TrajectoryLoader,
4747
configs: HashMap<String, TrkConfig>,
4848
seed: u64,
49-
_allow_overlap: Option<bool>,
5049
) -> Result<Self, NyxError> {
5150
// Try to convert the dynamic trajectory into a trajectory
5251
let inner = if let Ok(sc_traj) = trajectory.to_traj::<Spacecraft>() {

Diff for: tests/orbit_determination/two_body.rs

-3
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,6 @@ fn od_tb_ckf_fixed_step_iteration_test() {
644644

645645
let arc = arc_sim.generate_measurements(cosm.clone()).unwrap();
646646

647-
// Check that we have the same number of measurements as before the behavior change.
648-
// assert_eq!(arc.measurements.len(), 7954);
649-
650647
// Now that we have the truth data, let's start an OD with no noise at all and compute the estimates.
651648
// We expect the estimated orbit to be perfect since we're using strictly the same dynamics, no noise on
652649
// the measurements, and the same time step.

0 commit comments

Comments
 (0)