ken fuji / omuni3

Dependencies:   P_motor T_motor

Fork of omuni by gaku takasawa

Files at this revision

API Documentation at this revision

Comitter:
fujikenac
Date:
Mon Oct 23 13:29:16 2017 +0000
Parent:
5:5133533ed6d2
Commit message:
fix roll

Changed in this revision

P_motor.lib Show annotated file Show diff for this revision Revisions of this file
omuni.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/P_motor.lib	Mon Oct 16 09:57:14 2017 +0000
+++ b/P_motor.lib	Mon Oct 23 13:29:16 2017 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/fujikenac/code/P_motor/#9d893f55d17f
+https://os.mbed.com/users/fujikenac/code/P_motor/#483f189d3508
--- 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