Skip to main content

deke_linear/
diagnostic.rs

1use std::fmt;
2use std::time::Duration;
3
4/// Outcome of the Stage B branch-tracking plan over one run.
5#[derive(Clone, Debug)]
6pub struct LinearPlannerDiagnostic {
7    pub samples: usize,
8    pub min_manipulability: f64,
9    pub total_cost: f64,
10}
11
12impl fmt::Display for LinearPlannerDiagnostic {
13    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        write!(
15            f,
16            "planner: {} samples, min manipulability {:.3e}, route cost {:.3}",
17            self.samples, self.min_manipulability, self.total_cost
18        )
19    }
20}
21
22/// Outcome of the Stage C constant-speed retime over one run.
23#[derive(Clone, Debug)]
24pub struct LinearRetimerDiagnostic {
25    pub output_samples: usize,
26    pub duration: Duration,
27    pub arc_length: f64,
28    pub commanded_speed: f64,
29    pub peak_speed: f64,
30    /// Peak continuous per-joint acceleration `|q'·a + q''·v²|` over the run.
31    pub peak_joint_accel: f64,
32    /// Peak continuous per-joint jerk `|q'·j_s + 3·q''·a·v + q'''·v³|` over the
33    /// run. Bounded by the joint jerk limit by construction (the FD third
34    /// difference of the dt-sampled output can read higher at the jerk steps a
35    /// jerk-limited profile necessarily takes).
36    pub peak_joint_jerk: f64,
37}
38
39impl fmt::Display for LinearRetimerDiagnostic {
40    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41        write!(
42            f,
43            "retimer: {} samples over {:.3}s, {:.4}m, commanded {:.4} m/s, peak {:.4} m/s",
44            self.output_samples,
45            self.duration.as_secs_f64(),
46            self.arc_length,
47            self.commanded_speed,
48            self.peak_speed
49        )
50    }
51}
52
53/// Outcome of the redundancy-resolving (free-yaw) plan over one run.
54#[derive(Clone, Debug)]
55pub struct RedundantDiagnostic {
56    pub samples: usize,
57    pub min_manipulability: f64,
58    /// (min, max) resolved yaw about the tool axis, radians.
59    pub yaw_range: (f64, f64),
60}
61
62impl fmt::Display for RedundantDiagnostic {
63    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
64        write!(
65            f,
66            "redundant: {} samples, min manipulability {:.3e}, yaw ∈ [{:.1}°, {:.1}°]",
67            self.samples,
68            self.min_manipulability,
69            self.yaw_range.0.to_degrees(),
70            self.yaw_range.1.to_degrees()
71        )
72    }
73}