use nalgebra::Vector3;
use crate::{Frame, Wrench};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct LinkId {
pub(super) model_id: u64,
pub(super) index: usize,
}
impl LinkId {
pub(super) const fn new(model_id: u64, index: usize) -> Self {
Self { model_id, index }
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct IndexedLoad {
pub link: LinkId,
pub wrench: Wrench,
}
#[derive(Clone, Debug)]
pub struct Workspace {
pub(super) model_id: u64,
pub(super) joint_count: usize,
pub(super) frames: Vec<Frame>,
pub(super) angular_velocities: Vec<Vector3<f64>>,
pub(super) angular_accelerations: Vec<Vector3<f64>>,
pub(super) origin_accelerations: Vec<Vector3<f64>>,
pub(super) link_accelerations: Vec<Vector3<f64>>,
pub(super) link_loads: Vec<Wrench>,
pub(super) jacobian: Vec<f64>,
pub(super) q_work: Vec<f64>,
pub(super) step: Vec<f64>,
pub(super) ancestor_path: Vec<usize>,
}
impl Workspace {
pub(super) fn new(model_id: u64, joint_count: usize) -> Self {
Self {
model_id,
joint_count,
frames: vec![Frame::identity(); joint_count],
angular_velocities: vec![Vector3::zeros(); joint_count],
angular_accelerations: vec![Vector3::zeros(); joint_count],
origin_accelerations: vec![Vector3::zeros(); joint_count],
link_accelerations: vec![Vector3::zeros(); joint_count],
link_loads: vec![Wrench::zeros(); joint_count],
jacobian: vec![0.0; 6 * joint_count],
q_work: vec![0.0; joint_count],
step: vec![0.0; joint_count],
ancestor_path: vec![0; joint_count],
}
}
pub const fn joint_count(&self) -> usize {
self.joint_count
}
}