Skip to main content

rust_robotics_localization/experiments/ukf_ckf_accuracy/
sampled_bucket.rs

1use super::{AccuracyAggregationVariant, VariantDescriptor};
2
3#[derive(Debug, Clone)]
4pub struct SampledBucketAccuracyAggregation {
5    slots: Vec<usize>,
6}
7
8impl SampledBucketAccuracyAggregation {
9    pub fn new(slots: Vec<usize>) -> Self {
10        Self { slots }
11    }
12}
13
14impl AccuracyAggregationVariant for SampledBucketAccuracyAggregation {
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/ukf_ckf_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}