NHK2017Ateamかにろぼ
Dependencies: 2017NHKpin_config mbed FEP HMC6352 MotorDriverController PID QEI omni
\ ̄\ / ̄/ /l \ \ / / lヽ | ヽ ヽ | | / / | \ ` ‐ヽ ヽ ● ● / / ‐ / \ __ l | ||___|| / l __ / \ \ / \/ /\| 人__人 |/\ //\| |/\\ //\| |/\\ / . \_____/ \ ┏┓ ┏━┓┏┓ ┏┓ ┏┓┏┓ ┏┓ ┏┓┗┛ ┏┓ ┗┓┃┗┛ ┏┛┗━┓ ┃┃┃┃ ┃┃┏━┛┗┓┏┓┏┛┗━┓┃┃┏┓┏┓┏━━━┓ ┗┓┏━┛ ┃┃┗┛ ┃┃┗━┓┏┛┗┛┗┓┏┓┃┗┛┗┛┃┃┗━━━┛ ┏┛┃┏━┓┃┗━━┓┃┃┏━┛┗┓ ┏┛┃┃┃ ┃┃ ┃┏┛┗━┛┗━━┓┃┃┃┃┏┓┏┛ ┗━┛┃┃ ┃┃┏┓ ┃┃┏━━┓┏━━┛┃┃┃┃┗┛┃ ┏┛┃ ┃┃┃┗━━┓ ┗┛┗━━┛┗━━━┛┗┛┗━━┛ ┗━┛ ┗┛┗━━━┛
bot/bot.cpp@23:98746361f827, 2017-09-05 (annotated)
- Committer:
- uchitake
- Date:
- Tue Sep 05 12:02:47 2017 +0900
- Revision:
- 23:98746361f827
- Parent:
- 19:3a62cbc6fee9
remove WheelUnit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
UCHITAKE | 0:757e9800c103 | 1 | #include "bot.h" |
UCHITAKE | 0:757e9800c103 | 2 | |
uchitake |
17:6f52f4b1086a | 3 | Bot::Bot() : |
UCHITAKE | 19:3a62cbc6fee9 | 4 | PIDC(), pad(XBee1TX, XBee1RX, ADDR), motor(MDSDA, MDSCL, solenoidPin) |
UCHITAKE | 0:757e9800c103 | 5 | { |
UCHITAKE | 19:3a62cbc6fee9 | 6 | motor.goXY(0, 0, 0); |
UCHITAKE | 19:3a62cbc6fee9 | 7 | motor.moveSlider(0); |
UCHITAKE | 19:3a62cbc6fee9 | 8 | motor.destroy(0); |
UCHITAKE | 19:3a62cbc6fee9 | 9 | motor.swing(0); |
UCHITAKE | 19:3a62cbc6fee9 | 10 | motor.shakeHead(0); |
UCHITAKE | 1:269914e0aa07 | 11 | } |
UCHITAKE | 1:269914e0aa07 | 12 | |
UCHITAKE | 1:269914e0aa07 | 13 | void Bot::confirmAll() |
UCHITAKE | 1:269914e0aa07 | 14 | { |
UCHITAKE | 19:3a62cbc6fee9 | 15 | suc = pad.receiveState(); |
uchitake |
15:9a2dce34b660 | 16 | PIDC::confirm(); |
UCHITAKE | 19:3a62cbc6fee9 | 17 | if(pad.getNorm(1) > 0.5) PIDC::setSetPoint(pad.getRadian(1) * (180.0 / M_PI) - M_PI / 2.0); |
UCHITAKE | 19:3a62cbc6fee9 | 18 | if(!suc) { |
UCHITAKE | 19:3a62cbc6fee9 | 19 | motor.goXY(0, 0, 0); |
UCHITAKE | 19:3a62cbc6fee9 | 20 | motor.moveSlider(0); |
UCHITAKE | 19:3a62cbc6fee9 | 21 | motor.destroy(0); |
UCHITAKE | 19:3a62cbc6fee9 | 22 | motor.swing(0); |
UCHITAKE | 19:3a62cbc6fee9 | 23 | motor.shakeHead(0); |
UCHITAKE | 19:3a62cbc6fee9 | 24 | } |
UCHITAKE | 1:269914e0aa07 | 25 | } |
UCHITAKE | 1:269914e0aa07 | 26 | |
UCHITAKE | 1:269914e0aa07 | 27 | void Bot::controllDrive() |
UCHITAKE | 1:269914e0aa07 | 28 | { |
UCHITAKE | 19:3a62cbc6fee9 | 29 | if(suc) motor.goXY(pad.getStick(0) / 2.0,-pad.getStick(1) / 2.0, PIDC::co); |
UCHITAKE | 1:269914e0aa07 | 30 | } |
UCHITAKE | 1:269914e0aa07 | 31 | |
UCHITAKE | 1:269914e0aa07 | 32 | void Bot::controllMech() |
UCHITAKE | 1:269914e0aa07 | 33 | { |
UCHITAKE | 19:3a62cbc6fee9 | 34 | if(suc) { |
UCHITAKE | 19:3a62cbc6fee9 | 35 | // if(!pad.getButton1(0)) motor.moveSlider(ARM_MAX_SPEED); |
UCHITAKE | 19:3a62cbc6fee9 | 36 | // if(!pad.getButton1(1)) motor.moveSlider(-ARM_MAX_SPEED); |
UCHITAKE | 19:3a62cbc6fee9 | 37 | // if(pad.getButton1(0) && pad.getButton1(1)) motor.moveSlider(0); |
UCHITAKE | 19:3a62cbc6fee9 | 38 | // |
UCHITAKE | 19:3a62cbc6fee9 | 39 | // if(!pad.getButton1(3)) motor.shakeHead(ARM_MAX_SPEED); |
UCHITAKE | 19:3a62cbc6fee9 | 40 | // if(!pad.getButton1(4)) motor.shakeHead(-ARM_MAX_SPEED); |
UCHITAKE | 19:3a62cbc6fee9 | 41 | // if(pad.getButton1(3) && pad.getButton1(4)) motor.shakeHead(0); |
UCHITAKE | 19:3a62cbc6fee9 | 42 | // |
UCHITAKE | 19:3a62cbc6fee9 | 43 | if(!pad.getButton1(5)) motor.swing(0.2); |
UCHITAKE | 19:3a62cbc6fee9 | 44 | if(!pad.getButton1(6)) motor.swing(-0.2); |
UCHITAKE | 19:3a62cbc6fee9 | 45 | if(pad.getButton1(5) && pad.getButton1(6)) motor.swing(0); |
UCHITAKE | 1:269914e0aa07 | 46 | |
UCHITAKE | 19:3a62cbc6fee9 | 47 | // |
UCHITAKE | 19:3a62cbc6fee9 | 48 | // if(!pad.getButton1(2)) { |
UCHITAKE | 19:3a62cbc6fee9 | 49 | // motor.destroy(DESTROY_MAX_SPEED); |
UCHITAKE | 19:3a62cbc6fee9 | 50 | // } else { |
UCHITAKE | 19:3a62cbc6fee9 | 51 | // motor.destroy(0); |
UCHITAKE | 19:3a62cbc6fee9 | 52 | // } |
UCHITAKE | 19:3a62cbc6fee9 | 53 | // |
UCHITAKE | 19:3a62cbc6fee9 | 54 | // if(!pad.getButton2(0)) motor.release(); |
UCHITAKE | 19:3a62cbc6fee9 | 55 | } |
UCHITAKE | 19:3a62cbc6fee9 | 56 | } |
uchitake |
15:9a2dce34b660 | 57 | |
UCHITAKE | 19:3a62cbc6fee9 | 58 | |
UCHITAKE | 19:3a62cbc6fee9 | 59 | void Bot::calibrate() |
UCHITAKE | 19:3a62cbc6fee9 | 60 | { |
UCHITAKE | 19:3a62cbc6fee9 | 61 | if(suc && !pad.getButton2(0) && !pad.getButton2(1) && !pad.getButton2(2) && !pad.getButton2(3)) { |
UCHITAKE | 19:3a62cbc6fee9 | 62 | PIDC::calibration(HMC6352_ENTER_CALIB); |
UCHITAKE | 19:3a62cbc6fee9 | 63 | motor.goXY(0, 0, 0.3); |
UCHITAKE | 19:3a62cbc6fee9 | 64 | wait(2.0); |
UCHITAKE | 19:3a62cbc6fee9 | 65 | motor.goXY(0, 0, 0); |
UCHITAKE | 19:3a62cbc6fee9 | 66 | PIDC::calibration(HMC6352_EXIT_CALIB); |
UCHITAKE | 1:269914e0aa07 | 67 | } |
UCHITAKE | 19:3a62cbc6fee9 | 68 | } |