春ロボ ロケット団 / Mbed 2 deprecated Spring_motor_test2

Dependencies:   mbed SpeedController Encoder CruizCore_R1370P

Revision:
15:e26bad257626
Parent:
14:4bdb572bf464
Child:
16:7ce4ab00621a
diff -r 4bdb572bf464 -r e26bad257626 main.cpp
--- a/main.cpp	Thu Mar 05 08:02:27 2020 +0000
+++ b/main.cpp	Thu Mar 05 08:50:38 2020 +0000
@@ -155,7 +155,7 @@
     }
 }
 
-double a=1;
+double z=1;
 
 int main()
 {
@@ -196,7 +196,7 @@
 
         x=location.getX();
         y=location.getY();
-        printf("X=%d,Y=%d theta=%5.3f \r\n",x,y,theta);
+        printf("X=%d,Y=%d theta=%5.3f z=%5.3f \r\n",x,y,theta,z);
 
         //目的地決定(syuusoku check)
         aimX = plot[n][0];
@@ -208,14 +208,14 @@
         vy=dy/sqrt((double)dx*dx+dy*dy);
 
         //四輪の出力計算
-        omega.setOmega(a);
+        omega.setOmega(z);
         omega.setVxy(vx,vy);
         omega.calOmega();
 
         if(dx<300 &&dx>-300) {
             if(dy<300 && dy>-300) {
-                if(a>5) {
-                    a=a-0.1;
+                if(z>5) {
+                    z=z-0.1;
                 }
                 if(dx<50 && dx>-50) {
                     if(dy<50 && dy>-50) {
@@ -231,9 +231,12 @@
                 }
             }
 
-        } else {
-            if(a<10) {
-                a=a+0.01;
+        }
+        if(dx>300 || dx<-300) {
+            if(dy>300 || dy<-300) {
+                if(z<10) {
+                    z=z+0.1;
+                }
             }
         }
         if(n>4) {