NHK2017 octopus robot

Dependencies:   2017NHKpin_config mbed FEP ikarashiMDC PID jy901 omni HMC6352 omni_wheel

Fork of KANI2017v2 by NagaokaRoboticsClub_mbedTeam

bot/bot.cpp

Committer:
uchitake
Date:
2017-08-30
Revision:
16:86958857c739
Parent:
15:9a2dce34b660
Child:
17:64895e83bbbc
Child:
18:6f52f4b1086a

File content as of revision 16:86958857c739:

#include "bot.h"

Bot::Bot() : MotorDriver(), PIDC(), pad(XBee1TX, XBee1RX, ADDR)
{
}

void Bot::confirmAll()
{
    pad.receiveState();
    PIDC::confirm();
    if(pad.getNorm(1) > 0.5) PIDC::setSetPoint(pad.getRadian(1) * (180.0 / M_PI));
}

void Bot::controllDrive()
{
    MotorDriver::goXY(pad.getStick(0),pad.getStick(1), PIDC::co);
}

void Bot::controllMech()
{
    if(!pad.getButton1(0)) MotorDriver::moveSlider(ARM_MAX_SPEED);
    if(!pad.getButton1(1)) MotorDriver::moveSlider(-ARM_MAX_SPEED);
    if(pad.getButton1(0) && pad.getButton1(1)) MotorDriver::moveSlider(0);

    if(!pad.getButton1(3)) MotorDriver::shakeHead(ARM_MAX_SPEED);
    if(!pad.getButton1(4)) MotorDriver::shakeHead(-ARM_MAX_SPEED);
    if(pad.getButton1(3) && pad.getButton1(4)) MotorDriver::shakeHead(0);

    if(!pad.getButton1(5)) MotorDriver::swing(ARM_MAX_SPEED);
    if(!pad.getButton1(6)) MotorDriver::swing(-ARM_MAX_SPEED);
    if(pad.getButton1(5) && pad.getButton1(6)) MotorDriver::swing(0);

    if(!pad.getButton1(2)) {
        MotorDriver::destroy(DESTROY_MAX_SPEED);
    } else {
        MotorDriver::destroy(0);
    }

    if(!pad.getButton2(0)) MotorDriver::release();
}