手動b足回り

Dependents:   kobayashi_rei

Committer:
THtakahiro702286
Date:
Mon Sep 09 04:48:30 2019 +0000
Revision:
3:01a6eca21b23
Parent:
2:9017bbe177b7
wheelUnit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
THtakahiro702286 0:0d52f303ac08 1 #include "wheelUnit.h"
THtakahiro702286 0:0d52f303ac08 2
THtakahiro702286 0:0d52f303ac08 3 WheelUnit::WheelUnit(Serial* serial) :
THtakahiro702286 0:0d52f303ac08 4 omni(4),
THtakahiro702286 0:0d52f303ac08 5 pc(USBTX, USBRX, 115200)
THtakahiro702286 0:0d52f303ac08 6 {
THtakahiro702286 0:0d52f303ac08 7 md = new ikarashiMDC*[4];
THtakahiro702286 3:01a6eca21b23 8 for(int i = 0; i < 4; i++) md[i] = new ikarashiMDC(1,i,SM,serial);
THtakahiro702286 3:01a6eca21b23 9 for(int i = 0; i < 4; i++) md[i]->braking = true;
THtakahiro702286 0:0d52f303ac08 10 for(int i = 0; i < 4; i++) omni.wheel[i].setRadian(PI / 4.0 * (2.0*i+1.0));
THtakahiro702286 0:0d52f303ac08 11 }
THtakahiro702286 0:0d52f303ac08 12
THtakahiro702286 3:01a6eca21b23 13 void WheelUnit::setBrake(int trigger)
THtakahiro702286 3:01a6eca21b23 14 {
THtakahiro702286 3:01a6eca21b23 15 brake = (255 - trigger) / 255.0;
THtakahiro702286 3:01a6eca21b23 16 }
THtakahiro702286 3:01a6eca21b23 17
THtakahiro702286 0:0d52f303ac08 18 void WheelUnit::move(float x,float y,float turnPower)
THtakahiro702286 0:0d52f303ac08 19 {
THtakahiro702286 0:0d52f303ac08 20 omni.computeXY(x,y,turnPower);
THtakahiro702286 2:9017bbe177b7 21 for (int i = 0; i < 4; ++i) wheel[i] = omni.wheel[i];
THtakahiro702286 3:01a6eca21b23 22 for (int i = 0; i < 4; ++i) md[i]->setSpeed(wheel[i] * brake);
THtakahiro702286 0:0d52f303ac08 23 print = omni.wheel[0];
THtakahiro702286 3:01a6eca21b23 24 // pc.printf("%f\n\r",print);
THtakahiro702286 0:0d52f303ac08 25 }
THtakahiro702286 0:0d52f303ac08 26
THtakahiro702286 0:0d52f303ac08 27 void WheelUnit::stop()
THtakahiro702286 0:0d52f303ac08 28 {
THtakahiro702286 0:0d52f303ac08 29 for (int i = 0; i < 4; ++i) md[i]->setSpeed(0);
THtakahiro702286 0:0d52f303ac08 30 pc.printf("0\n\r");
THtakahiro702286 0:0d52f303ac08 31 }