blob: 3bad390a9cf58b2d51052aa015fe98ade4a114a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
use crate::dynamics::RigidBodyVelocity;
use crate::math::Real;
use na::DVector;
/// A temporary workspace for various updates of the multibody.
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[derive(Clone, Debug)]
pub(crate) struct MultibodyWorkspace {
pub accs: Vec<RigidBodyVelocity>,
pub ndofs_vec: DVector<Real>,
}
impl MultibodyWorkspace {
/// Create an empty workspace.
pub fn new() -> Self {
MultibodyWorkspace {
accs: Vec::new(),
ndofs_vec: DVector::zeros(0),
}
}
/// Resize the workspace so it is enough for `nlinks` links.
pub fn resize(&mut self, nlinks: usize, ndofs: usize) {
self.accs.resize(nlinks, RigidBodyVelocity::zero());
self.ndofs_vec = DVector::zeros(ndofs)
}
}
|