NHK2017Ateamかにろぼ

Dependencies:   2017NHKpin_config mbed FEP HMC6352 MotorDriverController PID QEI omni

classDiagram

    \ ̄\                   / ̄/ 
/l     \  \             /  / lヽ  
| ヽ  ヽ   |           |  /  / | 
\ ` ‐ヽ  ヽ  ●        ●         /  / ‐  / 
  \ __ l  |  ||___|| /  l __ / 
     \  \ /      \/ 
      /\|   人__人  |/\       
    //\|             |/\\     
    //\|             |/\\     
    /     . \_____/         \ 

                               ┏┓        ┏━┓┏┓              
     ┏┓         ┏┓┏┓   ┏┓    ┏┓┗┛     ┏┓ ┗┓┃┗┛              
┏┛┗━┓  ┃┃┃┃    ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ 
┗┓┏━┛  ┃┃┗┛    ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛    
┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓      ┏┛┃┃┃        ┃┃              
┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛      ┗━┛┃┃        ┃┃┏┓          
┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃         ┏┛┃        ┃┃┃┗━━┓    
┗┛┗━━┛┗━━━┛┗┛┗━━┛         ┗━┛        ┗┛┗━━━┛  
Committer:
uchitake
Date:
Tue Sep 05 12:00:34 2017 +0900
Revision:
22:bb6afe7332c3
Parent:
21:b2c1d73b0ee9
fix Security!!!!!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
UCHITAKE 3:d25e7fb07ed2 1 /**
UCHITAKE 3:d25e7fb07ed2 2 * @file controller.h
UCHITAKE 3:d25e7fb07ed2 3 * @brief FEPを使ったコントローラ受信部
uchitake 21:b2c1d73b0ee9 4 *
uchitake 21:b2c1d73b0ee9 5 * Example :
uchitake 21:b2c1d73b0ee9 6 * @code
uchitake 21:b2c1d73b0ee9 7 * #include "mbed.h"
uchitake 21:b2c1d73b0ee9 8 * #include "controller.h"
uchitake 21:b2c1d73b0ee9 9 *
uchitake 21:b2c1d73b0ee9 10 * Controller pad(PA_9, PA_10, 200);
uchitake 21:b2c1d73b0ee9 11 * Serial pc(USBTX, USBRX, 115200);
uchitake 21:b2c1d73b0ee9 12 *
uchitake 21:b2c1d73b0ee9 13 * int main()
uchitake 21:b2c1d73b0ee9 14 * {
uchitake 21:b2c1d73b0ee9 15 * while(1) {
uchitake 21:b2c1d73b0ee9 16 * if(pad.receiveState()) {
uchitake 21:b2c1d73b0ee9 17 * for(int i = 0; i < 7; i++) pc.printf("%d, ", pad.getButton1(i));
uchitake 21:b2c1d73b0ee9 18 * for(int i = 0; i < 6; i++) pc.printf("%d, ", pad.getButton2(i));
uchitake 21:b2c1d73b0ee9 19 * pc.printf("\r\n");
uchitake 21:b2c1d73b0ee9 20 * } else {
uchitake 21:b2c1d73b0ee9 21 * pc.printf("ERROR\n\r");
uchitake 21:b2c1d73b0ee9 22 * }
uchitake 21:b2c1d73b0ee9 23 * }
uchitake 21:b2c1d73b0ee9 24 * }
uchitake 21:b2c1d73b0ee9 25 * @endcode
UCHITAKE 3:d25e7fb07ed2 26 */
UCHITAKE 0:757e9800c103 27 #ifndef CONTROLLER_H
UCHITAKE 0:757e9800c103 28 #define CONTROLLER_H
UCHITAKE 0:757e9800c103 29
UCHITAKE 0:757e9800c103 30 #include "mbed.h"
UCHITAKE 0:757e9800c103 31 #include "pin_config.h"
UCHITAKE 1:269914e0aa07 32 #include <math.h>
UCHITAKE 0:757e9800c103 33
UCHITAKE 0:757e9800c103 34 #include "FEP.h"
UCHITAKE 0:757e9800c103 35
uchitake 22:bb6afe7332c3 36 // const double M_PI = 3.141592653589793;
uchitake 22:bb6afe7332c3 37 const int ADDR = 203;
uchitake 22:bb6afe7332c3 38 const bool FEP_SUCCESS =0;
uchitake 22:bb6afe7332c3 39 const int DATA_SIZE = 6;
uchitake 22:bb6afe7332c3 40 const float STICK_DIVIDE = 255.0;
uchitake 22:bb6afe7332c3 41 const float STICK_NEWTRAL = 0.1;
uchitake 22:bb6afe7332c3 42 const float STICK_NORM_MAX =1.0;
UCHITAKE 1:269914e0aa07 43
UCHITAKE 3:d25e7fb07ed2 44 /**
UCHITAKE 3:d25e7fb07ed2 45 * @brief FEPを使ったコントローラのクラス
UCHITAKE 3:d25e7fb07ed2 46 */
UCHITAKE 1:269914e0aa07 47 class Controller : public FEP
UCHITAKE 1:269914e0aa07 48 {
UCHITAKE 0:757e9800c103 49 public :
UCHITAKE 3:d25e7fb07ed2 50
UCHITAKE 3:d25e7fb07ed2 51 /**
UCHITAKE 3:d25e7fb07ed2 52 * @brief コンストラクタ
UCHITAKE 3:d25e7fb07ed2 53 */
UCHITAKE 0:757e9800c103 54 Controller();
UCHITAKE 1:269914e0aa07 55
UCHITAKE 3:d25e7fb07ed2 56 /**
uchitake 16:86958857c739 57 * @brief コンストラクタ
uchitake 16:86958857c739 58 * @param FEPtx FEPtx
uchitake 16:86958857c739 59 * @param FEPrx FEPrx
uchitake 16:86958857c739 60 * @param addr address
uchitake 16:86958857c739 61 */
uchitake 16:86958857c739 62 Controller(PinName FEPtx, PinName FEPrx,int addr);
uchitake 16:86958857c739 63
uchitake 16:86958857c739 64 /**
UCHITAKE 3:d25e7fb07ed2 65 * @brief メンバ変数にボタンのステートを格納
UCHITAKE 3:d25e7fb07ed2 66 */
UCHITAKE 19:3a62cbc6fee9 67 bool receiveState();
uchitake 15:9a2dce34b660 68
uchitake 16:86958857c739 69 /**
uchitake 16:86958857c739 70 * ボタン1の状態を取得
uchitake 16:86958857c739 71 * @param number button number
uchitake 16:86958857c739 72 * @return status
uchitake 16:86958857c739 73 */
uchitake 22:bb6afe7332c3 74 bool getButton1(int number) const;
uchitake 16:86958857c739 75
uchitake 16:86958857c739 76 /**
uchitake 16:86958857c739 77 * ボタン2の状態を取得
uchitake 16:86958857c739 78 * @param number button number
uchitake 16:86958857c739 79 * @return status
uchitake 16:86958857c739 80 */
uchitake 22:bb6afe7332c3 81 bool getButton2(int number) const;
uchitake 16:86958857c739 82
uchitake 16:86958857c739 83 /**
uchitake 16:86958857c739 84 * スティックの値を取得
uchitake 16:86958857c739 85 * @param number sticknumber(x, y, x, y)
uchitake 16:86958857c739 86 * @return stick value
uchitake 16:86958857c739 87 */
uchitake 22:bb6afe7332c3 88 float getStick(int number) const;
uchitake 16:86958857c739 89
uchitake 16:86958857c739 90 /**
uchitake 16:86958857c739 91 * スチィックの角度を取得
uchitake 16:86958857c739 92 * @param number left...0 right...1
uchitake 16:86958857c739 93 * @return radian
uchitake 16:86958857c739 94 */
uchitake 22:bb6afe7332c3 95 float getRadian(int number) const;
uchitake 16:86958857c739 96
uchitake 16:86958857c739 97 /**
uchitake 16:86958857c739 98 * スティックの距離を取得
uchitake 16:86958857c739 99 * @param number left..0 right..1
uchitake 16:86958857c739 100 * @return norm
uchitake 16:86958857c739 101 */
uchitake 22:bb6afe7332c3 102 float getNorm(int number) const;
uchitake 16:86958857c739 103
UCHITAKE 0:757e9800c103 104 private :
uchitake 15:9a2dce34b660 105 void setStick();
UCHITAKE 1:269914e0aa07 106
UCHITAKE 1:269914e0aa07 107 char data[6];
UCHITAKE 1:269914e0aa07 108 uint8_t fepTemp;
uchitake 15:9a2dce34b660 109
UCHITAKE 1:269914e0aa07 110 protected :
uchitake 15:9a2dce34b660 111 bool button1[7];
uchitake 15:9a2dce34b660 112 bool button2[6];
UCHITAKE 1:269914e0aa07 113 double stick[4];
uchitake 15:9a2dce34b660 114 double radian[2];
UCHITAKE 1:269914e0aa07 115 double norm[2];
UCHITAKE 0:757e9800c103 116 };
UCHITAKE 0:757e9800c103 117
uchitake 15:9a2dce34b660 118 #endif//CONTROLLER_H