26LoopConstraint::LoopConstraint():
28 std::numeric_limits<unsigned int>::max()){}
33 const unsigned int bodyIdPredecessor,
34 const unsigned int bodyIdSuccessor,
38 bool enableBaumgarteStabilization,
39 double stabilizationTimeConstant,
40 const char *loopConstraintName,
41 unsigned int userDefinedIdNumber,
42 bool positionLevelConstraint,
43 bool velocityLevelConstraint):
50 T.push_back(constraintAxis);
51 dblA = std::numeric_limits<double>::epsilon()*10.;
52#ifndef RBDL_USE_CASADI_MATH
59 bodyIds.push_back(bodyIdPredecessor);
60 bodyIds.push_back(bodyIdSuccessor);
89 bool updateKinematics)
129 bool updateKinematics)
181 bool updateKinematics)
245 bool updateKinematics)
258 for(
unsigned int j=0; j<GSys.
cols();++j){
276 std::vector< unsigned int > &constraintBodiesUpd,
277 std::vector< Math::SpatialTransform > &constraintBodyFramesUpd,
278 std::vector< Math::SpatialVector > &constraintForcesUpd,
280 bool resolveAllInRootFrame,
281 bool updateKinematics)
283 constraintBodiesUpd.resize(2);
284 constraintBodyFramesUpd.resize(2);
295 constraintForcesUpd.resize(2);
296 constraintForcesUpd[0].setZero();
297 constraintForcesUpd[1].setZero();
302 cache.
svecB.setZero();
308 constraintBodiesUpd.
resize(2);
309 constraintBodyFramesUpd.resize(2);
311 if(resolveAllInRootFrame){
312 constraintBodiesUpd[0] = 0;
313 constraintBodiesUpd[1] = 0;
317 constraintBodyFramesUpd[0].r = cache.
stA.
r;
318 constraintBodyFramesUpd[0].E.Identity();
320 constraintBodyFramesUpd[1].r = cache.
stB.
r;
321 constraintBodyFramesUpd[1].E.Identity();
324 constraintForcesUpd[0] = -cache.
svecB;
325 constraintForcesUpd[1] = cache.
svecB;
332 constraintForcesUpd[0].block(0,0,3,1) = -cache.
stA.
E.transpose()
333 *cache.
svecB.block(0,0,3,1);
334 constraintForcesUpd[0].block(3,0,3,1) = -cache.
stA.
E.transpose()
335 *cache.
svecB.block(3,0,3,1);
338 constraintForcesUpd[1].block(0,0,3,1) = cache.
stB.
E.transpose()
339 *cache.
svecB.block(0,0,3,1);
340 constraintForcesUpd[1].block(3,0,3,1) = cache.
stB.
E.transpose()
341 *cache.
svecB.block(3,0,3,1);
353 bool positionLevelConstraint,
354 bool velocityLevelConstraint)
357 dblA = 10.0*std::numeric_limits<double>::epsilon();
360#ifndef RBDL_USE_CASADI_MATH
367 T.push_back(constraintAxis);
372 assert(sizeOfConstraint <= 6 && sizeOfConstraint > 0);
MX_Xd_dynamic & setZero()
unsigned int cols() const
void resize(unsigned int newI, unsigned int newJ=1)
MX_Xd_SubMatrix block(unsigned int row_start, unsigned int col_start)
Interface to define general-purpose constraints.
void setEnableBaumgarteStabilization(bool flagEnableBaumgarteStabilization)
void setBaumgarteTimeConstant(double tStab)
Calculates and sets the Baumgarte stabilization coefficients as a function of tStab,...
std::vector< Math::SpatialTransform > bodyFrames
Transform from the frame of the predecessor body to the constraint frame.
unsigned int rowInSystem
The first row in G that corresponds to this constraint.
std::vector< bool > positionConstraint
unsigned int sizeOfConstraint
The number of rows that this constraint adds to G.
std::vector< unsigned int > bodyIds
The index of the predecessor body in the vector of bodies in Model.
std::vector< bool > velocityConstraint
void calcPositionError(Model &model, const double time, const Math::VectorNd &Q, Math::VectorNd &errSysUpd, ConstraintCache &cache, bool updateKinematics=false) override
In this function the sub vector of this constraint is inserted into the position error vector of the...
double dblA
A local working double.
void bind(const Model &model) override
Any local memory that has a dimension of N, where N is the length of QDot, is resized in this functio...
void calcGamma(Model &model, const double time, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::MatrixNd &GSys, Math::VectorNd &gammaSysUpd, ConstraintCache &cache, bool updateKinematics=false) override
In this function the vector of this constraint is inserted into the right-hand-side vector of the s...
std::vector< Math::SpatialVector > T
Vector of constraint axis resolved in the predecessor frame.
void calcConstraintForces(Model &model, const double time, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::MatrixNd &GSys, const Math::VectorNd &lagrangeMultipliersSys, std::vector< unsigned int > &constraintBodiesUpd, std::vector< Math::SpatialTransform > &constraintBodyFramesUpd, std::vector< Math::SpatialVector > &constraintForcesUpd, ConstraintCache &cache, bool resolveAllInRootFrame=false, bool updateKinematics=false) override
This function resolves the generalized forces this constraint applies to the system into the wrenches...
void calcConstraintJacobian(Model &model, const double time, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::MatrixNd &GSysUpd, ConstraintCache &cache, bool updateKinematics=false) override
In this function the matrix of this contraint is inserted into the system constraint Jacobian (GSys...
void calcVelocityError(Model &model, const double time, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::MatrixNd &GSys, Math::VectorNd &derrSysUpd, ConstraintCache &cache, bool updateKinematics=false) override
In this function the sub vector of this constraint is inserted into the position error vector of the...
void appendConstraintAxis(const Math::SpatialVector &constraintAxis, bool positionLevelConstraint=true, bool velocityLevelConstraint=true)
RBDL_DLLAPI Matrix3d CalcBodyWorldOrientation(Model &model, const VectorNd &Q, const unsigned int body_id, bool update_kinematics)
Returns the orientation of a given body as 3x3 matrix.
RBDL_DLLAPI void CalcPointJacobian6D(Model &model, const VectorNd &Q, unsigned int body_id, const Vector3d &point_position, MatrixNd &G, bool update_kinematics)
Computes a 6-D Jacobian for a point on a body.
RBDL_DLLAPI Vector3d CalcBodyToBaseCoordinates(Model &model, const VectorNd &Q, unsigned int body_id, const Vector3d &point_body_coordinates, bool update_kinematics)
Returns the base coordinates of a point given in body coordinates.
RBDL_DLLAPI SpatialVector CalcPointAcceleration6D(Model &model, const VectorNd &Q, const VectorNd &QDot, const VectorNd &QDDot, unsigned int body_id, const Vector3d &point_position, bool update_kinematics)
Computes linear and angular acceleration of a point on a body.
RBDL_DLLAPI Math::SpatialVector CalcPointVelocity6D(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, unsigned int body_id, const Math::Vector3d &point_position, bool update_kinematics)
Computes angular and linear velocity of a point that is fixed on a body.
SpatialMatrix crossm(const SpatialVector &v)
MX_Xd_dynamic fabs(const MX_Xd_dynamic &m)
Math::SpatialVector svecB
Math::SpatialVector svecA
Working SpatialVectors.
Math::SpatialTransform stB
Math::SpatialTransform stA
Working SpatialTransforms.
Math::SpatialVector svecD
Math::SpatialVector svecE
Math::SpatialVector svecF
Math::VectorNd vecNZeros
Here N is taken to mean the number of elements in QDot.
Math::Matrix3d mat3A
Working Matrix3d entries.
Math::SpatialVector svecC
Compact representation of spatial transformations.
SpatialVector apply(const SpatialVector &v_sp)