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:
number_key
Date:
2017-08-30
Revision:
17:64895e83bbbc
Parent:
16:86958857c739

File content as of revision 17:64895e83bbbc:

#include "bot.h"

Bot::Bot() : MotorDriver(), PIDC(), pad1(XBee1TX, XBee1RX, ADDR1), pad2(XBee2TX, XBee2RX, ADDR2)
{
}

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

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

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

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

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

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

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