use nalgebra as na;
use thiserror::Error;
#[derive(Debug, Clone, Error)]
#[non_exhaustive]
pub enum Error {
#[error(
"joint: {} is out of limit: {}, limit = {} <=> {}",
joint_name,
position,
max_limit,
min_limit
)]
OutOfLimitError {
joint_name: String,
position: f64,
max_limit: f64,
min_limit: f64,
},
#[error("joint {} is fixed joint but the position is set", joint_name)]
SetToFixedError {
joint_name: String,
},
#[error("size mismatch input = {}, required = {}", input, required)]
SizeMismatchError {
input: usize,
required: usize,
},
#[error("mimic error from {} to {}", from, to)]
MimicError {
from: String,
to: String,
},
#[error(
"ik solve not converged tried {} times, position diff = {}, rotation diff = {}",
num_tried,
position_diff,
rotation_diff
)]
NotConvergedError {
num_tried: usize,
position_diff: na::Vector3<f64>,
rotation_diff: na::Vector3<f64>,
},
#[error("inverse matrix error")]
InverseMatrixError,
#[error(
"ik precondition error: input Dof={}, must be greater than {}",
dof,
necessary_dof
)]
PreconditionError { dof: usize, necessary_dof: usize },
#[error("There is no valid joint named {}", joint_name)]
InvalidJointNameError { joint_name: String },
}