Choreonoid  1.8
LeggedBodyHelper.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_BODY_LEGGED_BODY_HELPER_H
7 #define CNOID_BODY_LEGGED_BODY_HELPER_H
8 
9 #include "Body.h"
10 #include "InverseKinematics.h"
11 #include <memory>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
16 class CNOID_EXPORT LeggedBodyHelper : public Referenced
17 {
18 public:
20  LeggedBodyHelper(Body* body);
22 
23  bool isValid() const { return isValid_; }
24  virtual bool resetBody(Body* body);
25 
26  virtual ~LeggedBodyHelper();
27 
28  Body* body() const { return body_; }
29 
30  int numFeet() const { return footInfos.size(); }
31 
32  Link* footLink(int index) const { return footInfos[index].link; }
33 
34  Link* kneePitchJoint(int footIndex) const { return footInfos[footIndex].kneePitchJoint; }
35 
36  std::shared_ptr<InverseKinematics> getFootBasedIK(Link* targetLink);
37 
38  bool doLegIkToMoveCm(const Vector3& c, bool onlyProjectionToFloor = false);
39  bool setStance(double width, Link* baseLink);
40 
41  const Vector3& centerOfSoleLocal(int footIndex) const { return footInfos[footIndex].soleCenter; }
42 
43  Vector3 centerOfSole(int footIndex) const;
44  Vector3 centerOfSoles() const;
45 
46  Vector3 homeCopOfSole(int footIndex) const;
47  Vector3 homeCopOfSoles() const;
48 
49 private:
50  BodyPtr body_;
51  bool isValid_;
52  struct FootInfo {
53  Link* link;
54  Link* kneePitchJoint;
55  Vector3 homeCop;
56  Vector3 soleCenter;
57  };
58  std::vector<FootInfo> footInfos;
59 };
60 
62 
63 CNOID_EXPORT LeggedBodyHelper* getLeggedBodyHelper(Body* body);
64 
65 }
66 
67 #endif
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::LeggedBodyHelper::body
Body * body() const
Definition: LeggedBodyHelper.h:28
cnoid::LeggedBodyHelper::footLink
Link * footLink(int index) const
Definition: LeggedBodyHelper.h:32
cnoid::ref_ptr< Body >
cnoid::LeggedBodyHelperPtr
ref_ptr< LeggedBodyHelper > LeggedBodyHelperPtr
Definition: LeggedBodyHelper.h:61
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::getLeggedBodyHelper
LeggedBodyHelper * getLeggedBodyHelper(Body *body)
Definition: LeggedBodyHelper.cpp:18
cnoid::LeggedBodyHelper::numFeet
int numFeet() const
Definition: LeggedBodyHelper.h:30
cnoid::Referenced
Definition: Referenced.h:54
Body.h
cnoid::LeggedBodyHelper::kneePitchJoint
Link * kneePitchJoint(int footIndex) const
Definition: LeggedBodyHelper.h:34
cnoid::LeggedBodyHelper::centerOfSoleLocal
const Vector3 & centerOfSoleLocal(int footIndex) const
Definition: LeggedBodyHelper.h:41
cnoid::Body
Definition: Body.h:28
cnoid::LeggedBodyHelper::isValid
bool isValid() const
Definition: LeggedBodyHelper.h:23
InverseKinematics.h
cnoid::LeggedBodyHelper
Definition: LeggedBodyHelper.h:16