メインプログラム最新版です

Dependencies:   mbed SBDBT arrc_mbed

Revision:
12:86b5327a79c4
Parent:
11:9ae7fe40a807
--- a/main.cpp	Thu Mar 31 09:47:57 2022 +0000
+++ b/main.cpp	Fri Apr 08 07:49:43 2022 +0000
@@ -14,7 +14,7 @@
 
     //scrp_slaveのid設定
     const int wheel_num = 1;
-    const int BeanbagGet_num = 2;
+    //const int BeanbagGet_num = 2;
     const int BeanbagShot_num = 3;
     const int TakoGetPut_num = 4;
     const int TapeLed_num = 5;
@@ -32,9 +32,10 @@
     const int switch_cmd = 7;
     const int l_x_component_cmd = 9;
     const int l_y_component_cmd = 10;
+    const int right_cmd = 11;
 
     //ビーンバッグ回収用
-    const int move = 1;
+    //const int move = 1;
 
     //ビーンバッグ発射用
     const int shot = 2;
@@ -49,17 +50,16 @@
 
     //テープLED用
     const int voice = 1;
-    const int start = 2;
 
     //遠隔非常停止受信用
 
     //全体送信用
     const int select = 50;//手動・自動切り替え
-    const int stop_all = 51;//全プログラム停止
+    const int stop_all = 51;//全プログラム停止,リセット機能
 
     //変数
     bool auto_mode = false;
-    bool status_start = 0;
+    //bool status_start = 0;
     bool auto_move = 0;
     bool field = 0;
     int r_x_component;
@@ -83,7 +83,7 @@
     int count_down;
     int count_shot;
     int count_auto;
-    int count_start;
+    //int count_start;
     int count_stop;
     int count_circle;
 //-------------------------------------
@@ -117,34 +117,36 @@
 
         //足回り
         scrp.send1(wheel_num,r_x_component_cmd,r_x_component);
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,r_y_component_cmd,r_y_component);
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,l2_cmd,l2_num);
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,r2_cmd,r2_num);
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,l1_cmd,sb.l1());
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,r1_cmd,sb.r1());
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,l_x_component_cmd,l_x_component);
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(wheel_num,l_y_component_cmd,l_y_component);
-        wait_ms(2);
+        wait_ms(5);
         if(auto_mode == true){
             if(sb.circle() == 1) {
                 count_circle++;
             if(count_circle == 1) {
                 auto_move =! auto_move;
                 scrp.send1(BeanbagShot_num,circle_cmd,auto_move);
-                wait_ms(2);
+                wait_ms(5);
             }
         } else {
             count_circle = 0;
+            scrp.send1(wheel_num,right_cmd,sb.right());
+            wait_ms(5);
         }
             scrp.send1(wheel_num,circle_cmd,auto_move);
-            wait_ms(2);
+            wait_ms(5);
         }
         
         if(sw1.read() == 1){
@@ -153,18 +155,18 @@
             field = 1;
         }
         scrp.send1(wheel_num,switch_cmd,field);
-        wait_ms(2);
+        wait_ms(5);
 
         //ビーンバッグ回収
         if(auto_mode == false) {
-            scrp.send1(TapeLed_num,1,sb.square());
-            wait_ms(2);
+            scrp.send1(TapeLed_num,1,sb.left());
+            wait_ms(5);
         }
 
         //ビーンバッグ発射
         if(auto_mode == true) {
             scrp.send1(BeanbagShot_num,shot,sb.square());
-            wait_ms(2);
+            wait_ms(5);
             if(sb.square() == 1) {
                 count_shot++;
                 if(count_shot == 1) {
@@ -174,6 +176,17 @@
                 count_shot = 0;
             }
         }
+        //装填
+        if(auto_mode == false) {
+            scrp.send1(BeanbagShot_num,10,sb.cross());
+            wait_ms(5);
+        }
+        if(auto_mode == true){
+            if(sb.cross() == 1){
+                scrp.send1(TapeLed_num,1,10);
+                wait_ms(5);
+            }
+        }
 
         //農作物回収・設置
         if(sb.up() == 1) {
@@ -193,25 +206,15 @@
             count_down = 0;
         }
         scrp.send1(TakoGetPut_num,up,sb.up());
-        wait_ms(2);
+        wait_ms(5);
         scrp.send1(TakoGetPut_num,down,sb.down());
-        wait_ms(2);
+        wait_ms(5);
 
         //テープLED
-        if(sb.start() == 1) {
-            count_auto++;
-            if(count_start == 1) {
-                status_start =! status_start;
-            }
-        } else {
-            count_start = 0;
-        }
-        scrp.send1(TapeLed_num,start,status_start);
-        wait_ms(2);
 
         //全体送信
         scrp.send1(send_all,select,auto_mode);//自動・手動モード切り替え
-        wait_ms(2);
+        wait_ms(5);
         if(status_stop.read() == 1) {
             count_stop++;
             if(count_stop <= 100000){
@@ -222,6 +225,11 @@
             count_stop = 0;
         }
         scrp.send1(send_all,stop_all,0);
-        wait_ms(2);
+        wait_ms(5);
+        if(sb.start() == 1){
+        scrp.send1(send_all,stop_all,3);
+        wait_ms(5);
+        NVIC_SystemReset();
+        }
     }
 }
\ No newline at end of file