Rigid Body Dynamics Library
Constraint_Contact.h
Go to the documentation of this file.
1/*
2 * RBDL - Rigid Body Dynamics Library
3 * Copyright (c) 2019 Matthew Millard <millard.matthew@gmail.com>
4 * Licensed under the zlib license. See LICENSE for more details.
5 */
6
7#ifndef RBDL_CONTACT_CONSTRAINT_H
8#define RBDL_CONTACT_CONSTRAINT_H
9
10#include <rbdl/rbdl_math.h>
11#include <rbdl/rbdl_mathutils.h>
12#include <rbdl/Kinematics.h>
13#include <rbdl/Constraint.h>
14#include <assert.h>
15
16namespace RigidBodyDynamics {
17
80class RBDL_DLLAPI ContactConstraint : public Constraint {
81
82public:
83
84
86
126 const unsigned int bodyId,
127 const Math::Vector3d &bodyPoint,
128 const Math::Vector3d &groundConstraintNormalVectors,
129 const char *contactConstraintName = NULL,
130 unsigned int userDefinedId = std::numeric_limits<unsigned int>::max(),
131 bool enableBaumgarteStabilization=false,
132 double stabilizationTimeConstant=0.1,
133 bool velocityLevelConstraint=true);
134
135
136 void bind( const Model &model) override;
137
138 void calcConstraintJacobian( Model &model,
139 const double time,
140 const Math::VectorNd &Q,
141 const Math::VectorNd &QDot,
142 Math::MatrixNd &GSysUpd,
143 ConstraintCache &cache,
144 bool updateKinematics=false) override;
145
146 void calcGamma( Model &model,
147 const double time,
148 const Math::VectorNd &Q,
149 const Math::VectorNd &QDot,
150 const Math::MatrixNd &GSys,
151 Math::VectorNd &gammaSysUpd,
152 ConstraintCache &cache,
153 bool updateKinematics=false) override;
154
155 void calcPositionError( Model &model,
156 const double time,
157 const Math::VectorNd &Q,
158 Math::VectorNd &errSysUpd,
159 ConstraintCache &cache,
160 bool updateKinematics=false) override;
161
162 void calcVelocityError( Model &model,
163 const double time,
164 const Math::VectorNd &Q,
165 const Math::VectorNd &QDot,
166 const Math::MatrixNd &GSys,
167 Math::VectorNd &derrSysUpd,
168 ConstraintCache &cache,
169 bool updateKinematics=false) override;
170
171 void calcConstraintForces(
172 Model &model,
173 const double time,
174 const Math::VectorNd &Q,
175 const Math::VectorNd &QDot,
176 const Math::MatrixNd &GSys,
177 const Math::VectorNd &lagrangeMultipliersSys,
178 std::vector< unsigned int > &constraintBodiesUpd,
179 std::vector< Math::SpatialTransform > &constraintBodyFramesUpd,
180 std::vector< Math::SpatialVector > &constraintForcesUpd,
181 ConstraintCache &cache,
182 bool resolveAllInRootFrame = false,
183 bool updateKinematics=false) override;
184
185
186
191 const std::vector< Math::Vector3d >& getConstraintNormalVectors(){
192 return T;
193 }
194
201 void appendNormalVector(const Math::Vector3d &normal,
202 bool velocityLevelConstraint=true);
203
204 /*** @brief Added to support ForwardDynamicsKokkevis
205
206 @param model: the multibody model
207 @param Q: the generalized positions of the model
208 @param QDot: the generalized velocities of the model
209 @param QDDot: the generalized accelerations of the model
210 @param pointAccelerationSysUpd the system's vector of point accelerations
211 @param updateKinematics setting this to true will force kinematic functions
212 to use the values of Q, QDot, and QDDot passed into this function.
213 */
214 void calcPointAccelerations(Model &model,
215 const Math::VectorNd &Q,
216 const Math::VectorNd &QDot,
217 const Math::VectorNd &QDDot,
218 std::vector<Math::Vector3d> &pointAccelerationSysUpd,
219 bool updateKinematics=false);
220
221 /*** @brief To support ForwardDynamicsKokkevis
222 @param model: the multibody model
223 @param Q: the generalized positions of the model
224 @param QDot: the generalized velocities of the model
225 @param QDDot: the generalized accelerations of the model
226 @param pointAccelerationUpd the acclerations of the one point in this constraint
227 @param updateKinematics setting this to true will force kinematic functions
228 to use the values of Q, QDot, and QDDot passed into this function.
229
230 */
231
232 void calcPointAccelerations(Model &model,
233 const Math::VectorNd &Q,
234 const Math::VectorNd &QDot,
235 const Math::VectorNd &QDDot,
236 Math::Vector3d &pointAccelerationUpd,
237 bool updateKinematics=false);
238
239
240 /*** @brief To support ForwardDynamicsKokkevis
241 @param model a reference to the multibody model
242 @param pointAccelerationSysUpd the system's vector of point accelerations
243 @param ddErrSysUpd: the error in the the acceleration of the point in this
244 constraint along the normal directions.
245
246 */
247 void calcPointAccelerationError(
248 const std::vector<Math::Vector3d> &pointAccelerationsSys,
249 Math::VectorNd &ddErrSysUpd);
250
251 /*** @brief To support ForwardDynamicsKokkevis
252 @param model a reference to the multibody model
253 @param Q: the generalized positions of the model
254 @param cache: a ConstraintCache struct used for working memory
255 @param fExtSysUpd: the point force constraint Jacobian
256 @param updateKinematics setting this to true will force kinematic functions
257 to use the value of Q passed in.
258 */
259 void calcPointForceJacobian(
260 Model &model,
261 const Math::VectorNd &Q,
262 ConstraintCache &cache,
263 std::vector<Math::SpatialVector> &fExtSysUpd,
264 bool updateKinematics=false);
265
266private:
268 std::vector< Math::Vector3d > T;
272 double dblA;
273
274};
275
276
277
278}
279
280/* RBDL_CONTACT_CONSTRAINT_H */
281#endif
Interface to define general-purpose constraints.
Definition: Constraint.h:139
Implements a rigid kinematic body-point–to–ground constraint along a normal direction as described in...
Math::Vector3d groundPoint
The location of the ground reference point.
std::vector< Math::Vector3d > T
A vector of the ground normal vectors used in this constraint.
const std::vector< Math::Vector3d > & getConstraintNormalVectors()