![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
4/2にちゃんと動いたやつ
Dependencies: mbed SBDBT arrc_mbed
main.cpp@6:fd9b59f828e8, 2022-01-29 (annotated)
- Committer:
- guesta
- Date:
- Sat Jan 29 14:48:41 2022 +0000
- Revision:
- 6:fd9b59f828e8
- Parent:
- 3:e4b5563563af
- Child:
- 7:59be95fceafa
add id cmd; ;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
guesta | 0:d8faed605a5c | 1 | #include "mbed.h" |
guesta | 3:e4b5563563af | 2 | #include "scrp_slave.hpp" |
guesta | 3:e4b5563563af | 3 | #include "sbdbt.hpp" |
guesta | 0:d8faed605a5c | 4 | |
guesta | 0:d8faed605a5c | 5 | int main(){ |
guesta | 1:642ee25ea489 | 6 | //---------------初期設定--------------- |
guesta | 3:e4b5563563af | 7 | //scrp_slave |
guesta | 3:e4b5563563af | 8 | ScrpSlave scrp(PC_12,PD_2,PH_1,0x0807f800); |
guesta | 6:fd9b59f828e8 | 9 | |
guesta | 3:e4b5563563af | 10 | //sbdbt |
guesta | 6:fd9b59f828e8 | 11 | sbdbt sb(A0,A1); |
guesta | 6:fd9b59f828e8 | 12 | |
guesta | 3:e4b5563563af | 13 | //scrp_slaveのid設定 |
guesta | 6:fd9b59f828e8 | 14 | const int wheel_num = 1; |
guesta | 3:e4b5563563af | 15 | const int BeanbagGet_num = 2; |
guesta | 3:e4b5563563af | 16 | const int BeanbagShot_num = 3; |
guesta | 3:e4b5563563af | 17 | const int TakoGetPut_num = 4; |
guesta | 6:fd9b59f828e8 | 18 | const int tape_LED_num = 5; |
guesta | 6:fd9b59f828e8 | 19 | const int remort_stop_num = 6; |
guesta | 6:fd9b59f828e8 | 20 | const int send_all = 255; |
guesta | 6:fd9b59f828e8 | 21 | |
guesta | 3:e4b5563563af | 22 | //コマンド番号設定 |
guesta | 6:fd9b59f828e8 | 23 | //足回り用 |
guesta | 3:e4b5563563af | 24 | const int x_component_cmd = 1; |
guesta | 3:e4b5563563af | 25 | const int y_component_cmd = 2; |
guesta | 3:e4b5563563af | 26 | const int l2_cmd = 3; |
guesta | 3:e4b5563563af | 27 | const int r2_cmd = 4; |
guesta | 6:fd9b59f828e8 | 28 | |
guesta | 6:fd9b59f828e8 | 29 | //ビーンバッグ回収用 |
guesta | 6:fd9b59f828e8 | 30 | |
guesta | 6:fd9b59f828e8 | 31 | //ビーンバッグ発射用 |
guesta | 6:fd9b59f828e8 | 32 | |
guesta | 6:fd9b59f828e8 | 33 | //農作物回収・設置用 |
guesta | 6:fd9b59f828e8 | 34 | const int up = 1; |
guesta | 6:fd9b59f828e8 | 35 | const int down = 2; |
guesta | 6:fd9b59f828e8 | 36 | |
guesta | 6:fd9b59f828e8 | 37 | //テープLED用 |
guesta | 6:fd9b59f828e8 | 38 | |
guesta | 6:fd9b59f828e8 | 39 | //遠隔非常停止受信用 |
guesta | 6:fd9b59f828e8 | 40 | const int |
guesta | 6:fd9b59f828e8 | 41 | |
guesta | 6:fd9b59f828e8 | 42 | //全体送信用 |
guesta | 6:fd9b59f828e8 | 43 | const int select = 50;//手動・自動切り替え |
guesta | 6:fd9b59f828e8 | 44 | const int stop_all = 51;//全プログラム停止 |
guesta | 6:fd9b59f828e8 | 45 | |
guesta | 1:642ee25ea489 | 46 | //変数 |
guesta | 3:e4b5563563af | 47 | int x_component; |
guesta | 3:e4b5563563af | 48 | int y_component; |
guesta | 3:e4b5563563af | 49 | int l2_num; |
guesta | 3:e4b5563563af | 50 | int r2_num; |
guesta | 3:e4b5563563af | 51 | //------------------------------------- |
guesta | 6:fd9b59f828e8 | 52 | |
guesta | 1:642ee25ea489 | 53 | while(true){ |
guesta | 3:e4b5563563af | 54 | sb.button_state(); |
guesta | 6:fd9b59f828e8 | 55 | x_component = sb.rsx(); |
guesta | 6:fd9b59f828e8 | 56 | y_component = sb.rsy(); |
guesta | 3:e4b5563563af | 57 | l2_num = sb.l2An(); |
guesta | 3:e4b5563563af | 58 | r2_num = sb.r2An(); |
guesta | 6:fd9b59f828e8 | 59 | |
guesta | 6:fd9b59f828e8 | 60 | //足回り |
guesta | 3:e4b5563563af | 61 | scrp.send1(wheel_num,x_component_cmd,x_component); |
guesta | 3:e4b5563563af | 62 | wait_ms(1); |
guesta | 3:e4b5563563af | 63 | scrp.send1(wheel_num,y_component_cmd,y_component); |
guesta | 3:e4b5563563af | 64 | wait_ms(1); |
guesta | 3:e4b5563563af | 65 | scrp.send1(wheel_num,l2_cmd,l2_num); |
guesta | 3:e4b5563563af | 66 | wait_ms(1); |
guesta | 3:e4b5563563af | 67 | scrp.send1(wheel_num,r2_cmd,r2_num); |
guesta | 3:e4b5563563af | 68 | wait_ms(1); |
guesta | 6:fd9b59f828e8 | 69 | |
guesta | 6:fd9b59f828e8 | 70 | //ビーンバッグ回収 |
guesta | 6:fd9b59f828e8 | 71 | |
guesta | 6:fd9b59f828e8 | 72 | //ビーンバッグ発射 |
guesta | 6:fd9b59f828e8 | 73 | |
guesta | 6:fd9b59f828e8 | 74 | //農作物回収・設置 |
guesta | 6:fd9b59f828e8 | 75 | |
guesta | 6:fd9b59f828e8 | 76 | //全体送信 |
guesta | 6:fd9b59f828e8 | 77 | scrp.send1(send_all,select,sb.select());//自動・手動モード切り替え |
guesta | 3:e4b5563563af | 78 | wait_ms(1); |
guesta | 1:642ee25ea489 | 79 | } |
guesta | 0:d8faed605a5c | 80 | } |