rust_robotics_mapping/experiments/point_cloud_sampling_quality/
percentile_bucket.rs1use super::{PointSamplingAggregationVariant, VariantDescriptor};
2
3#[derive(Debug, Clone)]
4pub struct PercentileBucketPointSamplingAggregation {
5 percentiles: Vec<f64>,
6}
7
8impl PercentileBucketPointSamplingAggregation {
9 pub fn new(percentiles: Vec<f64>) -> Self {
10 Self { percentiles }
11 }
12}
13
14impl PointSamplingAggregationVariant for PercentileBucketPointSamplingAggregation {
15 fn descriptor(&self) -> VariantDescriptor {
16 VariantDescriptor {
17 id: "percentile-bucket",
18 design_style: "percentile-spread",
19 source_path: concat!(
20 env!("CARGO_MANIFEST_DIR"),
21 "/src/experiments/point_cloud_sampling_quality/percentile_bucket.rs"
22 ),
23 knob_count: 1,
24 reports_dispersion: true,
25 }
26 }
27
28 fn selected_slots(&self, total_scenarios: usize) -> Vec<usize> {
29 if total_scenarios == 0 {
30 return Vec::new();
31 }
32
33 let last = total_scenarios.saturating_sub(1) as f64;
34 let mut slots = self
35 .percentiles
36 .iter()
37 .map(|percentile| (percentile.clamp(0.0, 1.0) * last).round() as usize)
38 .collect::<Vec<_>>();
39 slots.sort_unstable();
40 slots.dedup();
41 slots
42 }
43}