# File mechanics/src/joints/CouplerJointR.hpp¶

Go to the source code of this file

class CouplerJointR : public NewtonEulerJointR
#include <CouplerJointR.hpp>

This class implements a coupling (equality) between two DoFs of any NewtonEulerJointR.

Can be used e.g. to implement a screw relation (coupled rotation and translation) based on CylindricalJointR.

Public Functions

CouplerJointR()

Empty constructor.

The relation may be initialized later by setPoint, setAbsolute, and setBasePositions.

CouplerJointR(SP::NewtonEulerJointR joint1, unsigned int dof1, SP::NewtonEulerJointR joint2, unsigned int dof2, double ratio, SP::SiconosVector ref1 = SP::SiconosVector(), unsigned int ref1_index = 0, SP::SiconosVector ref2 = SP::SiconosVector(), unsigned int ref2_index = 0)

Initialize a coupler.

See setReferences() for an explanation of the parameters.

CouplerJointR(SP::NewtonEulerJointR joint1, unsigned int dof1, SP::NewtonEulerJointR joint2, unsigned int dof2, double ratio, SP::NewtonEulerDS refds1, unsigned int ref1_index, SP::NewtonEulerDS refds2, unsigned int ref2_index)

Initialize a coupler.

See setReferences() for an explanation of the parameters.

virtual ~CouplerJointR()

destructor

virtual void computeh(double time, BlockVector &q0, SiconosVector &y)
virtual void computehDoF(double time, BlockVector &q0, SiconosVector &y, unsigned int axis)

Compute the vector of linear and angular positions of the free axes.

virtual void computeJachq(double time, Interaction &inter, SP::BlockVector q0)
virtual void computeJachqDoF(double time, Interaction &inter, SP::BlockVector q0, SimpleMatrix &jachq, unsigned int axis)

Compute the jacobian of linear and angular DoF with respect to some q.

unsigned int dof1()
unsigned int dof2()
SP::NewtonEulerJointR joint1()
SP::NewtonEulerJointR joint2()
virtual unsigned int numberOfConstraints()

Get the number of constraints defined in the joint.

Return
the number of constraints

virtual unsigned int numberOfDoF()

Get the number of degrees of freedom defined in the joint.

Return
the number of degrees of freedom (DoF)

void setBasePositions(SP::SiconosVector q1, SP::SiconosVector q2 = SP::SiconosVector())

Initialize the joint constants based on the provided base positions.

Parameters
• q1: A SiconosVector of size 7 indicating translation and orientation in inertial coordinates.
• q2: An optional SiconosVector of size 7 indicating translation and orientation; if null, the inertial frame will be considered as the second base.

void setRatio(double ratio)
void setReferences(SP::NewtonEulerJointR joint1, unsigned int dof1, SP::NewtonEulerJointR joint2, unsigned int dof2, SP::SiconosVector ref1, unsigned int ref1_index, SP::SiconosVector ref2, unsigned int ref2_index)

Set reference joints and vectors.

This constraint maintains the equality theta2=theta1*ratio; theta1 is measured by joint1 with reference to some vector ref1 which must replace either the first or second DS of the current relation being defined. If ref1 and ref2 are null, then no reference is used. Typically ref1 and ref2 will be equal in order to implement gear ratios for example. joint1 must be between ref1 and ds1 specified in setBasePositions(), while joint2 must be between ref2 and ds2.

Parameters
• joint1: The joint for the first reference measurement theta1.
• dof1: The degree of freedom index of joint1 to use for the first reference measurement theta1.
• ref1: The optional reference position for the first reference measurement theta1.
• ref1_index: Must be 0 or 1, depending on where ref1 appears in joint1.
• joint2: The joint for the second reference measurement theta2.
• dof2: The degree of freedom index of joint2 to use for the second reference measurement theta2.
• ref2: The optional reference position for the second reference measurement theta2.
• ref2_index: Must be 0 or 1, depending on where ref2 appears in joint2.

void setReferences(SP::NewtonEulerJointR joint1, unsigned int dof1, SP::NewtonEulerJointR joint2, unsigned int dof2, SP::NewtonEulerDS refds1, unsigned int ref1_index, SP::NewtonEulerDS refds2, unsigned int ref2_index)

Set reference joints and vectors.

This constraint maintains the equality theta2=theta1*ratio; theta1 is measured by joint1 with reference to some vector ref1 which must replace either the first or second DS of the current relation being defined. If ref1 and ref2 are null, then no reference is used. Typically ref1 and ref2 will be equal in order to implement gear ratios for example. joint1 must be between ref1 and ds1 specified in setBasePositions(), while joint2 must be between ref2 and ds2. This alternative setReferences() takes NewtonEulerDS as parameters, but the reference vectors will be taken as refds1->q() and refds2->q() respectively.

Parameters
• joint1: The joint for the first reference measurement theta1.
• dof1: The degree of freedom index of joint1 to use for the first reference measurement theta1.
• refds1: The optional reference vector for the first reference measurement theta1.
• ref1_index: Must be 0 or 1, depending on where ref1 appears in joint1.
• joint2: The joint for the second reference measurement theta2.
• dof2: The degree of freedom index of joint2 to use for the second reference measurement theta2.
• refds2: The optional reference vector for the second reference measurement theta2.
• ref2_index: Must be 0 or 1, depending on where ref2 appears in joint2.

virtual DoF_Type typeOfDoF(unsigned int axis)

Return the type of a degree of freedom of this joint.

Return
the type of the degree of freedom (DoF)

Protected Functions

virtual void _normalDoF(SiconosVector &ans, const BlockVector &q0, int axis, bool absoluteRef = true)

Return the normal of the linear DoF axis.

Parameters
• axis: must be 0

ACCEPT_SERIALIZATION(CouplerJointR)

serialization hooks

void makeBlockVectors(SP::SiconosVector q1, SP::SiconosVector q2, BlockVector &q01, BlockVector &q02)

An internal helper function to assign reference vectors during computeh and computeJachq.

Protected Attributes

unsigned int _dof1
unsigned int _dof2
SP::NewtonEulerJointR _joint1
SP::NewtonEulerJointR _joint2
double _offset
double _ratio
SP::SiconosVector _ref1
unsigned int _ref1_index
SP::SiconosVector _ref2
unsigned int _ref2_index