Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
globalFlags.h
- Committer:
- MasashiNomura
- Date:
- 2018-12-13
- Revision:
- 26:732bc37fbefd
- Parent:
- 25:f3a6e7eec9c3
- Child:
- 27:ff63c23bc689
File content as of revision 26:732bc37fbefd:
#ifndef __GLOBALFLAGS_H__ #define __GLOBALFLAGS_H__ #include "mbed.h" #include "typedef.h" #define G_CMD_BUF_SIZ 32 #define STATE_QUE_SIZ 8 #define STATE_BUF_SIZ 8 #define LIM_MOT_INP_MIN -2000 #define LIM_MOT_INP_MAX 2000 typedef union{ UINT16 flg; struct{ bool e1 : 1;//前エンジン回転数 bool e2 : 1;//後ろエンジン回転数 bool m1 : 1;//サブモーター回転数 bool m2 : 1;//サブモーター回転数 bool m3 : 1;//サブモーター回転数 bool m4 : 1;//サブモーター回転数 bool gy : 1;//ジャイロ bool yaw : 1;//ヨー角 bool fb : 1;//PID制御feedback結果 bool pp : 1;//P制御ゲイン(アウターループ) bool p : 1;//P制御ゲイン bool i : 1;//I制御ゲイン bool d : 1;//D制御ゲイン bool stat : 1;//ステート表示 }bf; }typPrintFlag; typedef union{ UINT16 flg; struct{ bool e1 : 1;// bool e2 : 1;// bool m1 : 1;// bool m2 : 1;// bool m3 : 1;// bool m4 : 1;// bool gy : 1;// bool yaw : 1;// bool fb : 1;//PID制御feedback結果 bool pp : 1;//P制御ゲイン(アウターループ) bool p : 1;//P制御ゲイン bool i : 1;//I制御ゲイン bool d : 1;//D制御ゲイン }bf; }typCalFlag; // typedef union{ UINT16 dt; struct{ UINT16 val : 12;//アクセル設定値 bool req : 1;//アクセル更新要求 }bf; }typAccel; typedef union{ UINT16 flg; struct{ bool mo1 : 1;//Motor1 Offset val bool mo2 : 1;//Motor2 Offset val bool mo3 : 1;//Motor3 Offset val bool mo4 : 1;//Motor4 Offset val }bf; }typDbgPrintFlg; //ステート定義 enum enmHbState {NONE = 0 //何もなし ,SLEEP //スリープモード(最初ここ) ,WAKEUP //起動処理 ,STANDBY //スタンバイ(エンジンかかるの待ち) ,IDLE //アイドル(エンジンがかかったけどなにもしない) ,TAKE_OFF //離陸 ,HOVER //ホバリング ,DRIVE //運転 ,GROUND //着陸(エンジン同時下げ) ,EMGGND //緊急着陸(後ろエンジンを先に下げる) ,CHK_ENT //チェックエンター ,CHK_MOT //モーターチェック ,CHK_AXL //アクセルサーボチェック ,CHK_ATT //姿勢制御チェック ,CHK_EXIT //チェックステート脱出 ,MOT_STOP //モーター停止用 }; ///////////////////////////////////////////////// void initFlags(); void setState(enmHbState stat); void setStateF(enmHbState stat); /* class GlobalFlags{ private: enmHbState stateQueue[STATE_QUE_SIZ];//ステート予約用のキューバッファ int wp; //ライトポインタ int rp; //リードポインタ bool full; //フルフラグ bool empty; //エンプティフラグ public: //プロパティ enmHbState state;//現在のステート //メソッド GlobalFlags();//コンストラクタ bool push(enmHbState iState); bool pull(); }; */ //モニタ用LED extern DigitalOut led1; extern DigitalOut led2; extern DigitalOut led3; extern DigitalOut led4; ////////////////////////////////////////////////// // フラグ //extern GlobalFlags gf; extern char g_CmdBuf[G_CMD_BUF_SIZ] ;// コマンド受け渡しバッファ extern bool gf_CmdPrs; //コマンドパーサー実行要求フラグ extern bool gf_Armed; //アーミングフラグ extern bool gf_Dbg; //デバッグフラグ extern bool gf_StopMot; //モーターの強制停止 extern typPrintFlag gf_Print; //デバッグプリントフラグ(1回表示) extern typPrintFlag gf_Mon; //デバッグモニタフラグ(繰り返し表示) extern typCalFlag gf_Cal; //キャリブレーションフラグ extern typDbgPrintFlg gf_DbgPrint ;//デバッグ用 extern typAccel gf_AxReq[2]; //アクセル更新 extern typAccel gf_MtReq[4]; //モーター更新 extern enmHbState gf_State; //現在のステート extern bool gf_PidParaUpdate ;//PID Pp,P,I,Dの係数アップデートフラグ extern typPidPara g_PidPara; //PID Pp,P,I,Dの係数の外部設定用 extern bool gf_MotParaUpdate[4] ;//モーターのパラメータ値更新フラグ extern typMotPara g_MotPara[4]; //モーターのパラメータ値 #endif