Omni_2017_z

Dependencies:   MD_PID mbed

Files at this revision

API Documentation at this revision

Comitter:
hirotayamato
Date:
Sat Aug 05 07:26:38 2017 +0000
Parent:
3:49450eb53b6f
Commit message:
Omni_2017_b

Changed in this revision

2017_3_b/2017_3_b.cpp Show annotated file Show diff for this revision Revisions of this file
2017_3_b/2017_3_b.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/2017_3_b/2017_3_b.cpp	Sat Aug 05 06:41:15 2017 +0000
+++ b/2017_3_b/2017_3_b.cpp	Sat Aug 05 07:26:38 2017 +0000
@@ -2,35 +2,23 @@
 #include "mbed.h"
 #include <math.h>
 
-Omni_3::Omni_3(PinName pin_pwm_F1, PinName pin_pwm_F2, PinName pin_dere_F1, PinName pin_dere_F2, PinName pin_channelA_F, PinName pin_channelB_F,
-               PinName pin_pwm_L1, PinName pin_pwm_L2, PinName pin_dere_L1, PinName pin_dere_L2, PinName pin_channelA_L, PinName pin_channelB_L,
-               PinName pin_pwm_R1, PinName pin_pwm_R2, PinName pin_dere_R1, PinName pin_dere_R2, PinName pin_channelA_R, PinName pin_channelB_R,
+Omni_3::Omni_3(PinName pin_pwm_F, PinName pin_dere_F, PinName pin_channelA_F, PinName pin_channelB_F,
+               PinName pin_pwm_L, PinName pin_dere_L, PinName pin_channelA_L, PinName pin_channelB_L,
+               PinName pin_pwm_R, PinName pin_dere_R, PinName pin_channelA_R, PinName pin_channelB_R,
                int arg_rev)
 {
-    md_f1 = Create_MD_PID(pin_channelA_F, pin_channelB_F, NC, 500, QEI::X4_ENCODING, 
+    md_f = Create_MD_PID(pin_channelA_F, pin_channelB_F, NC, 500, QEI::X4_ENCODING, 
                          0.095 * 2, 0, 0.002 * 4, 500, 
-                         pin_pwm_F1, pin_dere_F1);
+                         pin_pwm_F, pin_dere_F);
                          
-    md_f2 = Create_MD_PID(pin_channelA_F, pin_channelB_F, NC, 500, QEI::X4_ENCODING,
+    md_l = Create_MD_PID(pin_channelA_L, pin_channelB_L, NC, 500, QEI::X4_ENCODING,
     					 0.095 * 2, 0, 0.002 * 4, 500,
-    					 pin_pwm_F2, pin_dere_F2);
-    
-    md_l1 = Create_MD_PID(pin_channelA_L, pin_channelB_L, NC, 500, QEI::X4_ENCODING,
-    					 0.095 * 2, 0, 0.002 * 4, 500,
-    					 pin_pwm_L1, pin_dere_L1);
+    					 pin_pwm_L, pin_dere_L);
     
-    md_l2 = Create_MD_PID(pin_channelA_L, pin_channelB_L, NC, 500, QEI::X4_ENCODING,
-    					 0.095 * 2, 0, 0.002 * 4, 500,
-    					 pin_pwm_L2, pin_dere_L2);
-    
-    md_r1 = Create_MD_PID(pin_channelA_R, pin_channelB_R, NC, 500, QEI::X4_ENCODING,
+    md_r = Create_MD_PID(pin_channelA_R, pin_channelB_R, NC, 500, QEI::X4_ENCODING,
     					 0.095 * 2, 0, 0.002 * 4, 500,
-    					 pin_pwm_R1, pin_dere_R1);
+    					 pin_pwm_R, pin_dere_R);
     					 
-    md_r2 = Create_MD_PID(pin_channelA_R, pin_channelB_R, NC, 500, QEI::X4_ENCODING,
-    					 0.095 * 2, 0, 0.002 * 4, 500,
-    					 pin_pwm_R2, pin_dere_R2);
-    
     rev = arg_rev;
 }
 
@@ -57,12 +45,9 @@
             }
         }
     }
-    md_f1->Drive(duty[0] * F_Gain, 100);
-    md_f2->Drive(duty[0] * F_Gain, 100);
-    md_l1->Drive(duty[1] * L_Gain, 100);
-    md_l2->Drive(duty[1] * L_Gain, 100);
-    md_r1->Drive(duty[2] * R_Gain, 100);
-    md_r2->Drive(duty[2] * R_Gain, 100);
+    md_f->Drive(duty[0] * F_Gain, 100);
+    md_l->Drive(duty[1] * L_Gain, 100);
+    md_r->Drive(duty[2] * R_Gain, 100);
 }
 
 void Omni_3::Matrix(double speed[3], double duty[3])
@@ -84,4 +69,4 @@
             duty[i] += keisu[i][j] * speed[j] * rev;
         }
     }
-}
\ No newline at end of file
+}
--- a/2017_3_b/2017_3_b.h	Sat Aug 05 06:41:15 2017 +0000
+++ b/2017_3_b/2017_3_b.h	Sat Aug 05 07:26:38 2017 +0000
@@ -6,9 +6,9 @@
 
 class Omni_3{
 public:
-    Omni_3(PinName pin_pwm_F1, PinName pin_pwm_F2, PinName pin_dere_F1, PinName pin_dere_F2, PinName pin_channelA_F, PinName pin_channelB_F,
-           PinName pin_pwm_L1, PinName pin_pwm_L2, PinName pin_dere_L1, PinName pin_dere_L2, PinName pin_channelA_L, PinName pin_channelB_L,
-           PinName pin_pwm_R1, PinName pin_pwm_R2, PinName pin_dere_R1, PinName pin_dere_R2, PinName pin_channelA_R, PinName pin_channelB_R,
+    Omni_3(PinName pin_pwm_F, PinName pin_dere_F, PinName pin_channelA_F, PinName pin_channelB_F,
+           PinName pin_pwm_L, PinName pin_dere_L, PinName pin_channelA_L, PinName pin_channelB_L,
+           PinName pin_pwm_R, PinName pin_dere_R, PinName pin_channelA_R, PinName pin_channelB_R,
            int rev = 1);
     void Drive( double arg_x, double arg_y, double arg_rota,
     			double F_Gain = 1.0, double L_Gain = 1.0, double R_Gain = 1.0);
@@ -16,12 +16,9 @@
 private:
     void Matrix(double speed[3], double duty[3]);
     int rev;
-    MD_PID *md_f1;
-    MD_PID *md_f2;
-    MD_PID *md_l1;
-    MD_PID *md_l2;
-    MD_PID *md_r1;
-    MD_PID *md_r2;
+    MD_PID *md_f;
+    MD_PID *md_l;
+    MD_PID *md_r;
 };
 #endif
 
--- a/main.cpp	Sat Aug 05 06:41:15 2017 +0000
+++ b/main.cpp	Sat Aug 05 07:26:38 2017 +0000
@@ -4,7 +4,7 @@
 #include "MD_PID.h"
 #include "QEI.h"
 
-Omni_3 Omni(p21, p22, p18, p17, p11, p12, p23, p24, p16, p15, p27, p28, p25, p26, p14, p13, p29, p30, 1);
+Omni_3 Omni(p21, p18, p11, p12, p22, p17, p27, p28, p23, p16, p29, p30, 1);
 
 Serial pc (USBTX, USBRX);
 I2CSlave slave(p9, p10);
@@ -51,3 +51,4 @@
     }
 }
 
+