Choreonoid  1.8
ConstraintForceSolver.h
Go to the documentation of this file.
1 
5 #ifndef CNOID_BODY_CONSTRAINT_FORCE_SOLVER_H
6 #define CNOID_BODY_CONSTRAINT_FORCE_SOLVER_H
7 
8 #include <cnoid/CollisionSeq>
9 #include "exportdecl.h"
10 
11 namespace cnoid {
12 
13 class Link;
14 class DyWorldBase;
15 class CollisionDetector;
16 class ContactMaterial;
17 class MaterialTable;
18 
19 class CNOID_EXPORT ConstraintForceSolver
20 {
21 public:
24 
25  void setCollisionDetector(CollisionDetector* detector);
26  CollisionDetector* collisionDetector();
27 
28  void setBodyCollisionDetectionMode(
29  int bodyIndex, bool isBodyToBodyCollisionEnabled, bool isSelfCollisionDetectionEnabled);
30 
31  void setMaterialTable(MaterialTable* table);
32 
33  void setFrictionCoefficientRange(double minFriction, double maxFriction);
34  double minFrictionCoefficient() const;
35  double maxFrictionCoefficient() const;
36 
37  void setContactCullingDistance(double thresh);
38  double contactCullingDistance() const;
39 
40  void setContactCullingDepth(double depth);
41  double contactCullingDepth();
42 
43  void setCoefficientOfRestitution(double epsilon);
44  double coefficientOfRestitution() const;
45 
46  void setGaussSeidelErrorCriterion(double e);
47  double gaussSeidelErrorCriterion();
48 
49  void setGaussSeidelMaxNumIterations(int n);
50  int gaussSeidelMaxNumIterations();
51 
52  void setContactDepthCorrection(double depth, double velocityRatio);
53  double contactCorrectionDepth();
54  double contactCorrectionVelocityRatio();
55 
56  void set2Dmode(bool on);
57 
58  [[deprecated("This function does nothing. Set Link::LinkContactState to Link::sensingMode from a controller.")]]
59  void enableConstraintForceOutput(bool on);
60 
61  void initialize(void);
62  void solve();
63  void clearExternalForces();
64 
65  std::shared_ptr<CollisionLinkPairList> getCollisions();
66 
67  // experimental functions
68  typedef std::function<bool(Link* link1, Link* link2,
69  const CollisionArray& collisions,
70  ContactMaterial* contactMaterial)> CollisionHandler;
71 
72  void registerCollisionHandler(const std::string& name, CollisionHandler handler);
73  bool unregisterCollisionHandler(const std::string& name);
74 
75 private:
76  class Impl;
77  Impl* impl;
78 };
79 
80 };
81 
82 #endif
cnoid::CollisionArray
std::vector< Collision > CollisionArray
Definition: Collision.h:27
cnoid::DyWorldBase
Definition: DyWorld.h:17
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::ContactMaterial
Definition: ContactMaterial.h:14
cnoid::CollisionDetector
Definition: CollisionDetector.h:20
cnoid::ConstraintForceSolver::CollisionHandler
std::function< bool(Link *link1, Link *link2, const CollisionArray &collisions, ContactMaterial *contactMaterial)> CollisionHandler
Definition: ConstraintForceSolver.h:70
cnoid::ConstraintForceSolver
Definition: ConstraintForceSolver.h:19
cnoid::MaterialTable
Definition: MaterialTable.h:18