タコ 腕
Dependencies: 2017NHKpin_config FEP ikarashiMDC
Fork of NHK2017_octopus2 by
bot/bot.cpp
- Committer:
- number_key
- Date:
- 2017-11-23
- Revision:
- 54:857390145ac4
- Parent:
- 52:320f910ca6ca
- Child:
- 55:ccf2ac8f6f32
File content as of revision 54:857390145ac4:
#include "bot.h" Bot::Bot() : pad(FEPTX, FEPRX, ADDR2), RS485(MDTX, MDRX, 115200), RS485Controller(NC), powerSwitch(MDstop), tentacle(&RS485Controller, &RS485), nishijoSword(&RS485Controller, &RS485), nishijo(&RS485Controller, &RS485), receiveSuccessed(0), debugSerial(USBTX, USBRX, 115200) { debugSerial.printf("OK\r\n"); tentacle.stop(); nishijoSword.stop(); nishijo.stop(); powerSwitch = true; } void Bot::confirmPad() { receiveSuccessed = pad.receiveState(); if(!pad.getButton2(3) && !pad.getButton2(0)) { powerSwitch = 0; } if(!receiveSuccessed) { tentacle.stop(); nishijoSword.stop(); nishijo.stop(); } } void Bot::controllMech() { if(receiveSuccessed) { //if(!pad.getButton1(2)&&!pad.getButton1(4)) powerSwitch=0; tentacle.leftMove(pad.getStick(3)); tentacle.rightMove(pad.getStick(1)); if (!pad.getButton2(0)) nishijoSword.move(-WIND_UP_SPEED); if (!pad.getButton2(1)) nishijoSword.move(WIND_UP_SPEED); if(pad.getButton2(0) && pad.getButton2(1)) nishijoSword.move(0); if (!pad.getButton2(3)) nishijo.move(-SWORD_SPEED); if (!pad.getButton2(2)) nishijo.move(SWORD_SPEED); if(pad.getButton2(2) && pad.getButton2(3)) nishijo.move(0); } else { tentacle.stop(); nishijoSword.stop(); nishijo.stop(); } } void Bot::checkConnection() { if(receiveSuccessed == 1) debugSerial.printf("ON\r\n"); else debugSerial.printf("OFF"); } void Bot::checkReceiveData() { debugSerial.printf("%f %f %f %f\r\n",pad.getStick(0),pad.getStick(1),pad.getStick(2),pad.getStick(3)); }