2015_robocon_bteam / Mbed 2 deprecated 2015robot_main

Dependencies:   PID QEI mbed

Fork of 2015robot_main by Naoto Deguchi

Revision:
77:7dd154b5ace3
Parent:
76:f9bcb7ac438f
Child:
78:abb760e0a935
--- a/main_ps3.cpp	Sat Oct 10 04:28:27 2015 +0000
+++ b/main_ps3.cpp	Sat Oct 10 08:16:47 2015 +0000
@@ -30,6 +30,11 @@
 
 Serial pc(USBTX, USBRX);
 //LocalFileSystem local("local");
+Timeout MStop;
+
+void Restart(){
+    if(step==10) step=11;
+}
 
 int main() {
 #ifdef IM920
@@ -73,13 +78,13 @@
             }
             if((step==3)&&(x<-100.0)) {
                 targ_velocity=0.0;
-                step=114;
+                step=114;-
                 autoflag = 0;
             }
             /***Cylinder***/
             if((x>2900.0)&&(CStep==1)) { /*nomal*/
                 if(!skip) sendData(1,1);
-                CStep=2;
+                CStep=2; 
             }
             if((x>5850.0)&&(CStep==2)) {
                 if(!skip) sendData(1,2);
@@ -99,7 +104,10 @@
             }
             /////////////////////////////////////////////////////////////////////////
             /******************************Middle Mode******************************/
-            if((step==4)&&((5700.0>x)&&(x>600.0))) targ_sita=0.03,step=5; /*middle*/
+            if((step==4)&&((5700.0>x)&&(x>600.0))) {/*middle*/
+                targ_sita=0.03;
+                step=5;
+            }
             if((step==5)&&(x>5000.0)) { 
                 targ_velocity=-speed;
                 step=6;
@@ -117,6 +125,39 @@
                 autoflag = 0;
             }
             /////////////////////////////////////////////////////////////////////////
+            /*****************************Opponents Mode****************************/
+            if((step==8)&&(x>1500.0)) {
+                targ_sita=-PI/2.0;
+                step=9;
+            }
+            if((step==9)&&(y<-1000.0)) {
+                targ_velocity = 0.0;
+                targ_sita     = 4.0 * ( PI / 9.0 );
+                step=10;
+            }
+            if((step==10)&&(abs(sita-targ_sita)<0.05)) {
+                sendData(1,4);
+                MStop.attach(Restart,0.5);
+            }
+            if(step==11){
+                targ_sita     = 0.0;
+                step          = 12;
+            }
+            if((step==12)&&(abs(sita-targ_sita)<0.05)){
+                targ_velocity = -speed;
+                flagf         = 0;
+                step          = 13;
+            }
+            if((step==13)&&(y>0.0)){
+                targ_sita     = 0.0;
+                step          = 14;
+            }
+            if((step==14)&&(x<-100.0)){
+                targ_velocity = 0.0;
+                targ_sita     = PI/4.0;
+                step          = 114;
+            }
+            /////////////////////////////////////////////////////////////////////////
 #else       
             //Red
             /********************************Nomal Mode*********************************/
@@ -155,7 +196,11 @@
             }
             /////////////////////////////////////////////////////////////////////////
             /******************************Middle Mode******************************/
-            if((step==4)&&((5700.0>x)&&(x>600.0))) targ_sita=-0.03,step=5; /*middle*/
+            if((step==4)&&((5700.0>x)&&(x>600.0))) { /*middle*/
+                targ_sita=-0.03;
+                step=5;
+                medge=1; 
+            }
             if((step==5)&&(x>5000.0)) {
                 targ_velocity=-speed;
                 step=6;