keiichi shimazu / Mbed 2 deprecated NITKK2019_WinterB-Manual_madebyshimazu

Dependencies:   mbed mdc_read

Revision:
0:9d5b8d0fb901
Child:
1:39ada37dfdbe
diff -r 000000000000 -r 9d5b8d0fb901 Control.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Control.cpp	Fri Dec 27 02:58:06 2019 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "Control.h"
+#include "pinmap.h"
+void control::setup(){
+    sb.setup(0);
+}
+
+void control::run(){
+ 
+    OmniControl;   
+}  
+
+void control::OmniControl(){
+    
+    Vx = sb.joySstick_dt[0] * -1;
+    Vy = sb.joySstick_dt[1];
+    wl = sb.joySstick_dt[2];
+    
+    pwm[0]=     (Vx - Vy)*bias[0] + wl;
+    pwm[1]=(-1)*(Vx + Vy)*bias[1] + wl;
+    pwm[2]=(-1)*(Vx - Vy)*bias[2] + wl;
+    pwm[3]=     (Vx + Vy)*bias[3] + wl;
+    
+    for(int i = 0; i < 4; i++){
+        if(pwm[i] > 127){
+            pwm[i] =127;
+        }else if(pwm[i] < -127){
+            pwm[i] = -127;
+        }
+    }
+    
+    mt1.move(pwm[0]/130.0f);
+    mt2.move(pwm[1]/130.0f);
+    mt3.move(pwm[2]/130.0f);
+    mt4.move(pwm[3]/130.0f);
+    
+    
+    
+    
+    
+}    
\ No newline at end of file