teamALI / Mbed 2 deprecated HB2018

Dependencies:   mbed FreeRTOS

Committer:
MasashiNomura
Date:
Thu Dec 06 11:03:13 2018 +0000
Revision:
22:24c9c2dedca9
Parent:
21:78302ecdb661
Child:
23:79e20be4bc5b
Temp State Transfer

Who changed what in which revision?

UserRevisionLine numberNew contents of line
takeru0x1103 8:1ca49cb18290 1 #ifndef __GLOBALFLAGS_H__
takeru0x1103 8:1ca49cb18290 2 #define __GLOBALFLAGS_H__
takeru0x1103 8:1ca49cb18290 3
takeru0x1103 16:05b9e44889f1 4 #include "mbed.h"
takeru0x1103 17:f9610f3cfa1b 5 #include "typedef.h"
takeru0x1103 17:f9610f3cfa1b 6
takeru0x1103 19:4b0fe9a5ec38 7 #define G_CMD_BUF_SIZ 32
takeru0x1103 19:4b0fe9a5ec38 8 #define STATE_QUE_SIZ 8
takeru0x1103 19:4b0fe9a5ec38 9
MasashiNomura 22:24c9c2dedca9 10 #define STATE_BUF_SIZ 8
MasashiNomura 22:24c9c2dedca9 11
takeru0x1103 17:f9610f3cfa1b 12 typedef union{
takeru0x1103 17:f9610f3cfa1b 13 UINT16 flg;
takeru0x1103 17:f9610f3cfa1b 14 struct{
takeru0x1103 17:f9610f3cfa1b 15 bool e1 : 1;//前エンジン回転数
takeru0x1103 17:f9610f3cfa1b 16 bool e2 : 1;//後ろエンジン回転数
takeru0x1103 17:f9610f3cfa1b 17 bool m1 : 1;//サブモーター回転数
takeru0x1103 17:f9610f3cfa1b 18 bool m2 : 1;//サブモーター回転数
takeru0x1103 17:f9610f3cfa1b 19 bool m3 : 1;//サブモーター回転数
takeru0x1103 17:f9610f3cfa1b 20 bool m4 : 1;//サブモーター回転数
takeru0x1103 17:f9610f3cfa1b 21 bool gy : 1;//ジャイロ
takeru0x1103 17:f9610f3cfa1b 22 bool yaw : 1;//ヨー角
takeru0x1103 18:5aa48aec9cae 23 bool fb : 1;//PID制御feedback結果
takeru0x1103 18:5aa48aec9cae 24 bool pp : 1;//P制御ゲイン(アウターループ)
takeru0x1103 18:5aa48aec9cae 25 bool p : 1;//P制御ゲイン
takeru0x1103 18:5aa48aec9cae 26 bool i : 1;//I制御ゲイン
takeru0x1103 18:5aa48aec9cae 27 bool d : 1;//D制御ゲイン
takeru0x1103 17:f9610f3cfa1b 28 }bf;
takeru0x1103 17:f9610f3cfa1b 29 }typPrintFlag;
takeru0x1103 17:f9610f3cfa1b 30
takeru0x1103 17:f9610f3cfa1b 31 typedef union{
takeru0x1103 17:f9610f3cfa1b 32 UINT16 flg;
takeru0x1103 17:f9610f3cfa1b 33 struct{
takeru0x1103 17:f9610f3cfa1b 34 bool e1 : 1;//
takeru0x1103 17:f9610f3cfa1b 35 bool e2 : 1;//
takeru0x1103 17:f9610f3cfa1b 36 bool m1 : 1;//
takeru0x1103 17:f9610f3cfa1b 37 bool m2 : 1;//
takeru0x1103 17:f9610f3cfa1b 38 bool m3 : 1;//
takeru0x1103 17:f9610f3cfa1b 39 bool m4 : 1;//
takeru0x1103 17:f9610f3cfa1b 40 bool gy : 1;//
takeru0x1103 17:f9610f3cfa1b 41 bool yaw : 1;//
takeru0x1103 18:5aa48aec9cae 42 bool fb : 1;//PID制御feedback結果
takeru0x1103 18:5aa48aec9cae 43 bool pp : 1;//P制御ゲイン(アウターループ)
takeru0x1103 18:5aa48aec9cae 44 bool p : 1;//P制御ゲイン
takeru0x1103 18:5aa48aec9cae 45 bool i : 1;//I制御ゲイン
takeru0x1103 18:5aa48aec9cae 46 bool d : 1;//D制御ゲイン
takeru0x1103 17:f9610f3cfa1b 47 }bf;
takeru0x1103 17:f9610f3cfa1b 48 }typCalFlag;
takeru0x1103 17:f9610f3cfa1b 49
takeru0x1103 19:4b0fe9a5ec38 50 //
takeru0x1103 17:f9610f3cfa1b 51 typedef union{
takeru0x1103 17:f9610f3cfa1b 52 UINT16 dt;
takeru0x1103 17:f9610f3cfa1b 53 struct{
takeru0x1103 18:5aa48aec9cae 54 UINT16 val : 12;//アクセル設定値
takeru0x1103 17:f9610f3cfa1b 55 bool req : 1;//アクセル更新要求
takeru0x1103 17:f9610f3cfa1b 56 }bf;
takeru0x1103 17:f9610f3cfa1b 57 }typAccel;
takeru0x1103 17:f9610f3cfa1b 58
takeru0x1103 19:4b0fe9a5ec38 59 //ステート定義
takeru0x1103 19:4b0fe9a5ec38 60 enum enmHbState
MasashiNomura 22:24c9c2dedca9 61 {NONE = 0 //何もなし
takeru0x1103 21:78302ecdb661 62 ,SLEEP //スリープモード(最初ここ)
takeru0x1103 20:0394e15412c3 63 ,WAKEUP //起動処理
takeru0x1103 20:0394e15412c3 64 ,STANDBY //スタンバイ(エンジンかかるの待ち)
takeru0x1103 21:78302ecdb661 65 ,IDLE //アイドル(エンジンがかかったけどなにもしない)
takeru0x1103 20:0394e15412c3 66 ,TAKE_OFF //離陸
takeru0x1103 20:0394e15412c3 67 ,HOVER //ホバリング
takeru0x1103 21:78302ecdb661 68 ,DRIVE //運転
takeru0x1103 21:78302ecdb661 69 ,GROUND //着陸(エンジン同時下げ)
takeru0x1103 21:78302ecdb661 70 ,EMGGND //緊急着陸(後ろエンジンを先に下げる)
takeru0x1103 20:0394e15412c3 71 ,CHK_ENT //チェックエンター
takeru0x1103 20:0394e15412c3 72 ,CHK_MOT //モーターチェック
takeru0x1103 20:0394e15412c3 73 ,CHK_AXL //アクセルサーボチェック
takeru0x1103 20:0394e15412c3 74 ,CHK_ATT //姿勢制御チェック
takeru0x1103 20:0394e15412c3 75 ,CHK_EXIT //チェックステート脱出
takeru0x1103 19:4b0fe9a5ec38 76 };
takeru0x1103 19:4b0fe9a5ec38 77
takeru0x1103 17:f9610f3cfa1b 78 /////////////////////////////////////////////////
takeru0x1103 21:78302ecdb661 79
MasashiNomura 22:24c9c2dedca9 80 void initFlags();
MasashiNomura 22:24c9c2dedca9 81
MasashiNomura 22:24c9c2dedca9 82 void setState(enmHbState stat);
MasashiNomura 22:24c9c2dedca9 83
MasashiNomura 22:24c9c2dedca9 84
takeru0x1103 21:78302ecdb661 85 /*
takeru0x1103 19:4b0fe9a5ec38 86 class GlobalFlags{
takeru0x1103 19:4b0fe9a5ec38 87 private:
takeru0x1103 19:4b0fe9a5ec38 88 enmHbState stateQueue[STATE_QUE_SIZ];//ステート予約用のキューバッファ
takeru0x1103 19:4b0fe9a5ec38 89 int wp; //ライトポインタ
takeru0x1103 19:4b0fe9a5ec38 90 int rp; //リードポインタ
takeru0x1103 19:4b0fe9a5ec38 91 bool full; //フルフラグ
takeru0x1103 19:4b0fe9a5ec38 92 bool empty; //エンプティフラグ
takeru0x1103 19:4b0fe9a5ec38 93 public:
takeru0x1103 21:78302ecdb661 94 //プロパティ
takeru0x1103 20:0394e15412c3 95 enmHbState state;//現在のステート
takeru0x1103 21:78302ecdb661 96 //メソッド
takeru0x1103 20:0394e15412c3 97 GlobalFlags();//コンストラクタ
takeru0x1103 19:4b0fe9a5ec38 98 bool push(enmHbState iState);
takeru0x1103 19:4b0fe9a5ec38 99 bool pull();
takeru0x1103 19:4b0fe9a5ec38 100 };
takeru0x1103 16:05b9e44889f1 101
takeru0x1103 21:78302ecdb661 102 */
takeru0x1103 21:78302ecdb661 103
takeru0x1103 21:78302ecdb661 104
takeru0x1103 17:f9610f3cfa1b 105 //モニタ用LED
takeru0x1103 16:05b9e44889f1 106 extern DigitalOut led1;
takeru0x1103 16:05b9e44889f1 107 extern DigitalOut led2;
takeru0x1103 16:05b9e44889f1 108 extern DigitalOut led3;
takeru0x1103 16:05b9e44889f1 109 extern DigitalOut led4;
takeru0x1103 8:1ca49cb18290 110
MasashiNomura 22:24c9c2dedca9 111 //////////////////////////////////////////////////
MasashiNomura 22:24c9c2dedca9 112 // フラグ
takeru0x1103 21:78302ecdb661 113 //extern GlobalFlags gf;
takeru0x1103 19:4b0fe9a5ec38 114
takeru0x1103 19:4b0fe9a5ec38 115 extern char g_CmdBuf[G_CMD_BUF_SIZ] ;// コマンド受け渡しバッファ
MasashiNomura 22:24c9c2dedca9 116 extern bool gf_CmdPrs; //コマンドパーサー実行要求フラグ
takeru0x1103 19:4b0fe9a5ec38 117
takeru0x1103 21:78302ecdb661 118 extern bool gf_Armed; //アーミングフラグ
MasashiNomura 22:24c9c2dedca9 119 extern bool gf_Dbg; //デバッグフラグ
MasashiNomura 22:24c9c2dedca9 120 extern typPrintFlag gf_Print; //デバッグプリントフラグ(1回表示)
MasashiNomura 22:24c9c2dedca9 121 extern typPrintFlag gf_Mon; //デバッグモニタフラグ(繰り返し表示)
MasashiNomura 22:24c9c2dedca9 122 extern typCalFlag gf_Cal; //キャリブレーションフラグ
MasashiNomura 22:24c9c2dedca9 123 extern typAccel gf_AxReq[2]; //アクセル更新
MasashiNomura 22:24c9c2dedca9 124 extern typAccel gf_MtReq[4]; //モーター更新
MasashiNomura 22:24c9c2dedca9 125
MasashiNomura 22:24c9c2dedca9 126 extern enmHbState gf_State; //現在のステート
takeru0x1103 19:4b0fe9a5ec38 127
takeru0x1103 19:4b0fe9a5ec38 128
takeru0x1103 18:5aa48aec9cae 129 #endif