Choreonoid  1.1
BodyMotion.h
説明を見る。
1 
6 #ifndef CNOID_BODY_BODY_MOTION_H_INCLUDED
7 #define CNOID_BODY_BODY_MOTION_H_INCLUDED
8 
9 #include <cnoid/MultiValueSeq>
10 #include <cnoid/MultiAffine3Seq>
11 #include <cnoid/Vector3Seq>
12 #include "exportdecl.h"
13 
14 namespace cnoid {
15 
17  {
18  public:
19  BodyMotion();
20  BodyMotion(const BodyMotion& org);
21 
22  virtual void setDimension(int numFrames, int numJoints, bool clearNewArea = false);
23 
24  void setDimension(int numFrames, int numJoints, int numLinks, bool clearNewArea = false);
25 
26  virtual void setNumParts(int numParts, bool clearNewElements = false);
27  virtual int getNumParts() const;
28 
29  inline int numJoints() const { return jointPosSeq_->numParts(); }
30  inline int numLinks() const { return linkPosSeq_->numParts(); }
31 
32  inline double frameRate() const { return jointPosSeq_->frameRate(); }
33  virtual double getFrameRate() const;
34  virtual void setFrameRate(double frameRate);
35 
36  inline int numFrames() const {
37  return std::max(jointPosSeq_->numFrames(), linkPosSeq_->numFrames());
38  }
39  virtual int getNumFrames() const;
40  virtual void setNumFrames(int n, bool clearNewArea = false);
41 
43  return jointPosSeq_;
44  }
45 
46  inline const MultiValueSeqPtr& jointPosSeq() const {
47  return jointPosSeq_;
48  }
49 
51  return linkPosSeq_;
52  }
53 
54  inline const MultiAffine3SeqPtr& linkPosSeq() const {
55  return linkPosSeq_;
56  }
57 
58  inline bool hasRelativeZmpSeq() { return relativeZmpSeq_; }
59  const Vector3SeqPtr& relativeZmpSeq();
60 
61  class Frame {
62  const BodyMotion& motion_;
63  int frame_;
64  Frame(const BodyMotion& motion, int frame) : motion_(motion), frame_(frame) { }
65  public:
66  Frame(const Frame& org) : motion_(org.motion_), frame_(org.frame_) { }
67  inline BodyMotion& motion() { return const_cast<BodyMotion&>(motion_); }
68  inline const BodyMotion& motion() const { return motion_; }
69  inline int frame() const { return frame_; }
70 
71  friend class BodyMotion;
72  };
73 
74  inline Frame frame(int frame) { return Frame(*this, frame); }
75  inline const Frame frame(int frame) const { return Frame(*this, frame); }
76 
77  virtual bool read(const YamlMapping& archive);
78  virtual bool write(YamlWriter& writer);
79 
80  bool loadStandardYamlFormat(const std::string& filename);
81  bool saveAsStandardYamlFormat(const std::string& filename);
82 
83  private:
84 
85  MultiValueSeqPtr jointPosSeq_;
86  MultiAffine3SeqPtr linkPosSeq_;
87  Vector3SeqPtr relativeZmpSeq_;
88  };
89 
90  typedef boost::shared_ptr<BodyMotion> BodyMotionPtr;
91 
92  class Body;
93 
96 }
97 
98 #endif