手動b足回り

Dependents:   kobayashi_rei

Files at this revision

API Documentation at this revision

Comitter:
THtakahiro702286
Date:
Mon Sep 09 04:48:30 2019 +0000
Parent:
2:9017bbe177b7
Commit message:
wheelUnit

Changed in this revision

wheelUnit.cpp Show annotated file Show diff for this revision Revisions of this file
wheelUnit.h Show annotated file Show diff for this revision Revisions of this file
--- a/wheelUnit.cpp	Thu Jul 11 09:19:29 2019 +0000
+++ b/wheelUnit.cpp	Mon Sep 09 04:48:30 2019 +0000
@@ -5,18 +5,23 @@
     pc(USBTX, USBRX, 115200)
 {
     md = new ikarashiMDC*[4];
-    for(int i = 0; i < 4; ++i) md[i] = new ikarashiMDC(2,i,SM,serial);
-    for(int i = 0; i < 4; ++i) md[i]->braking = true;
+    for(int i = 0; i < 4; i++) md[i] = new ikarashiMDC(1,i,SM,serial);
+    for(int i = 0; i < 4; i++) md[i]->braking = true;
     for(int i = 0; i < 4; i++) omni.wheel[i].setRadian(PI / 4.0 * (2.0*i+1.0));
 }
 
+void WheelUnit::setBrake(int trigger)
+{
+    brake = (255 - trigger) / 255.0;
+}
+
 void WheelUnit::move(float x,float y,float turnPower)
 {
     omni.computeXY(x,y,turnPower);
     for (int i = 0; i < 4; ++i) wheel[i] = omni.wheel[i];
-    for (int i = 0; i < 4; ++i) md[i]->setSpeed(wheel[i] * SPEEDRATE);
+    for (int i = 0; i < 4; ++i) md[i]->setSpeed(wheel[i] * brake);
     print = omni.wheel[0];
-    pc.printf("%f\n\r",print);
+//    pc.printf("%f\n\r",print);
 }
 
 void WheelUnit::stop()
--- a/wheelUnit.h	Thu Jul 11 09:19:29 2019 +0000
+++ b/wheelUnit.h	Mon Sep 09 04:48:30 2019 +0000
@@ -12,6 +12,7 @@
 {
 public:
     WheelUnit(Serial* serial);
+    void setBrake(int trigger);
     void move(float x,float y,float turnPower);
     void stop();
 
@@ -21,6 +22,7 @@
     Serial pc;
     float print;
     float wheel[4];
+    float brake;
 };
 
 #endif
\ No newline at end of file