base class for dynamic constraints.
base class for dynamic constraints. The constraint class is used to create dynamic constraints on mechanisms. Constraints restrict the motion of a mechanism by ensuring that the first and second derivatives of a constraint equation are zero. There are two general classes of constraints: bilateral constraints and unilateral constraints (represented by the classes bconstraint and uconstraint, respectively). The constraint equations for bilateral constraints are of the formC(t) = 0while unilateral constraints are of the formC(t) >= 0An example of a bilateral constraint is a mechanism with a closed kinematic chain, while a joint limit is a unilateral constraint. Unilateral constraints are much trickier (and more computationally expensive) to deal with than bilateral constraints.From a usage point of view, you simply create a constraint and then call dynamicSystem::addConstraint(). Note that the mechanism(s) which are acted on by the constraint must already belong to a dynamicSystem before you call addConstraint()--otherwise, the constraint won't know what system to add itself to. If you wish to delete a constraint, use dynamicSystem::deleteConstraint. If you only wish to temporarily deactivate a constraint, set its 'active' member to 0. Constraints are associated with mechanisms, and if you do not explicitly remove and delete a constraint, the mechanism will do it automatically when you delete the mechanism. Note that you can only create constraints with the new operator; you can't declare static, global, or automatic constraints. (This is enforced by having a protected destructor.)
Creating new constraint classes is more involved, and unfortunately I don't have time to write about it right now! In the meantime, look at the source for one of the derived classes to get you on your way.
Random notes:
- Don't create any s-vals (or do anything else depending on mechanism or joint offsets, indices, systemDOFs, or s-vals) in the constructor since, at the time the constructor is called, mechanisms have not been reparented to reflect the new constraint. Instead, do these things in createConstraintEquations().
Note that derived classes must allocate an array (even if only size 1) of linkForceRecords and assign it to frec in getForces(), as that behavior is expected by applyToMech().
Alphabetic index HTML hierarchy of classes or Java