27ContactConstraint::ContactConstraint():
29 std::numeric_limits<unsigned int>::max()){}
33 const unsigned int bodyId,
36 const char *contactConstraintName,
37 unsigned int userDefinedIdNumber,
38 bool enableBaumgarteStabilization,
39 double stabilizationTimeConstant,
40 bool velocityLevelConstraint):
47 T.push_back(groundConstraintUnitVector);
48 dblA = std::numeric_limits<double>::epsilon()*10.;
49#ifndef RBDL_USE_CASADI_MATH
95 bool updateKinematics)
116 bool updateKinematics)
126 -
T[i].transpose()*cache.
vec3A;
139 bool updateKinematics)
161 bool updateKinematics)
183 std::vector< unsigned int > &constraintBodiesUpd,
184 std::vector< Math::SpatialTransform > &constraintBodyFramesUpd,
185 std::vector< Math::SpatialVector > &constraintForcesUpd,
187 bool resolveAllInRootFrame,
188 bool updateKinematics)
198 if(resolveAllInRootFrame){
199 constraintBodiesUpd[0] = constraintBodiesUpd[1];
200 constraintBodyFramesUpd[0].r = cache.
vec3A;
201 constraintBodyFramesUpd[0].E = constraintBodyFramesUpd[1].E;
205 constraintForcesUpd.resize(
bodyIds.size());
206 for(
unsigned int i=0; i<
bodyIds.size(); ++i){
207 constraintForcesUpd[i].setZero();
210 cache.
vec3A.setZero();
218 if(resolveAllInRootFrame){
219 constraintForcesUpd[0].
block(3,0,3,1) = cache.
vec3A;
222 constraintForcesUpd[0].block(3,0,3,1) = cache.
mat3A*cache.
vec3A;
226 constraintForcesUpd[1].block(3,0,3,1) = -cache.
vec3A;
231 bool velocityLevelConstraint)
233 dblA = 10.0*std::numeric_limits<double>::epsilon();
236#ifndef RBDL_USE_CASADI_MATH
248 assert( sizeOfConstraint <= 3 && sizeOfConstraint > 0);
259 std::vector<Math::Vector3d> &pointAccelerationsSysUpd,
260 bool updateKinematics)
279 bool updateKinematics)
290 const std::vector<Math::Vector3d> &pointAccelerationsSys,
304 std::vector<Math::SpatialVector> &fExtSysUpd,
305 bool updateKinematics)
309 cache.
stA.
E.Identity();
315 cache.
svecA[3] = -
T[i][0];
316 cache.
svecA[4] = -
T[i][1];
317 cache.
svecA[5] = -
T[i][2];
MX_Xd_dynamic & setZero()
unsigned int cols() const
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 calcPointForceJacobian(Model &model, const Math::VectorNd &Q, ConstraintCache &cache, std::vector< Math::SpatialVector > &fExtSysUpd, bool updateKinematics=false)
void appendNormalVector(const Math::Vector3d &normal, bool velocityLevelConstraint=true)
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 working double.
Math::Vector3d groundPoint
The location of the ground reference point.
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...
void calcPointAccelerations(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDot, std::vector< Math::Vector3d > &pointAccelerationSysUpd, bool updateKinematics=false)
std::vector< Math::Vector3d > T
A vector of the ground normal vectors used in this constraint.
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 calcPointAccelerationError(const std::vector< Math::Vector3d > &pointAccelerationsSys, Math::VectorNd &ddErrSysUpd)
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 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 void CalcPointJacobian(Model &model, const VectorNd &Q, unsigned int body_id, const Vector3d &point_position, MatrixNd &G, bool update_kinematics)
Computes the point jacobian for a point on a body.
RBDL_DLLAPI Vector3d CalcPointVelocity(Model &model, const VectorNd &Q, const VectorNd &QDot, unsigned int body_id, const Vector3d &point_position, bool update_kinematics)
Computes the velocity of a point on a body.
RBDL_DLLAPI Vector3d CalcPointAcceleration(Model &model, const VectorNd &Q, const VectorNd &QDot, const VectorNd &QDDot, unsigned int body_id, const Vector3d &point_position, bool update_kinematics)
Computes the linear acceleration of a point on a body.
RBDL_DLLAPI Matrix3d Matrix3dIdentity
RBDL_DLLAPI Vector3d Vector3dZero
MX_Xd_dynamic fabs(const MX_Xd_dynamic &m)
Math::SpatialVector svecA
Working SpatialVectors.
Math::SpatialTransform stA
Working SpatialTransforms.
Math::VectorNd vecNZeros
Here N is taken to mean the number of elements in QDot.
Math::Vector3d vec3A
Working Vector3d entries.
Math::Matrix3d mat3A
Working Matrix3d entries.
Compact representation of spatial transformations.
SpatialVector applyAdjoint(const SpatialVector &f_sp)