Rigid Body Dynamics Library
Constraints.h
Go to the documentation of this file.
1/*
2 * RBDL - Rigid Body Dynamics Library
3 * Copyright (c) 2011-2018 Martin Felis <martin@fysx.org>
4 * 2019 Matthew Millard <mjhmilla@protonmail.com>
5 * Licensed under the zlib license. See LICENSE for more details.
6 */
7
8#ifndef RBDL_CONSTRAINTSETS_H
9#define RBDL_CONSTRAINTSETS_H
10
11#include <memory>
12
13#include <rbdl/rbdl_math.h>
14#include <rbdl/rbdl_mathutils.h>
15#include <rbdl/Kinematics.h>
16#include <rbdl/Constraint.h>
19#include <string.h>
20#include <assert.h>
21#include <map>
22
23namespace RigidBodyDynamics {
24
25
26
27
265struct Model;
266
267
268
269//class RBDL_DLLAPI Constraint;
270
271
281struct RBDL_DLLAPI ConstraintSet {
283 linear_solver (Math::LinearSolverColPivHouseholderQR),
284 bound (false) {}
285
286
287
304 unsigned int getGroupIndexByName(const char* userDefinedName){
305 std::string conName(userDefinedName);
306 return nameGroupMap.at(conName);
307 }
308
320 unsigned int getGroupIndexById(unsigned int userDefinedId){
321 return userDefinedIdGroupMap.at(userDefinedId);
322 }
323
337 unsigned int getGroupIndexByAssignedId(unsigned int assignedId){
338 return idGroupMap.at(assignedId);
339 }
340
341
348 unsigned int getGroupIndexMax(){
349 return unsigned(constraints.size()-1);
350 }
351
368 const char* getGroupName(unsigned int groupIndex){
369 return constraints[groupIndex]->getName();
370 }
371
380 unsigned int getGroupSize(unsigned int groupIndex){
381 return constraints[groupIndex]->getConstraintSize();
382 }
383
390 unsigned int getGroupType(unsigned int groupIndex){
391 return constraints[groupIndex]->getConstraintType();
392 }
393
411 unsigned int getGroupId(unsigned int groupIndex){
412 return constraints[groupIndex]->getUserDefinedId();
413 }
414
415
432 unsigned int getGroupAssignedId(unsigned int groupIndex){
433 unsigned int assignedId=std::numeric_limits<unsigned int>::max();
434 auto it = idGroupMap.begin();
435 bool found = false;
436 while(it != idGroupMap.end() && found == false){
437 if(it->second == groupIndex){
438 assignedId = it->first;
439 found = true;
440 }
441 it++;
442 }
443 if(found==false){
444 std::cerr << "Error: a groupIndex of " << groupIndex
445 << " could not be found. Valid groupIndex range between 0 and "
446 << unsigned(constraints.size()-1);
447 assert(0);
448 abort();
449 }
450 return assignedId;
451 }
452
504 unsigned int groupIndex,
505 Model& model,
506 const Math::VectorNd &Q,
507 const Math::VectorNd &QDot,
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);
513
514
566 unsigned int groupIndex,
567 Model& model,
568 const Math::VectorNd &Q,
569 const Math::VectorNd &QDot,
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);
575
596 unsigned int groupIndex,
597 Model& model,
598 const Math::VectorNd &Q,
599 Math::VectorNd &positionErrorOutput,
600 bool updateKinematics = false);
601
602
625 unsigned int groupIndex,
626 Model& model,
627 const Math::VectorNd &Q,
628 const Math::VectorNd &QDot,
629 Math::VectorNd &velocityErrorOutput,
630 bool updateKinematics = false);
631
632
652 unsigned int groupIndex,
653 Model& model,
654 const Math::VectorNd &positionError,
655 const Math::VectorNd &velocityError,
656 Math::VectorNd &baumgarteForcesOutput);
657
664 unsigned int groupIndex){
665 return constraints[groupIndex]->isBaumgarteStabilizationEnabled();
666 }
667
673 unsigned int groupIndex){
674 return constraints[groupIndex]->setEnableBaumgarteStabilization(true);
675 }
676
682 unsigned int groupIndex){
683 return constraints[groupIndex]->setEnableBaumgarteStabilization(false);
684 }
685
686
688 unsigned int groupIndex,
689 Math::Vector2d& baumgartePositionVelocityCoefficientsOutput){
690 constraints[groupIndex]->getBaumgarteStabilizationParameters(
691 baumgartePositionVelocityCoefficientsOutput);
692 }
693
715 unsigned int AddContactConstraint (
716 unsigned int bodyId,
717 const Math::Vector3d &bodyPoint,
718 const Math::Vector3d &worldNormal,
719 const char *constraintName = NULL,
720 unsigned int userDefinedId = std::numeric_limits<unsigned int>::max());
721
722
772 unsigned int AddLoopConstraint(
773 unsigned int bodyIdPredecessor,
774 unsigned int bodyIdSuccessor,
775 const Math::SpatialTransform &XPredecessor,
776 const Math::SpatialTransform &XSuccessor,
777 const Math::SpatialVector &constraintAxisInPredecessor,
778 bool enableBaumgarteStabilization = false,
779 double stabilizationTimeConstant = 0.1,
780 const char *constraintName = NULL,
781 unsigned int userDefinedId = std::numeric_limits<unsigned int>::max());
782
783
784
785
793 std::shared_ptr<Constraint> customConstraint);
794
799 ConstraintSet result (*this);
800 result.bound = false;
801
802 return result;
803 }
804
807 void SetSolver (Math::LinearSolver solver) {
808 linear_solver = solver;
809 }
810
823 bool Bind (const Model &model);
824
845 void SetActuationMap(const Model &model,
846 const std::vector<bool> &actuatedDof);
847
849 size_t size() const {
850 return constraintType.size();
851 }
852
854 void clear ();
855
857 Math::LinearSolver linear_solver;
859 bool bound;
860
861 // Common constraints variables.
862 std::vector<ConstraintType> constraintType;
863
864 std::vector<std::string> name;
865
866 std::map < std::string, unsigned int > nameGroupMap;
867 std::map < unsigned int, unsigned int> userDefinedIdGroupMap;
868 std::map < unsigned int, unsigned int> idGroupMap;
869
870 //A shared_ptr (MM 28 May 2019)
871 // :is 2x as expensive (with the optimize flags turned on) as a regular
872 // pointer (https://www.modernescpp.com/index.php/memory-and-performance-overhead-of-smart-pointer)
873 // :But
874 // -The memory is deleted automatically when all references are deleted.
875 // -A shared_ptr works with the existing Copy function
876 // -... although the Copy is a shallow copy. A deep copy would be better
877 //
878 // :A unique_ptr would be faster, but will require copy constructors to
879 // be defined for all constraint objects. In addition unique_ptr is only
880 // included in C++14, while shared_ptr is available in C++11. While this
881 // is clearly the better option, this will require me to make more
882 // edits to ConstraintSet: I don't have the time for this at the moment
883 std::vector< std::shared_ptr<Constraint> > constraints;
884
885 std::vector< std::shared_ptr<ContactConstraint> > contactConstraints;
886
887 std::vector< std::shared_ptr<LoopConstraint> > loopConstraints;
888
889
894
902
903 // Variables used by the Lagrangian methods
904
913
920
931
934
936 Math::MatrixNd Ful,Fur,Fll,Flr; //blocks of f for SimpleMath
937
939 Math::MatrixNd GTu, GTl;//blocks of GT for SimpleMath
944
945#ifndef RBDL_USE_CASADI_MATH
947 Eigen::HouseholderQR<Math::MatrixNd> GT_qr;
948 Eigen::FullPivHouseholderQR<Math::MatrixNd> GPT_full_qr;
949#endif
950
958
959 // Variables used by the IABI methods
969 std::vector<Math::SpatialVector> f_t;
971 std::vector<Math::SpatialVector> f_ext_constraints;
973 std::vector<Math::Vector3d> point_accel_0;
974
976 std::vector<Math::SpatialVector> d_pA;
978 std::vector<Math::SpatialVector> d_a;
980
982 std::vector<Math::SpatialMatrix> d_IA;
984 std::vector<Math::SpatialVector> d_U;
987
988 std::vector<Math::Vector3d> d_multdof3_u;
989
991
992
993
994
995};
996
1010RBDL_DLLAPI
1012 Model& model,
1013 const Math::VectorNd &Q,
1014 ConstraintSet &CS,
1015 Math::VectorNd& errOutput,
1016 bool update_kinematics = true
1017);
1018
1029RBDL_DLLAPI
1031 Model &model,
1032 const Math::VectorNd &Q,
1033 ConstraintSet &CS,
1034 Math::MatrixNd &GOutput,
1035 bool update_kinematics = true
1036);
1037
1054RBDL_DLLAPI
1056 Model& model,
1057 const Math::VectorNd &Q,
1058 const Math::VectorNd &QDot,
1059 ConstraintSet &CS,
1060 Math::VectorNd& errOutput,
1061 bool update_kinematics = true
1062);
1063
1081RBDL_DLLAPI
1083 Model &model,
1084 const Math::VectorNd &Q,
1085 const Math::VectorNd &QDot,
1086 const Math::VectorNd &Tau,
1087 ConstraintSet &CSOutput,
1088 bool update_kinematics = true,
1089 std::vector<Math::SpatialVector> *f_ext = NULL
1090);
1091
1092#ifndef RBDL_USE_CASADI_MATH
1109RBDL_DLLAPI
1111 Model &model,
1112 Math::VectorNd QInit,
1113 ConstraintSet &CS,
1114 Math::VectorNd &QOutput,
1115 const Math::VectorNd &weights,
1116 double tolerance = 1e-12,
1117 unsigned int max_iter = 100
1118);
1119#endif
1120
1132RBDL_DLLAPI
1134 Model &model,
1135 const Math::VectorNd &Q,
1136 const Math::VectorNd &QDotInit,
1137 ConstraintSet &CS,
1138 Math::VectorNd &QDotOutput,
1139 const Math::VectorNd &weights
1140);
1141
1195RBDL_DLLAPI
1197 Model &model,
1198 const Math::VectorNd &Q,
1199 const Math::VectorNd &QDot,
1200 const Math::VectorNd &Tau,
1201 ConstraintSet &CS,
1202 Math::VectorNd &QDDotOutput,
1203 bool update_kinematics = true,
1204 std::vector<Math::SpatialVector> *f_ext = NULL
1205);
1206
1207RBDL_DLLAPI
1209 Model &model,
1210 const Math::VectorNd &Q,
1211 const Math::VectorNd &QDot,
1212 const Math::VectorNd &Tau,
1213 ConstraintSet &CS,
1214 Math::VectorNd &QDDotOutput,
1215 bool update_kinematics = true,
1216 std::vector<Math::SpatialVector> *f_ext = NULL
1217);
1218
1219#ifndef RBDL_USE_CASADI_MATH
1220RBDL_DLLAPI
1222 Model &model,
1223 const Math::VectorNd &Q,
1224 const Math::VectorNd &QDot,
1225 const Math::VectorNd &Tau,
1226 ConstraintSet &CS,
1227 Math::VectorNd &QDDotOutput,
1228 bool update_kinematics = true,
1229 std::vector<Math::SpatialVector> *f_ext = NULL
1230);
1231#endif
1232
1298RBDL_DLLAPI
1300 Model &model,
1301 const Math::VectorNd &Q,
1302 const Math::VectorNd &QDot,
1303 const Math::VectorNd &Tau,
1304 ConstraintSet &CS,
1305 Math::VectorNd &QDDotOutput
1306);
1307
1308
1309#ifndef RBDL_USE_CASADI_MATH
1555RBDL_DLLAPI
1557 Model &model,
1558 const Math::VectorNd &Q,
1559 const Math::VectorNd &QDot,
1560 const Math::VectorNd &QDDotControls,
1561 ConstraintSet &CS,
1562 Math::VectorNd &QDDotOutput,
1563 Math::VectorNd &TauOutput,
1564 bool update_kinematics=true,
1565 std::vector<Math::SpatialVector> *f_ext = NULL);
1566#endif
1721RBDL_DLLAPI
1723 Model &model,
1724 const Math::VectorNd &Q,
1725 const Math::VectorNd &QDot,
1726 const Math::VectorNd &QDDotDesired,
1727 ConstraintSet &CS,
1728 Math::VectorNd &QDDotOutput,
1729 Math::VectorNd &TauOutput,
1730 bool update_kinematics=true,
1731 std::vector<Math::SpatialVector> *f_ext = NULL);
1732
1733#ifndef RBDL_USE_CASADI_MATH
1757RBDL_DLLAPI
1759 Model &model,
1760 const Math::VectorNd &Q,
1761 const Math::VectorNd &QDot,
1762 ConstraintSet &CS,
1763 bool update_kinematics=true,
1764 std::vector<Math::SpatialVector> *f_ext = NULL);
1765#endif
1766
1815RBDL_DLLAPI
1817 Model &model,
1818 const Math::VectorNd &Q,
1819 const Math::VectorNd &QDotMinus,
1820 ConstraintSet &CS,
1821 Math::VectorNd &QDotPlusOutput
1822);
1823
1831RBDL_DLLAPI
1833 Model &model,
1834 const Math::VectorNd &Q,
1835 const Math::VectorNd &QDotMinus,
1836 ConstraintSet &CS,
1837 Math::VectorNd &QDotPlusOutput
1838);
1839
1840#ifndef RBDL_USE_CASADI_MATH
1848RBDL_DLLAPI
1850 Model &model,
1851 const Math::VectorNd &Q,
1852 const Math::VectorNd &QDotMinus,
1853 ConstraintSet &CS,
1854 Math::VectorNd &QDotPlusOutput
1855);
1856#endif
1857
1876RBDL_DLLAPI
1878 Math::MatrixNd &H,
1879 const Math::MatrixNd &G,
1880 const Math::VectorNd &c,
1881 const Math::VectorNd &gamma,
1882 Math::VectorNd &lambda,
1883 Math::MatrixNd &A,
1884 Math::VectorNd &b,
1885 Math::VectorNd &x,
1886 Math::LinearSolver &linear_solver
1887);
1888
1911RBDL_DLLAPI
1913 Model &model,
1914 Math::MatrixNd &H,
1915 const Math::MatrixNd &G,
1916 const Math::VectorNd &c,
1917 const Math::VectorNd &gamma,
1918 Math::VectorNd &qddot,
1919 Math::VectorNd &lambda,
1920 Math::MatrixNd &K,
1921 Math::VectorNd &a,
1922 Math::LinearSolver linear_solver
1923);
1924
1947RBDL_DLLAPI
1949 Math::MatrixNd &H,
1950 const Math::MatrixNd &G,
1951 const Math::VectorNd &c,
1952 const Math::VectorNd &gamma,
1953 Math::VectorNd &qddot,
1954 Math::VectorNd &lambda,
1955 Math::MatrixNd &Y,
1956 Math::MatrixNd &Z,
1957 Math::VectorNd &qddot_y,
1958 Math::VectorNd &qddot_z,
1959 Math::LinearSolver &linear_solver
1960);
1961
1962
1963
1964}
1965
1966/* namespace RigidBodyDynamics */
1967
1968/* RBDL_CONSTRAINTS_H */
1969#endif
std::map< unsigned int, unsigned int > userDefinedIdGroupMap
Definition: Constraints.h:867
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...
Definition: Constraints.h:432
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.
Definition: Constraints.h:917
Math::VectorNd QDDot_t
Workspace for the test accelerations.
Definition: Constraints.h:965
std::vector< Math::SpatialVector > f_ext_constraints
Workspace for the actual spatial forces.
Definition: Constraints.h:971
std::vector< Math::Vector3d > d_multdof3_u
Definition: Constraints.h:988
std::vector< std::shared_ptr< LoopConstraint > > loopConstraints
Definition: Constraints.h:887
Math::VectorNd impulse
Constraint impulses along the constraint directions.
Definition: Constraints.h:899
size_t size() const
Returns the number of constraints.
Definition: Constraints.h:849
unsigned int getGroupType(unsigned int groupIndex)
Returns integer corresponding to the ConstraintType.
Definition: Constraints.h:390
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
Definition: Constraints.h:948
std::vector< std::shared_ptr< ContactConstraint > > contactConstraints
Definition: Constraints.h:885
Math::VectorNd QDDot_0
Workspace for the default accelerations.
Definition: Constraints.h:967
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.
Definition: Constraints.h:963
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.
Definition: Constraints.h:919
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.
Definition: Constraints.h:986
std::vector< Math::SpatialVector > d_pA
Workspace for the bias force due to the test force.
Definition: Constraints.h:976
Math::MatrixNd G
Workspace for the constraint Jacobian.
Definition: Constraints.h:912
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
Definition: Constraints.h:883
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
Definition: Constraints.h:862
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...
Definition: Constraints.h:348
std::vector< Math::SpatialMatrix > d_IA
Workspace for the inertia when applying constraint forces.
Definition: Constraints.h:982
std::vector< std::string > name
Definition: Constraints.h:864
void SetSolver(Math::LinearSolver solver)
Specifies which method should be used for solving undelying linear systems.
Definition: Constraints.h:807
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 ...
Definition: Constraints.h:304
Math::MatrixNd H
Workspace for the joint space inertia matrix.
Definition: Constraints.h:906
Math::VectorNd gamma
Workspace of the right hand side of the acceleration equation.
Definition: Constraints.h:910
bool isBaumgarteStabilizationEnabled(unsigned int groupIndex)
Definition: Constraints.h:663
Math::MatrixNd P
Selection matrix for the non-actuated parts of the model.
Definition: Constraints.h:925
std::vector< Math::SpatialVector > d_U
Workspace when applying constraint forces.
Definition: Constraints.h:984
unsigned int getGroupIndexById(unsigned int userDefinedId)
getGroupIndex returns the index to a constraints that have been grouped because they are of the same ...
Definition: Constraints.h:320
Math::VectorNd v_plus
The velocities we want to have along the constraint directions.
Definition: Constraints.h:901
bool bound
Whether the constraint set was bound to a model (mandatory!).
Definition: Constraints.h:859
Math::LinearSolver linear_solver
Method that should be used to solve internal linear systems.
Definition: Constraints.h:857
std::vector< Math::SpatialVector > d_a
Workspace for the acceleration due to the test force.
Definition: Constraints.h:978
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
Definition: Constraints.h:868
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.
Definition: Constraints.h:908
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 ...
Definition: Constraints.h:368
void enableBaumgarteStabilization(unsigned int groupIndex)
Definition: Constraints.h:672
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.
Definition: Constraints.h:798
void clear()
Clears all variables in the constraint set.
void disableBaumgarteStabilization(unsigned int groupIndex)
Definition: Constraints.h:681
std::vector< Math::SpatialVector > f_t
Workspace for the test forces.
Definition: Constraints.h:969
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.
Definition: Constraints.h:947
unsigned int getGroupSize(unsigned int groupIndex)
Returns the number of constraint equations in this group.
Definition: Constraints.h:380
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)
Definition: Constraints.h:687
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.
Definition: Constraints.h:973
Math::MatrixNd K
Workspace for the Inverse Articulated-Body Inertia.
Definition: Constraints.h:961
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...
Definition: Constraints.h:411
std::map< std::string, unsigned int > nameGroupMap
Definition: Constraints.h:866
Math::MatrixNd A
Workspace for the Lagrangian left-hand-side matrix.
Definition: Constraints.h:915
unsigned int getGroupIndexByAssignedId(unsigned int assignedId)
getGroupIndex returns the index to a constraints that have been grouped because they are of the same ...
Definition: Constraints.h:337
LinearSolverColPivHouseholderQR
Structure that contains both constraint information and workspace memory.
Definition: Constraints.h:281
Compact representation of spatial transformations.