1use deke_types::DekeError;
2
3#[derive(Debug, thiserror::Error)]
5pub enum LinearError {
6 #[error("need at least 2 poses to define a path, got {0}")]
7 TooFewPoses(usize),
8 #[error("run {run}: every vertex coincides — nothing to follow")]
9 DegenerateRun { run: usize },
10 #[error("run {run}: Cartesian pose at arc length {s:.4} m has no reachable IK solution")]
11 Unreachable { run: usize, s: f64 },
12 #[error(
13 "run {run}: every reachable configuration at arc length {s:.4} m is rejected by the validator (obstructed)"
14 )]
15 Obstructed { run: usize, s: f64 },
16 #[error("run {run}: could not route a continuous joint track through the IK candidates")]
17 NoContinuousTrack { run: usize },
18 #[error(
19 "retimer stalled on run {run} near arc length {s:.4} m (path likely passes through a singularity)"
20 )]
21 Stalled { run: usize, s: f64 },
22 #[error(
23 "run {run}: holding constant TCP speed forbids the interior dip at arc length {s:.4} m (max feasible {feasible_speed:.4} m/s < commanded {commanded:.4} m/s)"
24 )]
25 SpeedDipRequired {
26 run: usize,
27 s: f64,
28 feasible_speed: f64,
29 commanded: f64,
30 },
31 #[error(
32 "run {run}: cannot keep joint {joint} under its {kind} limit at arc length {s:.4} m ({value:.3} > {limit:.3}) — the joint path is too curved here for the commanded speed; smooth the path or lower the speed"
33 )]
34 LimitExceeded {
35 run: usize,
36 s: f64,
37 joint: usize,
38 kind: &'static str,
40 value: f64,
41 limit: f64,
42 },
43 #[error(
44 "run {run}: cannot keep the TCP {kind} under its limit ({value:.4} > {limit:.4}) — the commanded speed is too high for the path here"
45 )]
46 TcpLimitExceeded {
47 run: usize,
48 kind: &'static str,
50 value: f64,
51 limit: f64,
52 },
53 #[error(transparent)]
54 Deke(#[from] DekeError),
55}
56
57impl From<LinearError> for DekeError {
58 fn from(e: LinearError) -> Self {
59 match e {
60 LinearError::Deke(d) => d,
61 other => DekeError::RetimerFailed(other.to_string()),
62 }
63 }
64}