ken fuji / omuni3

Dependencies:   P_motor T_motor

Fork of omuni by gaku takasawa

Revision:
6:d01b00b57d54
Parent:
5:5133533ed6d2
diff -r 5133533ed6d2 -r d01b00b57d54 omuni.cpp
--- a/omuni.cpp	Mon Oct 16 09:57:14 2017 +0000
+++ b/omuni.cpp	Mon Oct 23 13:29:16 2017 +0000
@@ -52,15 +52,23 @@
         if((sieta1 < -PI/3 && sieta1 > -2*PI/3.0))
             w = -PI/3;
     }
-    float s1 = r2*float(sin(alpha)*-x2*0.01) + float(L*w);
-    float s2 = r2*float(sin(alpha+4.0/3*PI)*-x2 - cos(alpha+4.0/3*PI)*y2)*0.01 + float(L*w);
-    float s3 = r2*float(sin(alpha+2.0/3*PI)*-x2 - cos(alpha+2.0/3*PI)*y2)*0.01 + float(L*w);
-    m1 = s1;
-    m2 = s2;
-    m3 = s3;
-    m1.run();
-    m2.run();
-    m3.run();
+    
+    if(r2)
+    {
+        m1 = r2*float(sin(alpha)*-x2*0.01) + float(L*w);
+        m2 = r2*float(sin(alpha+4.0/3*PI)*-x2 - cos(alpha+4.0/3*PI)*y2)*0.01 + float(L*w);
+        m3 = r2*float(sin(alpha+2.0/3*PI)*-x2 - cos(alpha+2.0/3*PI)*y2)*0.01 + float(L*w);
+        m1.run();
+        m2.run();
+        m3.run();
+    }
+    else
+    {
+        float spdt = 0.5f * float(L*w);
+        m1.direct_controll(spdt);
+        m2.direct_controll(spdt);
+        m3.direct_controll(spdt);
+    }
     //printf("%5.2f : %5.2f : %5.2f : %5.2f",(float)x2,(float)y2,sieta1*180/PI,r1);
     //printf("\n");
 }
\ No newline at end of file