use std::fmt;
use std::time::Duration;
#[derive(Clone, Debug)]
pub struct LinearPlannerDiagnostic {
pub samples: usize,
pub min_manipulability: f64,
pub total_cost: f64,
}
impl fmt::Display for LinearPlannerDiagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"planner: {} samples, min manipulability {:.3e}, route cost {:.3}",
self.samples, self.min_manipulability, self.total_cost
)
}
}
#[derive(Clone, Debug)]
pub struct LinearRetimerDiagnostic {
pub output_samples: usize,
pub duration: Duration,
pub arc_length: f64,
pub commanded_speed: f64,
pub peak_speed: f64,
}
impl fmt::Display for LinearRetimerDiagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"retimer: {} samples over {:.3}s, {:.4}m, commanded {:.4} m/s, peak {:.4} m/s",
self.output_samples,
self.duration.as_secs_f64(),
self.arc_length,
self.commanded_speed,
self.peak_speed
)
}
}
#[derive(Clone, Debug)]
pub struct RedundantDiagnostic {
pub samples: usize,
pub min_manipulability: f64,
pub yaw_range: (f64, f64),
}
impl fmt::Display for RedundantDiagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"redundant: {} samples, min manipulability {:.3e}, yaw ∈ [{:.1}°, {:.1}°]",
self.samples,
self.min_manipulability,
self.yaw_range.0.to_degrees(),
self.yaw_range.1.to_degrees()
)
}
}
#[derive(Clone, Debug, Default)]
pub struct LinearFollowDiagnostic {
pub runs: usize,
pub planner: Vec<LinearPlannerDiagnostic>,
pub redundant: Vec<RedundantDiagnostic>,
pub retimer: Vec<LinearRetimerDiagnostic>,
pub total_samples: usize,
pub total_duration: Duration,
}
impl fmt::Display for LinearFollowDiagnostic {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"follow: {} run(s), {} samples, {:.3}s total",
self.runs,
self.total_samples,
self.total_duration.as_secs_f64()
)
}
}