![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
DRのPS3での操作用(アームの開閉をコントローラで制御可能)
Dependencies: mbed CalPID motorout ros_lib_melodic MotorController_AbsEC
AMT21/AMT21.h@5:4fba3e91741f, 2021-07-10 (annotated)
- Committer:
- ayu13
- Date:
- Sat Jul 10 09:19:49 2021 +0000
- Revision:
- 5:4fba3e91741f
- Parent:
- 4:3abefa13c2e3
- Child:
- 6:e6b303ea6439
LED_Operation check OK
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ayu13 | 0:83b2c6a67cce | 1 | #ifndef _INCLUDED_AMT212_H_ |
ayu13 | 0:83b2c6a67cce | 2 | #define _INCLUDED_AMT212_H_ |
ayu13 | 0:83b2c6a67cce | 3 | #include "mbed.h" |
ayu13 | 0:83b2c6a67cce | 4 | |
ayu13 | 0:83b2c6a67cce | 5 | #define SEND 1 |
ayu13 | 0:83b2c6a67cce | 6 | #define RECEIVE 0 |
ayu13 | 0:83b2c6a67cce | 7 | #define RECEIVE_COUNT 0 |
ayu13 | 0:83b2c6a67cce | 8 | #define RECEIVE_TURN 2 |
ayu13 | 0:83b2c6a67cce | 9 | #define GET_COUNT 84 |
ayu13 | 0:83b2c6a67cce | 10 | #define GET_TURN 85 |
ayu13 | 0:83b2c6a67cce | 11 | #define RESOLUTION_AMT21 16384 |
ayu13 | 0:83b2c6a67cce | 12 | #define DETECT_FLOW 5 |
ayu13 | 0:83b2c6a67cce | 13 | #define RESET 86 |
ayu13 | 5:4fba3e91741f | 14 | #define COUNT_OFFSET 9791 //////////////////1568 |
ayu13 | 0:83b2c6a67cce | 15 | #define GEER_STEER 1 |
ayu13 | 0:83b2c6a67cce | 16 | #ifndef M_PI |
ayu13 | 0:83b2c6a67cce | 17 | #define M_PI 3.14159265359f |
ayu13 | 0:83b2c6a67cce | 18 | #endif |
ayu13 | 0:83b2c6a67cce | 19 | |
ayu13 | 0:83b2c6a67cce | 20 | |
ayu13 | 0:83b2c6a67cce | 21 | |
ayu13 | 0:83b2c6a67cce | 22 | class Amt21 |
ayu13 | 0:83b2c6a67cce | 23 | { |
ayu13 | 0:83b2c6a67cce | 24 | private: |
ayu13 | 0:83b2c6a67cce | 25 | ////////////////////////////////////////////// |
ayu13 | 0:83b2c6a67cce | 26 | int low_count,high_count; |
ayu13 | 0:83b2c6a67cce | 27 | int low_turn,high_turn; |
ayu13 | 0:83b2c6a67cce | 28 | int receive_mode; |
ayu13 | 0:83b2c6a67cce | 29 | int instruction; |
ayu13 | 0:83b2c6a67cce | 30 | void sendMessage(); |
ayu13 | 0:83b2c6a67cce | 31 | void receiveMessage(); |
ayu13 | 0:83b2c6a67cce | 32 | ///////////////////////////////////////////// |
ayu13 | 0:83b2c6a67cce | 33 | int count_; |
ayu13 | 0:83b2c6a67cce | 34 | int receive_old; |
ayu13 | 0:83b2c6a67cce | 35 | int flow_count; |
ayu13 | 0:83b2c6a67cce | 36 | int th_min; |
ayu13 | 0:83b2c6a67cce | 37 | int th_max; |
ayu13 | 0:83b2c6a67cce | 38 | int pre_count; |
ayu13 | 0:83b2c6a67cce | 39 | double omega_; |
ayu13 | 0:83b2c6a67cce | 40 | double pre_time; |
ayu13 | 0:83b2c6a67cce | 41 | |
ayu13 | 0:83b2c6a67cce | 42 | int getAbCount();//カウント数取得関数 |
ayu13 | 0:83b2c6a67cce | 43 | int getTurn();//回転回数取得関数 |
ayu13 | 0:83b2c6a67cce | 44 | |
ayu13 | 0:83b2c6a67cce | 45 | protected: |
ayu13 | 0:83b2c6a67cce | 46 | Serial serial_;//RS485通信 |
ayu13 | 0:83b2c6a67cce | 47 | DigitalOut rs485_mode;//送受信の切り替え |
ayu13 | 0:83b2c6a67cce | 48 | public: |
ayu13 | 0:83b2c6a67cce | 49 | Amt21(PinName tx,PinName rx,PinName mode);//コンストラクタ |
ayu13 | 0:83b2c6a67cce | 50 | |
ayu13 | 0:83b2c6a67cce | 51 | Timer timer_; |
ayu13 | 0:83b2c6a67cce | 52 | |
ayu13 | 0:83b2c6a67cce | 53 | void rewriteCount();//1周期に1度呼び出す。 |
ayu13 | 0:83b2c6a67cce | 54 | int getCount();//インクリメント型のカウントと同じように使えて、-のカウントや16383以上のカウントを返す。 |
ayu13 | 0:83b2c6a67cce | 55 | double getDeg();//角度[°]を返す |
ayu13 | 0:83b2c6a67cce | 56 | double getRad();//角度[rad]を返す |
ayu13 | 0:83b2c6a67cce | 57 | void calOmega();//getOmegaする前に呼び出す |
ayu13 | 0:83b2c6a67cce | 58 | double getOmega();//角速度[rad/s]を返す |
ayu13 | 0:83b2c6a67cce | 59 | void reset();//回転数のリセット関数。※0~360を示すカウント数はリセットされない。 |
ayu13 | 0:83b2c6a67cce | 60 | |
ayu13 | 0:83b2c6a67cce | 61 | }; |
ayu13 | 0:83b2c6a67cce | 62 | #endif |