iDynTree::IJoint class

Interface (i.e.

abstract class) exposed by classes that implement a Joint. A Joint is the basic representation of the motion allowed between two links.

This interface is mean to be used by kinematics and dynamics algorithm to query informations related to a joint and the relations (relative position, relative twist, relative acceleration) that it imposes to the connected links.

The design of this class is heavily inspired by the Simbody implementation of joints, as described in this article:

Seth, Ajay, et al. "Minimal formulation of joint motion for biomechanisms." Nonlinear dynamics 62.1-2 (2010): 291-303.

Other sources of inspiration are RBDL, DART and Featherstone book.

With respect to all this implementation we model the joints as undirected quantities, i.e. as object in which information can be queryied in symmetric way with respect to the attached links. This mean there is no parent and child link, but the joint is attached to two link, and the interface is agnostic with respect to which link the code considers as "parent" or "child".

Derived classes

class FixedJoint
Class representing a fixed joint, i.e.
template<unsigned int nrOfPosCoords, unsigned int nrOfDOFs>
class MovableJointImpl
Base template for implementation of non-fixed joints.

Constructors, destructors, conversion operators

~IJoint() pure virtual
Denstructor.

Public functions

auto clone() const -> IJoint* pure virtual
Clone the joint object.
auto getNrOfPosCoords() const -> unsigned int pure virtual
Get the number of coordinates used to represent the position of the joint.
auto getNrOfDOFs() const -> unsigned int pure virtual
Get the number of degrees of freedom of the joint.

Methods to set joint

Methods to set joint informations (used when building a model)

void setAttachedLinks(const LinkIndex link1, const LinkIndex link2) pure virtual
Set the two links at which the joint is attached.
void setRestTransform(const Transform& link1_X_link2) pure virtual
Set the transform between the link2 frame and link1 frame at joint position 0 (or at the identity configuration element for complex joints).
auto getFirstAttachedLink() const -> LinkIndex pure virtual
Get the first link attached to the joint.
auto getSecondAttachedLink() const -> LinkIndex pure virtual
Get the second link attached to the joint.
auto getRestTransform(const LinkIndex child, const LinkIndex parent) const -> Transform pure virtual
Get the transform between the link parent and the link child at joint position 0 (or at the identity configuration element for complex joints).
auto getTransform(const VectorDynSize& jntPos, const LinkIndex child, const LinkIndex parent) const -> const Transform& pure virtual
Get the transform between the parent and the child, such that: p_child = child_H_parent*p_parent, where p_child is a quantity expressed in the child frame, and p_parent is a quantity expressed in the parent frame.
auto getTransformDerivative(const VectorDynSize& jntPos, const LinkIndex child, const LinkIndex parent, const int posCoord_i) const -> TransformDerivative pure virtual
Get the derivative of the transform with respect to a position coordinate.
auto getMotionSubspaceVector(int dof_i, const LinkIndex child, const LinkIndex parent) const -> SpatialMotionVector pure virtual
Get the motion subspace vector corresponding to the i-th dof of the joint, i.e.
void computeChildPosVelAcc(const VectorDynSize& jntPos, const VectorDynSize& jntVel, const VectorDynSize& jntAcc, LinkPositions& linkPositions, LinkVelArray& linkVels, LinkAccArray& linkAccs, const LinkIndex child, const LinkIndex parent) const pure virtual
Compute the position, velocity and acceleration of link child, given the position, velocty and acceleration of link parent and the joint position, velocity and acceleration.
void computeChildVelAcc(const VectorDynSize& jntPos, const VectorDynSize& jntVel, const VectorDynSize& jntAcc, LinkVelArray& linkVels, LinkAccArray& linkAccs, const LinkIndex child, const LinkIndex parent) const pure virtual
Compute the velocity and acceleration of child, given the velocity and acceleration of parent and the joint position, velocity and acceleration.
void computeChildVel(const VectorDynSize& jntPos, const VectorDynSize& jntVel, LinkVelArray& linkVels, const LinkIndex child, const LinkIndex parent) const pure virtual
Compute the velocity of child, given the velocity of parent and the joint position, velocity.
void computeChildAcc(const VectorDynSize& jntPos, const VectorDynSize& jntVel, const LinkVelArray& linkVels, const VectorDynSize& jntAcc, LinkAccArray& linkAccs, const LinkIndex child, const LinkIndex parent) const pure virtual
Compute the (body-fixed) acceleration of a child link given the (body-fixed) acceleration of the parent.
void computeChildBiasAcc(const VectorDynSize& jntPos, const VectorDynSize& jntVel, const LinkVelArray& linkVels, LinkAccArray& linkBiasAccs, const LinkIndex child, const LinkIndex parent) const pure virtual
Compute the (body-fixed) bias acceleration of a child link given the (body-fixed) bias acceleration of the parent.
void computeJointTorque(const VectorDynSize& jntPos, const Wrench& internalWrench, const LinkIndex linkThatAppliesWrench, const LinkIndex linkOnWhichWrenchIsApplied, VectorDynSize& jntTorques) const pure virtual
Compute the internal torque of joint, given the internal wrench that the linkThatAppliesWrench applies on the linkOnWhichWrenchIsApplied, expressed in the link frame of the linkOnWhichWrenchIsApplied.
void setIndex(JointIndex& _index) pure virtual
Set the index of the joint in the Model Joint serialization.
auto getIndex() const -> JointIndex pure virtual
Get the index of the joint in the model Joint serialization.
void setPosCoordsOffset(const size_t _index) pure virtual
Set the offset of the position coordinates of this joint in the position coordiantes serialization of the model.
auto getPosCoordsOffset() const -> size_t pure virtual
Get the offset of the position coordinates of this joint in the position coordiantes serialization of the model.
void setDOFsOffset(const size_t _index) pure virtual
Set the offset of the coordinates of this joint in the velocity/acceleration coordiantes serialization of the model.
auto getDOFsOffset() const -> size_t pure virtual
Get the offset of the position coordinates of joint in the velocity/acceleration coordiantes serialization of the model.

