1use std::{
2 convert::Infallible,
3 fmt::{Debug, Display},
4};
5
6pub use glam;
7pub use wide;
8
9mod fk;
10mod fk_dynamic;
11mod path;
12mod q;
13mod validator;
14mod validator_dynamic;
15
16pub use fk::{
17 DHChain, DHJoint, FKChain, HPChain, HPJoint, PrismaticFK, TransformedFK, URDFChain, URDFJoint,
18};
19pub use fk_dynamic::{BoxFK, DynamicDHChain, DynamicHPChain, DynamicURDFChain};
20pub use path::{RobotPath, SRobotPath};
21pub use q::{RobotQ, SRobotQ, robotq, SRobotQLike};
22pub use validator::{JointValidator, Validator, ValidatorAnd, ValidatorNot, ValidatorOr};
23pub use validator_dynamic::DynamicJointValidator;
24
25#[derive(Debug, Clone, thiserror::Error)]
26pub enum DekeError {
27 #[error("Expected {expected} joints, but found {found}")]
28 ShapeMismatch { expected: usize, found: usize },
29 #[error("Path has {0} waypoints, needs at least 2")]
30 PathTooShort(usize),
31 #[error("Joints contain non-finite values")]
32 JointsNonFinite,
33 #[error("Self-collision detected between joints {0} and {1}")]
34 SelfCollision(i16, i16),
35 #[error("Environment collision detected between joint {0} and object {1}")]
36 EnvironmentCollision(i16, i16),
37 #[error("Joints exceed their limits")]
38 ExceedJointLimits,
39 #[error("Out of iterations")]
40 OutOfIterations,
41 #[error("Super error")]
42 SuperError,
43}
44
45impl From<Infallible> for DekeError {
46 fn from(_: Infallible) -> Self {
47 unreachable!()
48 }
49}
50
51pub type DekeResult<T> = Result<T, DekeError>;
52
53pub trait Planner<const N: usize>: Sized + Clone + Debug + Send + Sync + 'static {
54 type Diagnostic: Display + Send + Sync;
55
56 fn plan<
57 E: Into<DekeError>,
58 A: SRobotQLike<N, E>,
59 B: SRobotQLike<N, E>,
60 >(
61 &self,
62 start: A,
63 goal: B,
64 validators: &mut impl Validator<N>,
65 ) -> (DekeResult<SRobotPath<N>>, Self::Diagnostic);
66}