Fujisawaコードをリスペクトした4輪オムニのラフコードだよ

Dependencies:   mbed

Fork of 4wd_omni by Bチーム

Files at this revision

API Documentation at this revision

Comitter:
Hatter
Date:
Sat Jun 28 06:58:19 2014 +0000
Commit message:
Fujisawa???????????4????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9a36dbb02bc8 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jun 28 06:58:19 2014 +0000
@@ -0,0 +1,58 @@
+/*
+ * 4WD_OMNI  by Tomoki Hokida
+ * Every direction Type
+ *
+ */
+
+#include "mbed.h"
+#include <math.h>
+
+#define PI 3.141592
+
+Serial pc(USBTX,USBRX);
+DigitalOut check(LED1);
+PwmOut wh[4] = {p21,p22,p23,p24};
+
+void moveOmni(int ox,int oy)
+{
+    double trans[4] = {0};
+
+    trans[0] = ox*(cos(0.75*PI)) + oy*(sin(0.75*PI));
+    trans[1] = ox*(cos(-0.75*PI)) + oy*(sin(-0.75*PI));
+    trans[2] = ox*(cos(-0.25*PI)) + oy*(sin(-0.25*PI));
+    trans[3] = ox*(cos(0.25*PI)) + oy*(sin(0.25*PI));
+
+    for(int i=0;i<4;i++){
+
+        if(trans[i]>100){
+            trans[i]=100; 
+        }else if(trans[i]<-100){
+            trans[i]=-100;
+        }
+
+        wh[i] = (trans[i]/100.0);        
+    }
+
+    pc.printf("motor:%f, motor:%f, motor:%f, motor:%f\n",trans[0],trans[1],trans[2],trans[3]);
+}
+
+int main()
+{
+    int ix,iy;
+
+    for(;;){
+        ix=0;
+        iy=0;
+
+        //ex value 
+        switch(pc.getc()){
+            case '1': ix = iy = -100; break;
+            case '2': ix = iy = 0; break;
+            case '3': ix = iy = 100; break;        
+        }    
+        moveOmni(ix,iy);  
+        
+        check = !check; 
+    }
+
+}
\ No newline at end of file
diff -r 000000000000 -r 9a36dbb02bc8 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jun 28 06:58:19 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/024bf7f99721
\ No newline at end of file