Limit handling methods.

Methods for handling physical limits of joints.

The model used for limits is rather simple: a joint can have limits (being bounded) or not.

In the current version the limits are supported only for simple joints in which the velocity is the derivative of the position coordinate, and then getNrOfPosCoords() is equal to getNrOfDOFs() . The limits for such joints are specified by two constant vectors of dimension getNrOfDOFs(), the vector of minimum positions and the vector of maximum positions.

auto hasPosLimits() const -> bool pure virtual
Method to check if the joint has limits.
auto enablePosLimits(const bool enable) -> bool pure virtual
Method to set if the joint has limits.
auto getPosLimits(const size_t _index, double& min, double& max) const -> bool pure virtual
Get min and max position limits of the joint, for the _index dof.
auto getMinPosLimit(const size_t _index) const -> double pure virtual
Get the min position limit of the joint, bindings-friendly version.
auto getMaxPosLimit(const size_t _index) const -> double pure virtual
Get the max position limit of the joint, bindings-friendly version.
auto setPosLimits(const size_t _index, double min, double max) -> bool pure virtual
Set the position limits for a dof the joint.

Joint dynamics methods.

Methods for handling representation of joint dynamics.

The precise definition of "joint dynamics" is not precisely, as depending on the specific application the kind of joint dynamics model can be different, and in some case it may be even just instantaneous models (for example, when only the damping is considered).

For the type of joint dynamics supported, see the iDynTree::JointDynamicsType enum documentation.

The joint dynamics model are used in the following contexts:

  • In methods to serialize and deserialize URDF files

The joint dynamics are not used at all in classes to compute kinematics and dynamics quantities, such as iDynTree::KinDynComputations .

