メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ | 関連ページ

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     /// 前回の目標値
00012     float lastGoal;
00013     /// 積分
00014     float integratedError;
00015 public:
00016     SGOBJECTDEF(PHJointPid);
00017     /// 制御対象関節
00018     UTRef<PHJointBase> joint;
00019     /// 対象の軸
00020     int axis;
00021     /// 目標値      Step()を呼ぶ前に設定する.
00022     float goal;
00023     /// 目標の速度  Step()を呼ぶ前に設定する.
00024     float dGoal;
00025     /// PIDの係数
00026     float proportional, differential, integral;
00027     /// 目標のタイプ 0:位置制御 1:速度制御
00028     int type;
00029     /// proportional,differential,integralによるトルク(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     /// 目標値,目標の速度   Step()を呼ぶ前に設定する
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     /// プライオリティ
00048     virtual int GetPriority() const { return SGBP_FORCEGENERATOR; }
00049     /// シーンをクリアするときの処理
00050     virtual void Clear(SGScene* s){ joint=NULL; }
00051 
00052     /// 状態の読み出し
00053     virtual void LoadState(const SGBehaviorStates& states);
00054     /// 状態の保存
00055     virtual void SaveState(SGBehaviorStates& states) const;
00056     /// PID制御をかける.
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     ニュートラルをまっすぐとして,
00073     - θ・φのグラフで可動域を表す.折れ線近似.
00074     - 最後の軸は,定数 or 中心と θ・φの設定点について設定.
00075     - θ・φは違反したら,最寄のθ・φに向かってPID制御.
00076 コーンで良い説.
00077 コーンの中心の向きVec3f と角度θだけでよい.
00078 */
00079 class PHJointBallPid:public SGBehaviorEngine{
00080 protected:
00081     /// 前回のゴール
00082     Quaterniond lastGoal;
00083     /// 積分
00084     Vec3f integratedError;
00085 public:
00086     SGOBJECTDEF(PHJointBallPid);
00087     /// 制御対象関節
00088     UTRef<PHJointBall> joint;
00089     /// 目標値          Step()を呼ぶ前に設定する.
00090     Quaternionf goal;
00091     /// 目標値の微分    Step()を呼ぶ前に設定する.設定しなくても良い.
00092     Vec3f dGoal;
00093     /// PIDの係数
00094     float proportional, differential, integral;
00095     /// proportional,differential,integralによるトルク(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     /// プライオリティ
00108     virtual int GetPriority() const { return SGBP_FORCEGENERATOR; }
00109     /// シーンをクリアするときの処理
00110     virtual void Clear(SGScene* s){ joint=NULL; }
00111 
00112     /// 状態の読み出し
00113     virtual void LoadState(const SGBehaviorStates& states);
00114     /// 状態の保存
00115     virtual void SaveState(SGBehaviorStates& states) const;
00116     /// PID制御をかける.
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

Springheadに対してSun Apr 16 01:57:54 2006に生成されました。  doxygen 1.4.1