8#ifndef RBDL_CONSTRAINTSETS_H
9#define RBDL_CONSTRAINTSETS_H
305 std::string conName(userDefinedName);
306 return nameGroupMap.at(conName);
321 return userDefinedIdGroupMap.at(userDefinedId);
338 return idGroupMap.at(assignedId);
349 return unsigned(constraints.size()-1);
369 return constraints[groupIndex]->getName();
381 return constraints[groupIndex]->getConstraintSize();
391 return constraints[groupIndex]->getConstraintType();
412 return constraints[groupIndex]->getUserDefinedId();
433 unsigned int assignedId=std::numeric_limits<unsigned int>::max();
434 auto it = idGroupMap.begin();
436 while(it != idGroupMap.end() && found ==
false){
437 if(it->second == groupIndex){
438 assignedId = it->first;
444 std::cerr <<
"Error: a groupIndex of " << groupIndex
445 <<
" could not be found. Valid groupIndex range between 0 and "
446 << unsigned(constraints.size()-1);
504 unsigned int groupIndex,
508 std::vector< unsigned int > &updConstraintBodyIdsOutput,
509 std::vector< Math::SpatialTransform > &updConstraintBodyFramesOutput,
510 std::vector< Math::SpatialVector > &updConstraintForcesOutput,
511 bool resolveAllInRootFrame =
false,
512 bool updateKinematics =
false);
566 unsigned int groupIndex,
570 std::vector< unsigned int > &constraintBodyIdsOutput,
571 std::vector< Math::SpatialTransform > &constraintBodyFramesOutput,
572 std::vector< Math::SpatialVector > &constraintImpulsesOutput,
573 bool resolveAllInRootFrame =
false,
574 bool updateKinematics =
false);
596 unsigned int groupIndex,
600 bool updateKinematics =
false);
625 unsigned int groupIndex,
630 bool updateKinematics =
false);
652 unsigned int groupIndex,
664 unsigned int groupIndex){
665 return constraints[groupIndex]->isBaumgarteStabilizationEnabled();
673 unsigned int groupIndex){
674 return constraints[groupIndex]->setEnableBaumgarteStabilization(
true);
682 unsigned int groupIndex){
683 return constraints[groupIndex]->setEnableBaumgarteStabilization(
false);
688 unsigned int groupIndex,
690 constraints[groupIndex]->getBaumgarteStabilizationParameters(
691 baumgartePositionVelocityCoefficientsOutput);
719 const char *constraintName = NULL,
720 unsigned int userDefinedId = std::numeric_limits<unsigned int>::max());
773 unsigned int bodyIdPredecessor,
774 unsigned int bodyIdSuccessor,
778 bool enableBaumgarteStabilization =
false,
779 double stabilizationTimeConstant = 0.1,
780 const char *constraintName = NULL,
781 unsigned int userDefinedId = std::numeric_limits<unsigned int>::max());
793 std::shared_ptr<Constraint> customConstraint);
800 result.
bound =
false;
808 linear_solver = solver;
823 bool Bind (
const Model &model);
846 const std::vector<bool> &actuatedDof);
850 return constraintType.size();
945#ifndef RBDL_USE_CASADI_MATH
947 Eigen::HouseholderQR<Math::MatrixNd>
GT_qr;
969 std::vector<Math::SpatialVector>
f_t;
976 std::vector<Math::SpatialVector>
d_pA;
978 std::vector<Math::SpatialVector>
d_a;
982 std::vector<Math::SpatialMatrix>
d_IA;
984 std::vector<Math::SpatialVector>
d_U;
1016 bool update_kinematics =
true
1035 bool update_kinematics =
true
1061 bool update_kinematics =
true
1088 bool update_kinematics =
true,
1089 std::vector<Math::SpatialVector> *f_ext = NULL
1092#ifndef RBDL_USE_CASADI_MATH
1116 double tolerance = 1e-12,
1117 unsigned int max_iter = 100
1203 bool update_kinematics =
true,
1204 std::vector<Math::SpatialVector> *f_ext = NULL
1215 bool update_kinematics =
true,
1216 std::vector<Math::SpatialVector> *f_ext = NULL
1219#ifndef RBDL_USE_CASADI_MATH
1228 bool update_kinematics =
true,
1229 std::vector<Math::SpatialVector> *f_ext = NULL
1309#ifndef RBDL_USE_CASADI_MATH
1564 bool update_kinematics=
true,
1565 std::vector<Math::SpatialVector> *f_ext = NULL);
1730 bool update_kinematics=
true,
1731 std::vector<Math::SpatialVector> *f_ext = NULL);
1733#ifndef RBDL_USE_CASADI_MATH
1763 bool update_kinematics=
true,
1764 std::vector<Math::SpatialVector> *f_ext = NULL);
1840#ifndef RBDL_USE_CASADI_MATH
1886 Math::LinearSolver &linear_solver
1922 Math::LinearSolver linear_solver
1959 Math::LinearSolver &linear_solver
std::map< unsigned int, unsigned int > userDefinedIdGroupMap
RBDL_DLLAPI void ComputeConstraintImpulsesNullSpace(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDotMinus, ConstraintSet &CS, Math::VectorNd &QDotPlusOutput)
Resolves contact gain using SolveContactSystemNullSpace()
unsigned int getGroupAssignedId(unsigned int groupIndex)
Returns assigned id of the constraint group which will be the first id assigned to an entry in a grou...
void calcVelocityError(unsigned int groupIndex, Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, Math::VectorNd &velocityErrorOutput, bool updateKinematics=false)
calcVelocityError calculates the vector of position errors associated with this constraint....
void calcPositionError(unsigned int groupIndex, Model &model, const Math::VectorNd &Q, Math::VectorNd &positionErrorOutput, bool updateKinematics=false)
calcPositionError calculates the vector of position errors associated with this constraint....
Math::VectorNd b
Workspace for the Lagrangian right-hand-side.
Math::VectorNd QDDot_t
Workspace for the test accelerations.
std::vector< Math::SpatialVector > f_ext_constraints
Workspace for the actual spatial forces.
std::vector< Math::Vector3d > d_multdof3_u
std::vector< std::shared_ptr< LoopConstraint > > loopConstraints
Math::VectorNd impulse
Constraint impulses along the constraint directions.
size_t size() const
Returns the number of constraints.
unsigned int getGroupType(unsigned int groupIndex)
Returns integer corresponding to the ConstraintType.
void calcBaumgarteStabilizationForces(unsigned int groupIndex, Model &model, const Math::VectorNd &positionError, const Math::VectorNd &velocityError, Math::VectorNd &baumgarteForcesOutput)
Eigen::FullPivHouseholderQR< Math::MatrixNd > GPT_full_qr
std::vector< std::shared_ptr< ContactConstraint > > contactConstraints
Math::VectorNd QDDot_0
Workspace for the default accelerations.
RBDL_DLLAPI void CalcConstraintsPositionError(Model &model, const Math::VectorNd &Q, ConstraintSet &CS, Math::VectorNd &errOutput, bool update_kinematics=true)
Computes the position errors for the given ConstraintSet.
RBDL_DLLAPI void ForwardDynamicsConstraintsNullSpace(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, ConstraintSet &CS, Math::VectorNd &QDDotOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
RBDL_DLLAPI void CalcConstraintsVelocityError(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, ConstraintSet &CS, Math::VectorNd &errOutput, bool update_kinematics=true)
Computes the velocity errors for the given ConstraintSet.
Math::VectorNd a
Workspace for the accelerations of due to the test forces.
RBDL_DLLAPI void InverseDynamicsConstraintsRelaxed(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDotControls, ConstraintSet &CS, Math::VectorNd &QDDotOutput, Math::VectorNd &TauOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
A relaxed inverse-dynamics operator that can be applied to under-actuated or fully-actuated constrain...
Math::VectorNd x
Workspace for the Lagrangian solution.
RBDL_DLLAPI void ForwardDynamicsConstraintsDirect(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, ConstraintSet &CS, Math::VectorNd &QDDotOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
Computes forward dynamics with contact by constructing and solving the full lagrangian equation.
Math::VectorNd d_d
Workspace when applying constraint forces.
std::vector< Math::SpatialVector > d_pA
Workspace for the bias force due to the test force.
Math::MatrixNd G
Workspace for the constraint Jacobian.
void SetActuationMap(const Model &model, const std::vector< bool > &actuatedDof)
Initializes and allocates memory needed for InverseDynamicsConstraints and InverseDynamicsConstraints...
RBDL_DLLAPI void SolveConstrainedSystemDirect(Math::MatrixNd &H, const Math::MatrixNd &G, const Math::VectorNd &c, const Math::VectorNd &gamma, Math::VectorNd &lambda, Math::MatrixNd &A, Math::VectorNd &b, Math::VectorNd &x, Math::LinearSolver &linear_solver)
Solves the full contact system directly, i.e. simultaneously for contact forces and joint acceleratio...
std::vector< std::shared_ptr< Constraint > > constraints
RBDL_DLLAPI void CalcConstrainedSystemVariables(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, ConstraintSet &CSOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
Computes the terms , , and of the constrained dynamic problem and stores them in the ConstraintSet.
RBDL_DLLAPI void InverseDynamicsConstraints(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &QDDotDesired, ConstraintSet &CS, Math::VectorNd &QDDotOutput, Math::VectorNd &TauOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
An inverse-dynamics operator that can be applied to fully-actuated constrained systems.
RBDL_DLLAPI bool CalcAssemblyQ(Model &model, Math::VectorNd QInit, ConstraintSet &CS, Math::VectorNd &QOutput, const Math::VectorNd &weights, double tolerance=1e-12, unsigned int max_iter=100)
Computes a feasible initial value of the generalized joint positions.
unsigned int AddLoopConstraint(unsigned int bodyIdPredecessor, unsigned int bodyIdSuccessor, const Math::SpatialTransform &XPredecessor, const Math::SpatialTransform &XSuccessor, const Math::SpatialVector &constraintAxisInPredecessor, bool enableBaumgarteStabilization=false, double stabilizationTimeConstant=0.1, const char *constraintName=NULL, unsigned int userDefinedId=std::numeric_limits< unsigned int >::max())
Adds a loop constraint to the constraint set.
std::vector< ConstraintType > constraintType
RBDL_DLLAPI void ComputeConstraintImpulsesDirect(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDotMinus, ConstraintSet &CS, Math::VectorNd &QDotPlusOutput)
Computes contact gain by constructing and solving the full lagrangian equation.
unsigned int getGroupIndexMax()
getGroupIndexMax returns the maximum valid constraint group index (the min. is zero) so that constrai...
std::vector< Math::SpatialMatrix > d_IA
Workspace for the inertia when applying constraint forces.
std::vector< std::string > name
void SetSolver(Math::LinearSolver solver)
Specifies which method should be used for solving undelying linear systems.
RBDL_DLLAPI void CalcAssemblyQDot(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDotInit, ConstraintSet &CS, Math::VectorNd &QDotOutput, const Math::VectorNd &weights)
Computes a feasible initial value of the generalized joint velocities.
unsigned int AddCustomConstraint(std::shared_ptr< Constraint > customConstraint)
Adds a custom constraint to the constraint set.
unsigned int getGroupIndexByName(const char *userDefinedName)
getGroupIndex returns the index to a constraints that have been grouped because they are of the same ...
Math::MatrixNd H
Workspace for the joint space inertia matrix.
Math::VectorNd gamma
Workspace of the right hand side of the acceleration equation.
bool isBaumgarteStabilizationEnabled(unsigned int groupIndex)
Math::MatrixNd P
Selection matrix for the non-actuated parts of the model.
std::vector< Math::SpatialVector > d_U
Workspace when applying constraint forces.
unsigned int getGroupIndexById(unsigned int userDefinedId)
getGroupIndex returns the index to a constraints that have been grouped because they are of the same ...
Math::VectorNd v_plus
The velocities we want to have along the constraint directions.
bool bound
Whether the constraint set was bound to a model (mandatory!).
Math::LinearSolver linear_solver
Method that should be used to solve internal linear systems.
std::vector< Math::SpatialVector > d_a
Workspace for the acceleration due to the test force.
RBDL_DLLAPI void SolveConstrainedSystemNullSpace(Math::MatrixNd &H, const Math::MatrixNd &G, const Math::VectorNd &c, const Math::VectorNd &gamma, Math::VectorNd &qddot, Math::VectorNd &lambda, Math::MatrixNd &Y, Math::MatrixNd &Z, Math::VectorNd &qddot_y, Math::VectorNd &qddot_z, Math::LinearSolver &linear_solver)
Solves the contact system by first solving for the joint accelerations and then for the constraint fo...
void calcImpulses(unsigned int groupIndex, Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, std::vector< unsigned int > &constraintBodyIdsOutput, std::vector< Math::SpatialTransform > &constraintBodyFramesOutput, std::vector< Math::SpatialVector > &constraintImpulsesOutput, bool resolveAllInRootFrame=false, bool updateKinematics=false)
calcImpulses resolves the generalized impluses generated by this constraint into equivalent spatial i...
std::map< unsigned int, unsigned int > idGroupMap
unsigned int AddContactConstraint(unsigned int bodyId, const Math::Vector3d &bodyPoint, const Math::Vector3d &worldNormal, const char *constraintName=NULL, unsigned int userDefinedId=std::numeric_limits< unsigned int >::max())
Adds a single contact constraint (point-ground) to the constraint set.
Math::VectorNd C
Workspace for the coriolis forces.
RBDL_DLLAPI bool isConstrainedSystemFullyActuated(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, ConstraintSet &CS, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
A method to evaluate if the constrained system is fully actuated.
RBDL_DLLAPI void CalcConstraintsJacobian(Model &model, const Math::VectorNd &Q, ConstraintSet &CS, Math::MatrixNd &GOutput, bool update_kinematics=true)
Computes the Jacobian for the given ConstraintSet.
const char * getGroupName(unsigned int groupIndex)
Returns the name of the constraint group, which may differ from the names entered by the user if the ...
void enableBaumgarteStabilization(unsigned int groupIndex)
RBDL_DLLAPI void SolveConstrainedSystemRangeSpaceSparse(Model &model, Math::MatrixNd &H, const Math::MatrixNd &G, const Math::VectorNd &c, const Math::VectorNd &gamma, Math::VectorNd &qddot, Math::VectorNd &lambda, Math::MatrixNd &K, Math::VectorNd &a, Math::LinearSolver linear_solver)
Solves the contact system by first solving for the the joint accelerations and then the contact force...
ConstraintSet Copy()
Copies the constraints and resets its ConstraintSet::bound flag.
void clear()
Clears all variables in the constraint set.
void disableBaumgarteStabilization(unsigned int groupIndex)
std::vector< Math::SpatialVector > f_t
Workspace for the test forces.
RBDL_DLLAPI void ComputeConstraintImpulsesRangeSpaceSparse(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDotMinus, ConstraintSet &CS, Math::VectorNd &QDotPlusOutput)
Resolves contact gain using SolveContactSystemRangeSpaceSparse()
RBDL_DLLAPI void ForwardDynamicsConstraintsRangeSpaceSparse(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, ConstraintSet &CS, Math::VectorNd &QDDotOutput, bool update_kinematics=true, std::vector< Math::SpatialVector > *f_ext=NULL)
RBDL_DLLAPI void ForwardDynamicsContactsKokkevis(Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, const Math::VectorNd &Tau, ConstraintSet &CS, Math::VectorNd &QDDotOutput)
Computes forward dynamics that accounts for active contacts in ConstraintSet.
Eigen::HouseholderQR< Math::MatrixNd > GT_qr
Workspace for the QR decomposition of the null-space method.
unsigned int getGroupSize(unsigned int groupIndex)
Returns the number of constraint equations in this group.
void calcForces(unsigned int groupIndex, Model &model, const Math::VectorNd &Q, const Math::VectorNd &QDot, std::vector< unsigned int > &updConstraintBodyIdsOutput, std::vector< Math::SpatialTransform > &updConstraintBodyFramesOutput, std::vector< Math::SpatialVector > &updConstraintForcesOutput, bool resolveAllInRootFrame=false, bool updateKinematics=false)
calcForces resolves the generalized forces generated by this constraint into equivalent spatial force...
void getBaumgarteStabilizationCoefficients(unsigned int groupIndex, Math::Vector2d &baumgartePositionVelocityCoefficientsOutput)
bool Bind(const Model &model)
Initializes and allocates memory for the constraint set.
std::vector< Math::Vector3d > point_accel_0
Workspace for the default point accelerations.
Math::MatrixNd K
Workspace for the Inverse Articulated-Body Inertia.
unsigned int getGroupId(unsigned int groupIndex)
Returns the user-defined-id of the constraint group, which may differ from the names entered by the u...
std::map< std::string, unsigned int > nameGroupMap
Math::MatrixNd A
Workspace for the Lagrangian left-hand-side matrix.
unsigned int getGroupIndexByAssignedId(unsigned int assignedId)
getGroupIndex returns the index to a constraints that have been grouped because they are of the same ...
LinearSolverColPivHouseholderQR
Structure that contains both constraint information and workspace memory.
Compact representation of spatial transformations.