use crate::kinematics::differential_drive::BodyTwist;
use crate::linear_algebra::Vector;
use crate::scalar::Numeric;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Unicycle<T: Numeric = f64> {
twist: BodyTwist<T>,
}
impl<T: Numeric> Unicycle<T> {
#[inline]
pub fn new(twist: BodyTwist<T>) -> Self {
Unicycle { twist }
}
#[inline]
pub fn derivative(self, state: &Vector<3, T>) -> Vector<3, T> {
let v = self.twist.linear();
let theta = state[2];
Vector::new([v * theta.cos(), v * theta.sin(), self.twist.angular()])
}
#[inline]
pub fn field(self) -> impl Fn(T, &Vector<3, T>) -> Vector<3, T> {
move |_t, y| self.derivative(y)
}
}