2015_robocon_bteam / Mbed 2 deprecated 2015robot_main

Dependencies:   PID QEI mbed

Fork of 2015robot_main by Naoto Deguchi

Revision:
73:86b7b82ba997
Parent:
72:021a14ee970f
Child:
75:4cdcd50ee666
--- a/main_ps3.cpp	Sat Oct 10 00:47:26 2015 +0000
+++ b/main_ps3.cpp	Sat Oct 10 01:44:30 2015 +0000
@@ -7,6 +7,8 @@
 //回転機構wait PI/4 追加で待つ
 //射出をスキップする機能を追加(サイクリックでCstepを変える)
 //スタートゾーンにマシンを戻した後に暴走しないようにする
+//手動時の操作性の改善
+//一度手動モードになったらスタートゾーンに戻るまで再び自動モードにならないようにする
 
 /***コース選択***/
 //#define BLUE
@@ -61,8 +63,6 @@
 #endif
 #ifdef BLUE
             //Blue            
-//            if((step==0)&&((8650.0>x)&&(x>1400.0))) targ_sita=0.0,step=1;
-//            if((step==0)&&((8650.0>x)&&(x>1400.0))) targ_sita=0.015,step=1; /*nomal*/
             if((step==0)&&((8650.0>x)&&(x>900.0))) targ_sita=0.03,step=1; /*nomal*/
             if((step==1)&&(x>8650.0)) targ_velocity=-speed,step=2,flagf=0;
             if((step==2)&&(x<1700.0)) {
@@ -70,13 +70,11 @@
                 step=3;
                 sendData(7,31);
             }
-            if((step==3)&&(x<-100.0)) targ_velocity=0.0,step=8;
-            /*if((step==2)&&(x<1950.0)) {
-                targ_sita=PI/4;
-                step=3;
-                sendData(7,31);
+            if((step==3)&&(x<-100.0)) {
+                targ_velocity=0.0;
+                step=8;
+                autoflag = 0;
             }
-            if((step==3)&&(x<70.0)) targ_velocity=0.0,step=8;*/
             
             if((step==4)&&((5700.0>x)&&(x>600.0))) targ_sita=0.03,step=5; /*middle*/
             if((step==5)&&(x>5000.0)) { /*middle shoot*/
@@ -90,7 +88,11 @@
                 step=7;
                 sendData(7,31);
             }
-            if((step==7)&&(x<-100.0)) targ_velocity=0.0,step=8;
+            if((step==7)&&(x<-100.0)) {
+                targ_velocity=0.0;
+                step=8;
+                autoflag = 0;
+            }
             
             if((x>2900.0)&&(CStep==1)) { /*nomal*/
                 if(!skip) sendData(1,1);
@@ -112,12 +114,6 @@
                 if(!skip) sendData(1,4);
                 CStep=6;
             }
-            
-            /*if((x>3344.0)&&(CStep==1)) CStep=2,sendData(1,1);
-            if((x>6234.0)&&(CStep==2)) CStep=3,sendData(1,2);
-            if((x>7885.0)&&(CStep==3)) CStep=4,sendData(1,3);
-            if((x<6750.0)&&(CStep==4)) CStep=5,sendData(1,5);
-            if((x<6300.0)&&(CStep==5)) CStep=6,sendData(1,4);*/
 
 #else       
             //Red
@@ -128,8 +124,11 @@
                 step=3;
                 sendData(7,31);
             }
-            if((step==3)&&(x<-100.0)) targ_velocity=0.0,step=8;
-            
+            if((step==3)&&(x<-100.0)) {
+                targ_velocity=0.0;
+                step=8;
+                autoflag=0;
+            }
             
             if((step==4)&&((5700.0>x)&&(x>600.0))) targ_sita=-0.03,step=5; /*middle*/
             if((step==5)&&(x>5000.0)) { /*middle shoot*/
@@ -143,7 +142,11 @@
                 step=7;
                 sendData(7,31);
             }
-            if((step==7)&&(x<-100.0)) targ_velocity=0.0,step=8;
+            if((step==7)&&(x<-100.0)) {
+                targ_velocity=0.0;
+                step=8;
+                autoflag=0;
+            }
             
             if((x>2900.0)&&(CStep==1)&&(!skip)) CStep=2,sendData(1,1);
             if((x>5850.0)&&(CStep==2)&&(!skip)) CStep=3,sendData(1,3);
@@ -151,9 +154,11 @@
             if((x<6600.0)&&(CStep==4)&&(!skip)) CStep=5,sendData(1,4);
             if((x<6100.0)&&(CStep==5)&&(!skip)) CStep=6,sendData(1,5);
 #endif
-            move_following();
+            mesure_state();   /*位置測定*/
+            move_following(); /*位置移動*/
         }
         else if(!autoflag) {
+            resetState();
 #ifdef IM920
             manualMoveIM920(); /*analogStick*/
             manualIM920();     /*IM920 button*/
@@ -174,7 +179,6 @@
 #ifdef IM920
         readIM920();
 #endif
-        mesure_state();
         mesureSwing();
         wait(RATE);