ジャパンオープン用のメインプログラム

Dependencies:   mbed AQM1602 HMC6352 PID

Files at this revision

API Documentation at this revision

Comitter:
lilac0112_1
Date:
Sun Mar 27 13:04:39 2016 +0000
Parent:
37:6100c01f402d
Commit message:
JapanSoccerOpen2016 CatPot Program(main)

Changed in this revision

main_processing/strategy/LineProcess.cpp Show annotated file Show diff for this revision Revisions of this file
main_processing/strategy/strategy.cpp Show annotated file Show diff for this revision Revisions of this file
main_processing/strategy_parts/input.cpp Show annotated file Show diff for this revision Revisions of this file
setting/def.h Show annotated file Show diff for this revision Revisions of this file
diff -r 6100c01f402d -r 67bc78f3c0ab main_processing/strategy/LineProcess.cpp
--- a/main_processing/strategy/LineProcess.cpp	Fri Mar 25 14:56:52 2016 +0000
+++ b/main_processing/strategy/LineProcess.cpp	Sun Mar 27 13:04:39 2016 +0000
@@ -346,6 +346,8 @@
 void LineJudgeReturn2(double pow_x, double pow_y, double *x, double *y){
     const int8_t static LineReturn[5] = {0, 0, 0, 0, 20};
     uint8_t LinePingState[4];
+    //JSO2
+    static uint8_t lnRawReturn1 = 0;
     //◎ボールを追う力とラインから離れる力の向きが違うならばラインから離れる力が優先される.
     //◎ボールを追う力とラインから離れる力の向きが同じならばボールを追う力が優先される.
     //◎ラインセンサ全てが場外になるまではボールを追う力は作用しない.ボールを追う力は場内に出るまで作用する.
@@ -374,12 +376,54 @@
         ){
             data.lnStop[Y_LINE]=0;
             *y = -LineReturn[4];
+            //JSO1
+            if(
+                (data.ping[F_PING]<45)&&
+                (data.lnRawReturn==1)//JSO2
+            ){
+                data.lnStop[X_LINE]=0;
+            }
+            //JSO2
+            if(
+                (
+                    ((Line[A_SPOT].read()==1)&&(Line[B_SPOT].read()==0))||
+                    ((LineHolding[A_SPOT].read()==1)&&(LineHolding[B_SPOT].read()==0))
+                )&&
+                (data.ping[F_PING]>45)&&
+                (data.ping[F_PING]<200)&&
+                (data.ping[R_PING]<25)&&
+                (data.ping[L_PING]>40)
+            ){
+                *x = -LineReturn[4];
+                data.lnStop[X_LINE]=0;
+            }
+            if(
+                (
+                    ((Line[A_SPOT].read()==0)&&(Line[B_SPOT].read()==1))||
+                    ((LineHolding[A_SPOT].read()==0)&&(LineHolding[B_SPOT].read()==1))
+                )&&
+                (data.ping[F_PING]>45)&&
+                (data.ping[F_PING]<200)&&
+                (data.ping[L_PING]<25)&&
+                (data.ping[R_PING]>40)
+            ){
+                *x = LineReturn[4];
+                data.lnStop[X_LINE]=0;
+            }
         }
         else if(
             ((data.lnRawOrder[0]==C_SPOT)&&(1)&&(1))
         ){
             data.lnStop[Y_LINE]=0;
             *y = LineReturn[4];
+            
+            //JSO1
+            if(
+                (data.ping[B_PING]<45)&&
+                (data.lnRawReturn==1)
+            ){
+                data.lnStop[X_LINE]=0;
+            }
         }
         else if(//x
             ((data.lnRawOrder[0]==A_SPOT)&&(data.lnRawOrder[1]==C_SPOT)&&(1))
@@ -432,6 +476,12 @@
                       data.lnStop[Y_LINE]=0;
                     }
                 }
+                //JSO2
+                if((LineHolding[A_SPOT].read()==1)&&(LineHolding[B_SPOT].read()==1)&&(LineHolding[C_SPOT].read()==0)&&(data.lnRawReturn==1)){
+                    *y = -LineReturn[4];
+                    data.lnStop[Y_LINE]=0;
+                }
+                
                 if((LinePingState[B_PING]==1)&&(LinePingState[F_PING]==0)){
                     if(pow_y>0){
                       *y = 0;
@@ -450,6 +500,60 @@
         }
         else{
             data.lnRawReturn=0;
+            
+            //JSO3
+            if((data.lnOrder[0]==A_SPOT)&&(data.lnOrder[1]==LINE_EMPTY)&&(pow_x>0)){
+                data.lnStop[X_LINE]=0;
+            }
+            if((data.lnOrder[0]==B_SPOT)&&(data.lnOrder[1]==LINE_EMPTY)&&(pow_x<0)){
+                data.lnStop[X_LINE]=0;
+            }
+            //JSO3
+            if((Line[C_SPOT].read()==1)&&(1)&&(pow_y>0)){
+                data.lnStop[Y_LINE]=0;
+            }
+        }
+        //JSO3
+        if((Line[C_SPOT].read()==1)&&(1)&&(pow_y>0)){
+            data.lnStop[Y_LINE]=0;
+        }
+        //JSO1
+        if(data.lnRawReturn==1){
+            //JSO2
+            if((lnRawReturn1==0)){
+                LineLiberate();
+                lnRawReturn1=1;
+            }
+            
+            if(
+                (
+                    ((data.lnRawOrder[0]==A_SPOT)&&(data.lnRawOrder[1]==C_SPOT)&&(1))||
+                    ((data.lnRawOrder[0]==B_SPOT)&&(data.lnRawOrder[1]==C_SPOT)&&(1))
+                )&&
+                //((Line[A_SPOT].read()==1)&&(Line[B_SPOT].read()==1))&&//JSO1
+                ((LineHolding[A_SPOT].read()==1)&&(LineHolding[B_SPOT].read()==1))&&//JSO2
+                ((data.ping[F_PING]<45)&&(1))&&//JSO2
+                //(!((data.ping[B_PING]<40)&&(data.ping[B_PING]>25)))&&//JSO2
+                ((data.lnRawOrder[0]!=C_SPOT)&&(data.lnRawOrderLog1[0]!=C_SPOT)&&(data.lnRawOrderLog2[0]!=C_SPOT))
+                
+            ){
+                *y = -LineReturn[4];
+                data.lnStop[Y_LINE]=0;//JSO2
+            }
+        }
+        else{
+            lnRawReturn1=0;
+            
+            
+            if((LinePingState[L_PING]==0)&&(LinePingState[R_PING]==1)){
+                *x = -LineReturn[4];
+                data.lnStop[X_LINE]=0;
+            }
+            if((LinePingState[L_PING]==1)&&(LinePingState[R_PING]==0)){
+                *x = LineReturn[4];
+                data.lnStop[X_LINE]=0;
+            }
+            
         }
         
     }
