rust_robotics_control/experiments/path_tracking_accuracy/
sampled_bucket.rs1use super::{TrackingAggregationVariant, VariantDescriptor};
2
3#[derive(Debug, Clone)]
4pub struct SampledBucketTrackingAggregation {
5 slots: Vec<usize>,
6}
7
8impl SampledBucketTrackingAggregation {
9 pub fn new(slots: Vec<usize>) -> Self {
10 Self { slots }
11 }
12}
13
14impl TrackingAggregationVariant for SampledBucketTrackingAggregation {
15 fn descriptor(&self) -> VariantDescriptor {
16 VariantDescriptor {
17 id: "sampled-bucket",
18 design_style: "configurable-pipeline",
19 source_path: concat!(
20 env!("CARGO_MANIFEST_DIR"),
21 "/src/experiments/path_tracking_accuracy/sampled_bucket.rs"
22 ),
23 knob_count: 1,
24 reports_dispersion: false,
25 }
26 }
27
28 fn selected_slots(&self, total_scenarios: usize) -> Vec<usize> {
29 let mut slots = self
30 .slots
31 .iter()
32 .copied()
33 .filter(|slot| *slot < total_scenarios)
34 .collect::<Vec<_>>();
35 slots.sort_unstable();
36 slots.dedup();
37 if slots.is_empty() && total_scenarios > 0 {
38 vec![0]
39 } else {
40 slots
41 }
42 }
43}