手動b足回り
wheelUnit.cpp@0:0d52f303ac08, 2019-07-08 (annotated)
- Committer:
- THtakahiro702286
- Date:
- Mon Jul 08 08:45:38 2019 +0000
- Revision:
- 0:0d52f303ac08
- Child:
- 1:3c9eaf598f21
syudou b wheel control
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:0d52f303ac08 | 8 | for(int i = 0; i < 4; ++i) md[i] = new ikarashiMDC(2,i,SM,serial); |
THtakahiro702286 | 0:0d52f303ac08 | 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 | 0:0d52f303ac08 | 13 | void WheelUnit::move(float x,float y,float turnPower) |
THtakahiro702286 | 0:0d52f303ac08 | 14 | { |
THtakahiro702286 | 0:0d52f303ac08 | 15 | omni.computeXY(x,y,turnPower); |
THtakahiro702286 | 0:0d52f303ac08 | 16 | for (int i = 0; i < 4; ++i) md[i]->setSpeed(omni.wheel[i]); |
THtakahiro702286 | 0:0d52f303ac08 | 17 | print = omni.wheel[0]; |
THtakahiro702286 | 0:0d52f303ac08 | 18 | pc.printf("%f\n\r",print); |
THtakahiro702286 | 0:0d52f303ac08 | 19 | } |
THtakahiro702286 | 0:0d52f303ac08 | 20 | |
THtakahiro702286 | 0:0d52f303ac08 | 21 | void WheelUnit::stop() |
THtakahiro702286 | 0:0d52f303ac08 | 22 | { |
THtakahiro702286 | 0:0d52f303ac08 | 23 | for (int i = 0; i < 4; ++i) md[i]->setSpeed(0); |
THtakahiro702286 | 0:0d52f303ac08 | 24 | pc.printf("0\n\r"); |
THtakahiro702286 | 0:0d52f303ac08 | 25 | } |