2015_robocon_bteam / Mbed 2 deprecated 2015robot_main_zenkoku

Dependencies:   PID QEI mbed

Revision:
3:8d8c25c556ae
Parent:
2:738b28f6a04b
Child:
4:09f684eac572
--- a/main_ps3.cpp	Fri Oct 30 09:21:03 2015 +0000
+++ b/main_ps3.cpp	Sat Oct 31 00:30:52 2015 +0000
@@ -3,8 +3,8 @@
  */
 
 /***コース選択***/
-//#define BLUE
-#define RED
+#define BLUE
+//#define RED
 
 /***コントローラ選択***/
 #define IM920
@@ -31,24 +31,6 @@
 LocalFileSystem local("local");
 #endif
 
-Ticker Com;
-void Call(){
-    mesure_state();
-    if(autoflag){
-        move_following();
-        if(spcount<speed){
-            spcount+=speed/100.0;
-            targ_velocity=spcount;
-        }
-    }
-#ifdef MESURE
-    if(mesureflag){
-        fprintf(fp_r, "%1.3f %f\r\n",time,velocity);
-        time+=0.01;
-    }
-#endif
-}
-
 int main() {
     Com.attach(&Call,RATE);
 #ifdef IM920
@@ -85,20 +67,24 @@
             //Blue            
             /********************************Nomal Mode*********************************/
             if((step==0)&&((8650.0>x)&&(x>800.0))) {
-                targ_sita=0.025;
+//                targ_sita=0.025;
+                targ_sita=0.0;
                 step=1;
             }
             if((step==1)&&(x>8600.0+deff)) {
                 targ_velocity=0.0;
                 direction_controller.setBias(0.0);
                 direction_controller.reset();
+                velocity_controller.setBias(0.0);
+                velocity_controller.reset();
                 step=2;
             }
             if((step==2)&&((velocity<500.0)&&(velocity>-500.0))){
                 step=3;
                 spcount=0.0;
                 flagf=0;
-                targ_sita=0.035;
+                targ_sita=0.1;
+//                targ_sita=0.0;
             }
             if((step==3)&&(x<2000.0)) {
                 targ_sita=PI/4;
@@ -136,7 +122,8 @@
             /////////////////////////////////////////////////////////////////////////
             /******************************Middle Mode******************************/
             if((step==5)&&((5700.0>x)&&(x>800.0))) {
-                targ_sita=0.025;
+//                targ_sita=0.025;
+                targ_sita=0.0;
                 step=6;
             }
             if((step==6)&&(x>7000.0)){
@@ -358,6 +345,7 @@
         }
         else if(!autoflag) {
             flaga=0;
+            mesureSwing();
 #ifdef IM920
             manualMoveIM920(); /*analogStick*/
             manualIM920();     /*IM920 button*/