Choreonoid  1.8
AISTSimulatorItem.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODYPLUGIN_AIST_SIMULATOR_ITEM_H
7 #define CNOID_BODYPLUGIN_AIST_SIMULATOR_ITEM_H
8 
9 #include "SimulatorItem.h"
10 #include <cnoid/Collision>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class ContactMaterial;
16 class ExtraJoint;
17 
18 class CNOID_EXPORT AISTSimulatorItem : public SimulatorItem
19 {
20 public:
21  static void initializeClass(ExtensionManager* ext);
22 
25  virtual ~AISTSimulatorItem();
26 
27  enum DynamicsMode { FORWARD_DYNAMICS = 0, KINEMATICS, N_DYNAMICS_MODES };
28  enum IntegrationMode { EULER_INTEGRATION = 0, RUNGE_KUTTA_INTEGRATION, N_INTEGRATION_MODES };
29 
30  void setDynamicsMode(int mode);
31  void setIntegrationMode(int mode);
32  void setGravity(const Vector3& gravity);
33  const Vector3& gravity() const;
34  void setFrictionCoefficientRange(double minFriction, double maxFriction);
35  double minFrictionCoefficient() const;
36  double maxFrictionCoefficient() const;
37  void setContactCullingDistance(double value);
38  void setContactCullingDepth(double value);
39  void setErrorCriterion(double value);
40  void setMaxNumIterations(int value);
41  void setContactCorrectionDepth(double value);
42  void setContactCorrectionVelocityRatio(double value);
43  void setEpsilon(double epsilon);
44  void set2Dmode(bool on);
45  void setKinematicWalkingEnabled(bool on);
46 
47  [[deprecated("This function does nothing. Set Link::LinkContactState to Link::sensingMode from a controller.")]]
48  void setConstraintForceOutputEnabled(bool on);
49 
50  void addExtraJoint(ExtraJoint& extraJoint);
51  void clearExtraJoints();
52 
53  virtual Vector3 getGravity() const override;
54  virtual void setForcedPosition(BodyItem* bodyItem, const Isometry3& T) override;
55  virtual bool isForcedPositionActiveFor(BodyItem* bodyItem) const override;
56  virtual void clearForcedPositions() override;
57 
58  typedef std::function<bool(Link* link1, Link* link2,
59  const CollisionArray& collisions,
60  ContactMaterial* contactMaterial)> CollisionHandler;
61 
62  void registerCollisionHandler(const std::string& name, CollisionHandler handler);
63  bool unregisterCollisionHandler(const std::string& name);
64 
66  void setFriction(Link* link1, Link* link2, double staticFriction, double dynamicFriction);
67 
68 protected:
69  virtual SimulationBody* createSimulationBody(Body* orgBody, CloneMap& cloneMap) override;
70  virtual bool initializeSimulation(const std::vector<SimulationBody*>& simBodies) override;
71  virtual bool completeInitializationOfSimulation() override;
72  virtual bool stepSimulation(const std::vector<SimulationBody*>& activeSimBodies) override;
73  virtual void finalizeSimulation() override;
74  virtual std::shared_ptr<CollisionLinkPairList> getCollisions() override;
75 
76  virtual Item* doDuplicate() const override;
77  virtual void doPutProperties(PutPropertyFunction& putProperty) override;
78  virtual bool store(Archive& archive) override;
79  virtual bool restore(const Archive& archive) override;
80 
81 private:
82  class Impl;
83  Impl* impl;
84 };
85 
87 
88 }
89 
90 #endif
cnoid::CollisionArray
std::vector< Collision > CollisionArray
Definition: Collision.h:27
cnoid::AISTSimulatorItem::CollisionHandler
std::function< bool(Link *link1, Link *link2, const CollisionArray &collisions, ContactMaterial *contactMaterial)> CollisionHandler
Definition: AISTSimulatorItem.h:60
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::AISTSimulatorItemPtr
ref_ptr< AISTSimulatorItem > AISTSimulatorItemPtr
Definition: AISTSimulatorItem.h:86
cnoid::ExtensionManager
Definition: ExtensionManager.h:23
cnoid::PutPropertyFunction
Definition: PutPropertyFunction.h:51
cnoid::Isometry3
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
cnoid::Archive
Definition: Archive.h:22
cnoid::ref_ptr
Definition: Referenced.h:103
cnoid::BodyItem
Definition: BodyItem.h:28
cnoid::SimulationBody
Definition: SimulatorItem.h:29
cnoid::AISTSimulatorItem::IntegrationMode
IntegrationMode
Definition: AISTSimulatorItem.h:28
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::Item
Definition: Item.h:29
cnoid::CloneMap
Definition: CloneMap.h:13
cnoid::ContactMaterial
Definition: ContactMaterial.h:14
cnoid::AISTSimulatorItem
Definition: AISTSimulatorItem.h:18
cnoid::AISTSimulatorItem::RUNGE_KUTTA_INTEGRATION
@ RUNGE_KUTTA_INTEGRATION
Definition: AISTSimulatorItem.h:28
cnoid::ExtraJoint
Definition: ExtraJoint.h:13
cnoid::Body
Definition: Body.h:28
SimulatorItem.h
cnoid::AISTSimulatorItem::DynamicsMode
DynamicsMode
Definition: AISTSimulatorItem.h:27
cnoid::SimulatorItem
Definition: SimulatorItem.h:81