auto getJointDynamicsType() const -> JointDynamicsType pure virtual
Method to get the specific joint dynamics type used for the joint.
auto setJointDynamicsType(const JointDynamicsType enable) -> bool pure virtual
Method to get the specific joint dynamics type used for the joint.
auto setDamping(const size_t _index, double damping) -> bool pure virtual
Set damping parameter of the joint, for the _index dof.
auto setStaticFriction(const size_t _index, double staticFriction) -> bool pure virtual
Set static friction parameter of the joint, for the _index dof.
auto getDamping(const size_t _index) const -> double pure virtual
Get the damping coefficient of the joint.
auto getStaticFriction(const size_t _index) const -> double pure virtual
Get the static friction coefficient of the joint.

Function documentation

unsigned int iDynTree::IJoint::getNrOfPosCoords() const pure virtual

Get the number of coordinates used to represent the position of the joint.

Returns the number of position coordinates.

For joints whose configuration is in R^n, the number of position coordinates should match the number of degrees of freedom of the joint.

unsigned int iDynTree::IJoint::getNrOfDOFs() const pure virtual

Get the number of degrees of freedom of the joint.

Returns the number of degrees of freedom of the joint.

This should be a number between 0 (fixed joint) and 6 (free joint).

void iDynTree::IJoint::setAttachedLinks(const LinkIndex link1, const LinkIndex link2) pure virtual

Set the two links at which the joint is attached.

Parameters
link1 is the first link
link2 is the second link

void iDynTree::IJoint::setRestTransform(const Transform& link1_X_link2) pure virtual

Set the transform between the link2 frame and link1 frame at joint position 0 (or at the identity configuration element for complex joints).

The link1_T_link2 is transform that transforms a quantity expressed in link2 frame in a quantity expressed in the link1 frame, when the joint is in the 0 position : p_link1 = link1_T_link2*p_link2 .

Transform iDynTree::IJoint::getRestTransform(const LinkIndex child, const LinkIndex parent) const pure virtual

Get the transform between the link parent and the link child at joint position 0 (or at the identity configuration element for complex joints).

Such that: p_child = child_H_parent*p_parent where p_child is a quantity expressed in the child frame, and p_parent is a quantity expressed in the child frame.

TransformDerivative iDynTree::IJoint::getTransformDerivative(const VectorDynSize& jntPos, const LinkIndex child, const LinkIndex parent, const int posCoord_i) const pure virtual

Get the derivative of the transform with respect to a position coordinate.

In particular, if the selected position coordinate is $q$ , return the derivative:

\[ \frac{\partial {}^\texttt{child} H_\texttt{parent} }{\partial q} \]

If posCoord_i is not >= 0 and < getNrOfPosCoords(), the returned value is undefined.

SpatialMotionVector iDynTree::IJoint::getMotionSubspaceVector(int dof_i, const LinkIndex child, const LinkIndex parent) const pure virtual

Get the motion subspace vector corresponding to the i-th dof of the joint, i.e.

Returns the motion subspace vector.

the i-th column of the motion subspace matrix. The motion subspace matrix is the matrix that maps the joint velocity to the relative twist between the two links.

In particular the motion subspace vector of the i-th dof is the S vector such that v_child = S_{child,parent}*dq_i + child_X_parent*v_parent if the velocities associated to all other DOFs of the joint are considered zero, where v_child and v_parent are the left-trivialized (body) velocities of the link child and parent.

See "Modelling, Estimation and Identification of Humanoid Robots Dynamics" Silvio Traversaro - Section 3.2 https://traversaro.github.io/preprints/traversaro-phd-thesis.pdf for more details.

If dof_i is not >= 0 and < getNrOfDOFs(), the returned value is undefined.

void iDynTree::IJoint::computeChildPosVelAcc(const VectorDynSize& jntPos, const VectorDynSize& jntVel, const VectorDynSize& jntAcc, LinkPositions& linkPositions, LinkVelArray& linkVels, LinkAccArray& linkAccs, const LinkIndex child, const LinkIndex parent) const pure virtual