diff -r 6100c01f402d -r 67bc78f3c0ab main_processing/strategy/strategy.cpp
--- a/main_processing/strategy/strategy.cpp	Fri Mar 25 14:56:52 2016 +0000
+++ b/main_processing/strategy/strategy.cpp	Sun Mar 27 13:04:39 2016 +0000
@@ -46,6 +46,9 @@
         //LineLiberate();
         //LineRankClear();
         
+        //JSO2
+        LineLiberate();
+        
         LineRawRankClear();
         
         //data.lnRawMemory[A_SPOT]=0;
@@ -423,7 +426,8 @@
         }
         else{
             ir_x = 0;
-            //sys.HomeStayFlag[X_PING]=1;
+            //
+            sys.HomeStayFlag[X_PING]=1;
         }
         //y
         if((data.ping[B_PING]>60)&&(1)&&(sys.HomeStayFlag[Y_PING]==0)){
@@ -443,7 +447,8 @@
                 ir_y = 0;
             }
             */
-            //sys.HomeStayFlag[Y_PING]=1;
+            //
+            sys.HomeStayFlag[Y_PING]=1;
         }
     }
     else{
@@ -451,12 +456,22 @@
         ir_y = (ir_y_dir + ir_y_turn);
     }
     if((sys.HomeBlind==0)&&(data.irNotice==IR_FAR)){
-        ir_pow_x = ir_pow_y = 25;
-        if(ir_y>0) ir_y=0;
-        if((data.ping[B_PING]>40)&&(1)){
+        if(ir_y>0){
+            ir_y=0;
+            ir_pow_x = ir_pow_y = 25;
+            
+            if((data.ping[B_PING]>50)&&(1)){
+                ir_y = -1;
+                //ir_pow_y = 15;
+            }
+            
+        }
+        //ir_pow_x = ir_pow_y = 25;
+        //if(ir_y>0) ir_y=0;
+        /*if((data.ping[B_PING]>40)&&(1)){
             ir_y = -1;
             //ir_pow_y = 15;
-        }
+        }*/
     }
     if(
         (sys.DefenceFlag==1)&&
@@ -511,12 +526,24 @@
             }
         }
         else{
-            ir_x = 0;
+            if((abs(data.ping[L_PING]-data.ping[R_PING])>10)&&(1)){
+                if(data.ping[L_PING]>data.ping[R_PING]){
+                    ir_x = -1;
+                }
+                else{
+                    ir_x = 1;
+                }
+            }
+            else{
+                ir_x = 0;
+            }
+            
+            //ir_x = 0;
             DriveSolenoid();
         }
         //y
         if((data.ping[F_PING]<45)&&(abs(data.ping[L_PING]-data.ping[R_PING])>50)){
-            ir_y = 0.75;
+            //ir_y = 0.75;
         }
         //kick
         if((abs(data.ping[L_PING]-data.ping[R_PING])<30)&&(1)){
diff -r 6100c01f402d -r 67bc78f3c0ab main_processing/strategy_parts/input.cpp
--- a/main_processing/strategy_parts/input.cpp	Fri Mar 25 14:56:52 2016 +0000
+++ b/main_processing/strategy_parts/input.cpp	Sun Mar 27 13:04:39 2016 +0000
@@ -134,6 +134,9 @@
 }
 void LineRawRankClear(void){
     
+    //JSO2
+    LineLiberate();
+    
     data.lnRawOrderLog2[0]=data.lnRawOrderLog1[0];
     data.lnRawOrderLog2[1]=data.lnRawOrderLog1[1];
     data.lnRawOrderLog2[2]=data.lnRawOrderLog1[2];
diff -r 6100c01f402d -r 67bc78f3c0ab setting/def.h
--- a/setting/def.h	Fri Mar 25 14:56:52 2016 +0000
+++ b/setting/def.h	Sun Mar 27 13:04:39 2016 +0000
@@ -2,8 +2,8 @@
 #define _DEF_H_
 
 //red or green
-//#define RED_CAT//jj
-#define GREEN_CAT//lily
+#define RED_CAT//jj
+//#define GREEN_CAT//lily
 
 //BT(BlueTooth)
 #define DATA_NUM 8+2//2byte→KEYCODE(拝啓)とCHECKCODE(敬具) 8byte→やりとりするデータ
@@ -202,7 +202,7 @@
 #define MD_1CH (1)
 #define MD_2CH (1)
 #define MD_3CH (-1)
-#define MD_4CH (1)
+#define MD_4CH (-1)
 #endif /*GREEN_CAT*/