Octopus!!
Dependencies: 2017NHKpin_config FEP HMC6352 PID QEI R1307 ikarashiMDC omni_wheel
Fork of KANIv3 by
Diff: bot/bot.cpp
- Branch:
- develop
- Revision:
- 32:b619c7787dc3
- Parent:
- 29:41f6fc4c8962
- Child:
- 35:4608938f67c5
--- a/bot/bot.cpp Thu Oct 05 20:09:43 2017 +0900 +++ b/bot/bot.cpp Fri Oct 06 20:12:29 2017 +0900 @@ -1,7 +1,6 @@ #include "bot.h" Bot::Bot() : - PIDC(), pad(XBee2TX, XBee2RX, ADDR), RS485(MDTX, MDRX, 38400), RS485Controller(PWM1), @@ -51,11 +50,11 @@ void Bot::controllDrive() { if(receiveSuccessed) { - debugSerial.printf("%d\n\r", PIDC::getRawDegree()); + debugSerial.printf("%d\n\r", plane.getRawDegree()); led[1] = !led[1]; if(pad.getNorm(1) > 0.5) { - PIDC::PID::setSetPoint((pad.getRadian(1) - M_PI / 2) * (180.0 / M_PI)); - PIDC::confirm(); + plane.setSetPoint((pad.getRadian(1) - M_PI / 2) * (180.0 / M_PI)); + plane.confirm(); } quadOmni.moveXY( pad.getStick(0), @@ -71,30 +70,31 @@ void Bot::controllDrive2() { - PIDC::confirm(); + plane.confirm(); + axis.confirm(); float moment = 0; static float beforestick = pad.getStick(2); if(!pad.getButton2(2)) { - PIDC::resetPlaneOffset(); + axis.resetOffset(); } if((beforestick >= 0.5 && pad.getStick(2) < 0.5) || (beforestick <= -0.5 && pad.getStick(2) > -0.5)) { - PIDC::PID::setSetPoint(0.0); - PIDC::resetAxisOffset(); + plane.setSetPoint(0.0); + plane.resetOffset(); } if(pad.getStick(2) > 0.5 || pad.getStick(2) < -0.5) { moment = pad.getStick(2) / 2.0; } else { - moment = PIDC::calculationResult; + moment = plane.getCalculationResult(); } if(receiveSuccessed) { led[1] = !led[1]; quadOmni.moveCircular( pad.getNorm(0), - pad.getRadian(0) - PIDC::planeCurrentDegree / 10.0 * (M_PI / 180.0) + M_PI, + pad.getRadian(0) - axis.getCurrentDegree() / 10.0 * (M_PI / 180.0) + M_PI, 0.5, 0.5, -moment @@ -130,27 +130,27 @@ } if(mode == 1) { - PIDC::PID::setSetPoint(frontDegree); - PIDC::confirm(); + plane.setPoint(frontDegree); + plane.confirm(); quadOmni.moveXY( pad.getStick(0), -pad.getStick(1), 0.5, 0.5, - -PIDC::calculationResult + -plane.getCalculationResult() ); } if(mode == 2) { - PIDC::PID::setSetPoint(90.0 + frontDegree); - PIDC::confirm(); + plane.setPoint(90.0 + frontDegree); + plane.confirm(); quadOmni.moveXY( -pad.getStick(1), -pad.getStick(0), 0.5, 0.5, - -PIDC::calculationResult + -plane.getCalculationResult() ); } } else { @@ -190,7 +190,7 @@ ) { t.start(); t.reset(); - PIDC::calibration(HMC6352_ENTER_CALIB); + plane.calibration(HMC6352_ENTER_CALIB); while(t.read() < 5.0) { quadOmni.moveXY(0, 0, 0.4); slider.slide(0); @@ -200,6 +200,6 @@ } t.stop(); quadOmni.moveXY(0, 0, 0); - PIDC::calibration(HMC6352_EXIT_CALIB); + plane.calibration(HMC6352_EXIT_CALIB); } }