Compute the position, velocity and acceleration of link child, given the position, velocty and acceleration of link parent and the joint position, velocity and acceleration.

The position, velocity and acceleration of link child are directly saved in the linkPositions, linkVels and linkAccs arguments.

void iDynTree::IJoint::computeJointTorque(const VectorDynSize& jntPos, const Wrench& internalWrench, const LinkIndex linkThatAppliesWrench, const LinkIndex linkOnWhichWrenchIsApplied, VectorDynSize& jntTorques) const pure virtual

Compute the internal torque of joint, given the internal wrench that the linkThatAppliesWrench applies on the linkOnWhichWrenchIsApplied, expressed in the link frame of the linkOnWhichWrenchIsApplied.

Parameters
jntPos in vector of joint positions.
internalWrench in internal wrench that the linkThatAppliesWrench applies on the linkOnWhichWrenchIsApplied, expressed in the link frame of the linkOnWhichWrenchIsApplied
linkThatAppliesWrench in link index of the link that applies the considered internal wrench.
linkOnWhichWrenchIsApplied in link index of the link on which the considered internal wrench is applied.
jntTorques out vector of joint torques.

bool iDynTree::IJoint::hasPosLimits() const pure virtual

Method to check if the joint has limits.

Returns true if the joints has limits

bool iDynTree::IJoint::enablePosLimits(const bool enable) pure virtual

Method to set if the joint has limits.

Returns true if everything went correctly, false otherwise (for example if the joint does not support joint position limits)

bool iDynTree::IJoint::getPosLimits(const size_t _index, double& min, double& max) const pure virtual

Get min and max position limits of the joint, for the _index dof.

Parameters
_index in index of the dof for which the limit are obtained.
min
max
Returns true if everything is correct, false otherwise.

bool iDynTree::IJoint::setPosLimits(const size_t _index, double min, double max) pure virtual

Set the position limits for a dof the joint.

JointDynamicsType iDynTree::IJoint::getJointDynamicsType() const pure virtual

Method to get the specific joint dynamics type used for the joint.

Returns the specific joint dynamics type used for the joint.

bool iDynTree::IJoint::setJointDynamicsType(const JointDynamicsType enable) pure virtual

Method to get the specific joint dynamics type used for the joint.

Returns true if everything went correctly, false otherwise

bool iDynTree::IJoint::setDamping(const size_t _index, double damping) pure virtual

Set damping parameter of the joint, for the _index dof.

Parameters
_index in index of the dof for which the dynamic parameters are obtained.
damping
Returns true if everything is correct, false otherwise.

The damping coefficient is expressed in N∙s/m for a prismatic joint, N∙m∙s/rad for a revolute joint.

This parameter is considered in the following joint dynamics types:

  • URDFJointDynamics

bool iDynTree::IJoint::setStaticFriction(const size_t _index, double staticFriction) pure virtual

Set static friction parameter of the joint, for the _index dof.

Parameters
_index in index of the dof for which the dynamic parameters are obtained.
staticFriction
Returns true if everything is correct, false otherwise.

The static friction coefficient is expressed in N for a prismatic joint, N∙m for a revolute joint.

This parameter is considered in the following joint dynamics types:

  • URDFJointDynamics

double iDynTree::IJoint::getDamping(const size_t _index) const pure virtual

Get the damping coefficient of the joint.

The unit is N∙s/m for a prismatic joint, N∙m∙s/rad for a revolute joint.

This parameter is considered in the following joint dynamics types:

  • URDFJointDynamics

double iDynTree::IJoint::getStaticFriction(const size_t _index) const pure virtual

Get the static friction coefficient of the joint.

The unit is N for a prismatic joint, N∙m for a revolute joint.

This parameter is considered in the following joint dynamics types:

  • URDFJointDynamics