pub trait RobotTorque: RobotBasic {
// Required method
fn inverse_dynamics(
&self,
q: &[f64],
dq: &[f64],
ddq: &[f64],
tau: &mut [f64],
) -> Result<(), RobotDynamicsError>;
}Expand description
Robot trait with inverse-dynamics capability.
This trait is mainly required when building COPP2/COPP3 problems with
torque/dynamics constraints. For TOPP-only use cases, a direct
Constraints workflow is usually
enough.
A usize variable can serve as a trivial RobotTorque implementation representing a point-mass model, where tau = ddq. For physical robots, users should implement this trait with their own inverse dynamics.
Required Methods§
Sourcefn inverse_dynamics(
&self,
q: &[f64],
dq: &[f64],
ddq: &[f64],
tau: &mut [f64],
) -> Result<(), RobotDynamicsError>
fn inverse_dynamics( &self, q: &[f64], dq: &[f64], ddq: &[f64], tau: &mut [f64], ) -> Result<(), RobotDynamicsError>
Evaluate inverse dynamics.
tau = M(q) * ddq + C(q, dq) * dq + g(q) + f(q, sgn(dq))
For a robot with dimension dim:
qjoint positions (dim).dq: joint velocities (dim).ddq: joint accelerations (dim).tau: output required torques/forces (dim).dq,ddq, andtauare vectors inR^dim.M(q)is the inertia/mass matrix inR^(dim x dim).C(q, dq)is the Coriolis/centrifugal matrix inR^(dim x dim). It must satisfyC(q, lambda * dq) = lambda * C(q, dq)for any scalarlambda.g(q)is the gravity torque/force vector inR^dim.f(q, sgn(dq))is the dry-friction torque/force vector inR^dim, wheresgn(dq)is interpreted element-wise. It is required thatf(q, sgn(dq))is zero ifdqis zero. An common dry-friction model is biased Coulomb friction.
Important: when implementing the sign function sgn(dq),
zero and near-zero velocities must map to 0, not to +1 or -1.
A recommended convention is to treat abs(dq[i]) <= 1e-16 as zero.
On success, write every entry of tau and return Ok(()).
The tau buffer may contain old values on entry; implementations
should overwrite it directly rather than reading or accumulating into
existing contents. If the dynamics backend cannot evaluate this state,
return Err(RobotDynamicsError::new(message)) or Err(message.into())
with a user-facing reason.
Implementations on Foreign Types§
Source§impl RobotTorque for usize
impl RobotTorque for usize
Source§fn inverse_dynamics(
&self,
_q: &[f64],
_dq: &[f64],
ddq: &[f64],
tau: &mut [f64],
) -> Result<(), RobotDynamicsError>
fn inverse_dynamics( &self, _q: &[f64], _dq: &[f64], ddq: &[f64], tau: &mut [f64], ) -> Result<(), RobotDynamicsError>
Evaluate inverse dynamics for point-mass model.
Since tau = ddq, this function copies ddq directly into tau.