Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

PHJointPid.h

00001 #ifndef PH_JOINTPID_H
00002 #define PH_JOINTPID_H
00003 
00004 #include <Physics/PHJoint1D.h>
00005 #include <Physics/PHJointMulti.h>
00006 
00007 namespace Spr{;
00008 
00009 class PHJointPid:public SGBehaviorEngine{
00010 protected:
00011     /// ‘O‰ñ‚Ì–Ú•W’l
00012     float lastGoal;
00013     /// Ï•ª
00014     float integratedError;
00015 public:
00016     SGOBJECTDEF(PHJointPid);
00017     /// §Œä‘Ώۊ֐ß
00018     UTRef<PHJointBase> joint;
00019     /// ‘Ώۂ̎²
00020     int axis;
00021     /// –Ú•W’l      Step()‚ðŒÄ‚Ô‘O‚ɐݒ肷‚éD
00022     float goal;
00023     /// –Ú•W‚Ì‘¬“x  Step()‚ðŒÄ‚Ô‘O‚ɐݒ肷‚éD
00024     float dGoal;
00025     /// PID‚ÌŒW”
00026     float proportional, differential, integral;
00027     /// –Ú•W‚̃^ƒCƒv 0:ˆÊ’u§Œä 1F‘¬“x§Œä
00028     int type;
00029     /// proportional,differential,integral‚É‚æ‚éƒgƒ‹ƒN(PID§Œä)
00030     float pTorque, dTorque, iTorque;
00031 
00032     /// p_torque, d_torque,i_torque‚̎擾
00033     float GetProportionalTorque(){ return pTorque; }
00034     float GetDifferentialTorque(){ return dTorque; }
00035     float GetIntegralTorque(){ return iTorque; }
00036 
00037     /// –Ú•W’l,–Ú•W‚Ì‘¬“x   Step()‚ðŒÄ‚Ô‘O‚ɐݒ肷‚é
00038     void SetPGoal(float p_goal){ goal = p_goal;}
00039     void SetDGoal(float d_goal){ dGoal = d_goal;}
00040     
00041     /// 
00042     PHJointPid():type(0), proportional(0), differential(0), integral(0), goal(0), dGoal(FLT_MAX), lastGoal(0), integratedError(0), axis(0){}
00043     ///
00044     void Print(std::ostream& os) const;
00045     ///
00046     static PHJointPid* Find(PHJoint1D* j, SGScene* scene);
00047     /// ƒvƒ‰ƒCƒIƒŠƒeƒB
00048     virtual int GetPriority() const { return SGBP_FORCEGENERATOR; }
00049     /// ƒV[ƒ“‚ðƒNƒŠƒA‚·‚邯‚«‚̏ˆ—
00050     virtual void Clear(SGScene* s){ joint=NULL; }
00051 
00052     /// ó‘Ԃ̓ǂݏo‚µ
00053     virtual void LoadState(const SGBehaviorStates& states);
00054     /// ó‘Ԃ̕ۑ¶
00055     virtual void SaveState(SGBehaviorStates& states) const;
00056     /// PID§Œä‚ð‚©‚¯‚éD
00057     void Step(SGScene* s);  
00058 
00059     ///
00060     double GetJointTorque(){ return joint->GetJointTorque(axis); }
00061 
00062     size_t NReferenceObjects();
00063     SGObject* ReferenceObject(size_t i);
00064     bool AddChildObject(SGObject* o, SGScene* s);
00065     bool DelChildObject(SGObject* o, SGScene* s);
00066 protected:
00067 };
00068 
00069 
00070 
00071 /*  ‰Â“®ˆæ‚ɂ‚¢‚Ä
00072     ƒjƒ…[ƒgƒ‰ƒ‹‚ð‚Ü‚Á‚·‚®‚Æ‚µ‚āC
00073     - ƒÆEƒÓ‚̃Oƒ‰ƒt‚ʼn“®ˆæ‚ð•\‚·DÜ‚êü‹ßŽ—D
00074     - ÅŒã‚ÌŽ²‚Í,’萔 or ’†S‚Æ ƒÆEƒÓ‚̐ݒè“_‚ɂ‚¢‚ĐݒèD
00075     - ƒÆEƒÓ‚͈ᔽ‚µ‚½‚çCÅŠñ‚̃ƁEƒÓ‚ÉŒü‚©‚Á‚ÄPID§ŒäD
00076 ƒR[ƒ“‚Å—Ç‚¢àD
00077 ƒR[ƒ“‚Ì’†S‚ÌŒü‚«Vec3f ‚ÆŠp“xƒÆ‚¾‚¯‚ł悢D
00078 */
00079 class PHJointBallPid:public SGBehaviorEngine{
00080 protected:
00081     /// ‘O‰ñ‚̃S[ƒ‹
00082     Quaterniond lastGoal;
00083     /// Ï•ª
00084     Vec3f integratedError;
00085 public:
00086     SGOBJECTDEF(PHJointBallPid);
00087     /// §Œä‘Ώۊ֐ß
00088     UTRef<PHJointBall> joint;
00089     /// –Ú•W’l          Step()‚ðŒÄ‚Ô‘O‚ɐݒ肷‚éD
00090     Quaternionf goal;
00091     /// –Ú•W’l‚Ì”÷•ª    Step()‚ðŒÄ‚Ô‘O‚ɐݒ肷‚éDÝ’肵‚È‚­‚Ä‚à—Ç‚¢D
00092     Vec3f dGoal;
00093     /// PID‚ÌŒW”
00094     float proportional, differential, integral;
00095     /// proportional,differential,integral‚É‚æ‚éƒgƒ‹ƒN(PID§Œä)
00096     Vec3f pTorque, dTorque, iTorque;
00097 
00098     /// p_torque, d_torque,i_torque‚̎擾
00099     Vec3f GetProportionalTorque(){ return pTorque; }
00100     Vec3f GetDifferentialTorque(){ return dTorque; }
00101     Vec3f GetIntegralTorque(){ return iTorque; }
00102     
00103     /// 
00104     PHJointBallPid():proportional(0), differential(0), integral(0), dGoal(FLT_MAX,0,0){}
00105     ///
00106     static PHJointBallPid* Find(PHJointBall* j, SGScene* scene);
00107     /// ƒvƒ‰ƒCƒIƒŠƒeƒB
00108     virtual int GetPriority() const { return SGBP_FORCEGENERATOR; }
00109     /// ƒV[ƒ“‚ðƒNƒŠƒA‚·‚邯‚«‚̏ˆ—
00110     virtual void Clear(SGScene* s){ joint=NULL; }
00111 
00112     /// ó‘Ԃ̓ǂݏo‚µ
00113     virtual void LoadState(const SGBehaviorStates& states);
00114     /// ó‘Ԃ̕ۑ¶
00115     virtual void SaveState(SGBehaviorStates& states) const;
00116     /// PID§Œä‚ð‚©‚¯‚éD
00117     void Step(SGScene* s);
00118 
00119     ///
00120     Vec3f GetJointTorque(){ return joint->GetTorque(); }
00121 
00122     size_t NReferenceObjects();
00123     SGObject* ReferenceObject(size_t i);
00124     bool AddChildObject(SGObject* o, SGScene* s);
00125     bool DelChildObject(SGObject* o, SGScene* s);   
00126 
00127     virtual void Print(std::ostream& os) const;
00128 
00129 };
00130 
00131 
00132 }
00133 
00134 #endif

Generated on Sun Apr 16 02:07:11 2006 for Springhead by  doxygen 1.4.1