DART 6.13.2
|
ConstraintSolver manages constraints and computes constraint impulses. More...
#include <ConstraintSolver.hpp>
Public Member Functions | |
ConstraintSolver (double timeStep) | |
Constructor. | |
ConstraintSolver () | |
Default constructor. | |
ConstraintSolver (const ConstraintSolver &other)=delete | |
Copy constructor. | |
virtual | ~ConstraintSolver ()=default |
Destructor. | |
void | addSkeleton (const dynamics::SkeletonPtr &skeleton) |
Add single skeleton. | |
void | addSkeletons (const std::vector< dynamics::SkeletonPtr > &skeletons) |
Add mutiple skeletons. | |
const std::vector< dynamics::SkeletonPtr > & | getSkeletons () const |
Returns all the skeletons added to this ConstraintSolver. | |
void | removeSkeleton (const dynamics::SkeletonPtr &skeleton) |
Remove single skeleton. | |
void | removeSkeletons (const std::vector< dynamics::SkeletonPtr > &skeletons) |
Remove multiple skeletons. | |
void | removeAllSkeletons () |
Remove all skeletons in this constraint solver. | |
void | addConstraint (const ConstraintBasePtr &constraint) |
Add a constraint. | |
void | removeConstraint (const ConstraintBasePtr &constraint) |
Remove a constraint. | |
void | removeAllConstraints () |
Remove all constraints. | |
std::size_t | getNumConstraints () const |
Returns the number of constraints that was manually added to this ConstraintSolver. | |
constraint::ConstraintBasePtr | getConstraint (std::size_t index) |
Returns a constraint by index. | |
constraint::ConstConstraintBasePtr | getConstraint (std::size_t index) const |
Returns a constraint by index. | |
std::vector< constraint::ConstraintBasePtr > | getConstraints () |
Returns all the constraints added to this ConstraintSolver. | |
std::vector< constraint::ConstConstraintBasePtr > | getConstraints () const |
Returns all the constraints added to this ConstraintSolver. | |
template<typename Func > | |
void | eachConstraint (Func func) const |
Iterates all the constraints and invokes the callback function. | |
template<typename Func > | |
void | eachConstraint (Func func) |
Iterates all the constraints and invokes the callback function. | |
void | clearLastCollisionResult () |
Clears the last collision result. | |
virtual void | setTimeStep (double _timeStep) |
Set time step. | |
double | getTimeStep () const |
Get time step. | |
void | setCollisionDetector (collision::CollisionDetector *collisionDetector) |
Set collision detector. | |
void | setCollisionDetector (const std::shared_ptr< collision::CollisionDetector > &collisionDetector) |
Set collision detector. | |
collision::CollisionDetectorPtr | getCollisionDetector () |
Get collision detector. | |
collision::ConstCollisionDetectorPtr | getCollisionDetector () const |
Get (const) collision detector. | |
collision::CollisionGroupPtr | getCollisionGroup () |
Return collision group of collision objects that are added to this ConstraintSolver. | |
collision::ConstCollisionGroupPtr | getCollisionGroup () const |
Return (const) collision group of collision objects that are added to this ConstraintSolver. | |
collision::CollisionOption & | getCollisionOption () |
Returns collision option that is used for collision checkings in this ConstraintSolver to generate contact constraints. | |
const collision::CollisionOption & | getCollisionOption () const |
Returns collision option that is used for collision checkings in this ConstraintSolver to generate contact constraints. | |
collision::CollisionResult & | getLastCollisionResult () |
Return the last collision checking result. | |
const collision::CollisionResult & | getLastCollisionResult () const |
Return the last collision checking result. | |
void | setLCPSolver (std::unique_ptr< LCPSolver > lcpSolver) |
Set LCP solver. | |
LCPSolver * | getLCPSolver () const |
Get LCP solver. | |
void | solve () |
Solve constraint impulses and apply them to the skeletons. | |
virtual void | setFromOtherConstraintSolver (const ConstraintSolver &other) |
Sets this constraint solver using other constraint solver. | |
ContactSurfaceHandlerPtr | getLastContactSurfaceHandler () const |
Get the handler used for computing contact surface parameters based on the contact properties of the two colliding bodies. | |
void | addContactSurfaceHandler (ContactSurfaceHandlerPtr handler) |
Set the handler used for computing contact surface parameters based on the contact properties of the two colliding bodies. | |
bool | removeContactSurfaceHandler (const ContactSurfaceHandlerPtr &handler) |
Remove the given contact surface handler. | |
Protected Types | |
using | CollisionDetector = collision::CollisionDetector |
Protected Member Functions | |
virtual void | solveConstrainedGroup (ConstrainedGroup &group)=0 |
bool | containSkeleton (const dynamics::ConstSkeletonPtr &skeleton) const |
Checks if the skeleton is contained in this solver. | |
bool | hasSkeleton (const dynamics::ConstSkeletonPtr &skeleton) const |
Checks if the skeleton is contained in this solver. | |
bool | checkAndAddSkeleton (const dynamics::SkeletonPtr &skeleton) |
Add skeleton if the constraint is not contained in this solver. | |
bool | containConstraint (const ConstConstraintBasePtr &constraint) const |
Check if the constraint is contained in this solver. | |
bool | checkAndAddConstraint (const ConstraintBasePtr &constraint) |
Add constraint if the constraint is not contained in this solver. | |
void | updateConstraints () |
Update constraints. | |
void | buildConstrainedGroups () |
Build constrained groupsContact. | |
void | solveConstrainedGroups () |
Solve constrained groups. | |
bool | isSoftContact (const collision::Contact &contact) const |
Return true if at least one of colliding body is soft body. | |
Protected Attributes | |
collision::CollisionDetectorPtr | mCollisionDetector |
Collision detector. | |
collision::CollisionGroupPtr | mCollisionGroup |
Collision group. | |
collision::CollisionOption | mCollisionOption |
Collision detection option. | |
collision::CollisionResult | mCollisionResult |
Last collision checking result. | |
double | mTimeStep |
Time step. | |
std::vector< dynamics::SkeletonPtr > | mSkeletons |
Skeleton list. | |
std::vector< ContactConstraintPtr > | mContactConstraints |
Contact constraints those are automatically created. | |
std::vector< SoftContactConstraintPtr > | mSoftContactConstraints |
Soft contact constraints those are automatically created. | |
std::vector< JointConstraintPtr > | mJointConstraints |
Joint limit constraints those are automatically created. | |
std::vector< MimicMotorConstraintPtr > | mMimicMotorConstraints |
Mimic motor constraints those are automatically created. | |
std::vector< JointCoulombFrictionConstraintPtr > | mJointCoulombFrictionConstraints |
Joint Coulomb friction constraints those are automatically created. | |
std::vector< ConstraintBasePtr > | mManualConstraints |
Constraints that manually added. | |
std::vector< ConstraintBasePtr > | mActiveConstraints |
Active constraints. | |
std::vector< ConstrainedGroup > | mConstrainedGroups |
Constraint group list. | |
ContactSurfaceHandlerPtr | mContactSurfaceHandler |
Factory for ContactSurfaceParams for each contact. | |
ConstraintSolver manages constraints and computes constraint impulses.
|
protected |
|
explicit |
Constructor.
dart::constraint::ConstraintSolver::ConstraintSolver | ( | ) |
Default constructor.
|
delete |
Copy constructor.
|
virtualdefault |
Destructor.
void dart::constraint::ConstraintSolver::addConstraint | ( | const ConstraintBasePtr & | constraint | ) |
Add a constraint.
void dart::constraint::ConstraintSolver::addContactSurfaceHandler | ( | ContactSurfaceHandlerPtr | handler | ) |
Set the handler used for computing contact surface parameters based on the contact properties of the two colliding bodies.
This function automatically sets the previous handler as parent of the given handler.
void dart::constraint::ConstraintSolver::addSkeleton | ( | const dynamics::SkeletonPtr & | skeleton | ) |
Add single skeleton.
void dart::constraint::ConstraintSolver::addSkeletons | ( | const std::vector< dynamics::SkeletonPtr > & | skeletons | ) |
Add mutiple skeletons.
|
protected |
Build constrained groupsContact.
|
protected |
Add constraint if the constraint is not contained in this solver.
|
protected |
Add skeleton if the constraint is not contained in this solver.
void dart::constraint::ConstraintSolver::clearLastCollisionResult | ( | ) |
Clears the last collision result.
|
protected |
Check if the constraint is contained in this solver.
|
protected |
Checks if the skeleton is contained in this solver.
void dart::constraint::ConstraintSolver::eachConstraint | ( | Func | func | ) |
Iterates all the constraints and invokes the callback function.
Func | The callback function type. The function signature should be equivalent to void(ConstraintBase*) or bool(ConstraintBase*) . If you want to conditionally iterate, use bool(ConstraintBase*) and return false when to stop iterating. |
[in] | func | The callback function to be called for each ConstraintBase. |
void dart::constraint::ConstraintSolver::eachConstraint | ( | Func | func | ) | const |
Iterates all the constraints and invokes the callback function.
Func | The callback function type. The function signature should be equivalent to void(const ConstraintBase*) or bool(const
ConstraintBase*) . If you want to conditionally iterate, use bool(const
ConstraintBase*) and return false when to stop iterating. |
[in] | func | The callback function to be called for each ConstraintBase. |
collision::CollisionDetectorPtr dart::constraint::ConstraintSolver::getCollisionDetector | ( | ) |
Get collision detector.
collision::ConstCollisionDetectorPtr dart::constraint::ConstraintSolver::getCollisionDetector | ( | ) | const |
Get (const) collision detector.
collision::CollisionGroupPtr dart::constraint::ConstraintSolver::getCollisionGroup | ( | ) |
Return collision group of collision objects that are added to this ConstraintSolver.
collision::ConstCollisionGroupPtr dart::constraint::ConstraintSolver::getCollisionGroup | ( | ) | const |
Return (const) collision group of collision objects that are added to this ConstraintSolver.
collision::CollisionOption & dart::constraint::ConstraintSolver::getCollisionOption | ( | ) |
Returns collision option that is used for collision checkings in this ConstraintSolver to generate contact constraints.
const collision::CollisionOption & dart::constraint::ConstraintSolver::getCollisionOption | ( | ) | const |
Returns collision option that is used for collision checkings in this ConstraintSolver to generate contact constraints.
ConstraintBasePtr dart::constraint::ConstraintSolver::getConstraint | ( | std::size_t | index | ) |
Returns a constraint by index.
ConstConstraintBasePtr dart::constraint::ConstraintSolver::getConstraint | ( | std::size_t | index | ) | const |
Returns a constraint by index.
std::vector< ConstraintBasePtr > dart::constraint::ConstraintSolver::getConstraints | ( | ) |
Returns all the constraints added to this ConstraintSolver.
std::vector< ConstConstraintBasePtr > dart::constraint::ConstraintSolver::getConstraints | ( | ) | const |
Returns all the constraints added to this ConstraintSolver.
collision::CollisionResult & dart::constraint::ConstraintSolver::getLastCollisionResult | ( | ) |
Return the last collision checking result.
const collision::CollisionResult & dart::constraint::ConstraintSolver::getLastCollisionResult | ( | ) | const |
Return the last collision checking result.
ContactSurfaceHandlerPtr dart::constraint::ConstraintSolver::getLastContactSurfaceHandler | ( | ) | const |
Get the handler used for computing contact surface parameters based on the contact properties of the two colliding bodies.
LCPSolver * dart::constraint::ConstraintSolver::getLCPSolver | ( | ) | const |
Get LCP solver.
std::size_t dart::constraint::ConstraintSolver::getNumConstraints | ( | ) | const |
Returns the number of constraints that was manually added to this ConstraintSolver.
const std::vector< SkeletonPtr > & dart::constraint::ConstraintSolver::getSkeletons | ( | ) | const |
Returns all the skeletons added to this ConstraintSolver.
double dart::constraint::ConstraintSolver::getTimeStep | ( | ) | const |
Get time step.
|
protected |
Checks if the skeleton is contained in this solver.
|
protected |
Return true if at least one of colliding body is soft body.
void dart::constraint::ConstraintSolver::removeAllConstraints | ( | ) |
Remove all constraints.
void dart::constraint::ConstraintSolver::removeAllSkeletons | ( | ) |
Remove all skeletons in this constraint solver.
void dart::constraint::ConstraintSolver::removeConstraint | ( | const ConstraintBasePtr & | constraint | ) |
Remove a constraint.
bool dart::constraint::ConstraintSolver::removeContactSurfaceHandler | ( | const ContactSurfaceHandlerPtr & | handler | ) |
Remove the given contact surface handler.
If it is not the last in the chain of handlers, the neighbor handlers are automatically connected when the given handler is removed. This function returns true when the given handler was found. It returns false when the handler is not found. The search procedure utilizes pointer equality (i.e. the shared pointers have to point to the same address to be treated equal). Take special care to make sure at least one handler is always available.
void dart::constraint::ConstraintSolver::removeSkeleton | ( | const dynamics::SkeletonPtr & | skeleton | ) |
Remove single skeleton.
void dart::constraint::ConstraintSolver::removeSkeletons | ( | const std::vector< dynamics::SkeletonPtr > & | skeletons | ) |
Remove multiple skeletons.
void dart::constraint::ConstraintSolver::setCollisionDetector | ( | collision::CollisionDetector * | collisionDetector | ) |
Set collision detector.
This function acquires ownership of the CollisionDetector passed as an argument. This method is deprecated in favor of the overload that accepts a std::shared_ptr.
void dart::constraint::ConstraintSolver::setCollisionDetector | ( | const std::shared_ptr< collision::CollisionDetector > & | collisionDetector | ) |
Set collision detector.
|
virtual |
Sets this constraint solver using other constraint solver.
All the properties and registered skeletons and constraints will be copied over.
void dart::constraint::ConstraintSolver::setLCPSolver | ( | std::unique_ptr< LCPSolver > | lcpSolver | ) |
Set LCP solver.
|
virtual |
Set time step.
void dart::constraint::ConstraintSolver::solve | ( | ) |
Solve constraint impulses and apply them to the skeletons.
|
protectedpure virtual |
Implemented in dart::constraint::BoxedLcpConstraintSolver.
|
protected |
Solve constrained groups.
|
protected |
Update constraints.
|
protected |
Active constraints.
|
protected |
Collision detector.
|
protected |
Collision group.
|
protected |
Collision detection option.
|
protected |
Last collision checking result.
|
protected |
Constraint group list.
|
protected |
Contact constraints those are automatically created.
|
protected |
Factory for ContactSurfaceParams for each contact.
|
protected |
Joint limit constraints those are automatically created.
|
protected |
Joint Coulomb friction constraints those are automatically created.
|
protected |
Constraints that manually added.
|
protected |
Mimic motor constraints those are automatically created.
|
protected |
Skeleton list.
|
protected |
Soft contact constraints those are automatically created.
|
protected |
Time step.