main

Dependents:   00_yotsuba 200_yotsuba_21 200_yotuba_21_uiChange

robot.cpp

Committer:
piroro4560
Date:
2020-01-30
Revision:
3:8e7c24edbaea
Parent:
2:fc5545ddf69a
Child:
4:a4f94f186ba0

File content as of revision 3:8e7c24edbaea:

#include "robot.h"

robot::robot()
    : spin(P, I, D, interval),
      pc(USBTX, USBRX, 115200),
      shot(kicker),
      
{
    omni.wheel[0].setRadian(PI/4 * 1);
    omni.wheel[1].setRadian(PI/4 * 3);
    omni.wheel[2].setRadian(PI/4 * 5);
    omni.wheel[3].setRadian(PI/4 * 7);
    motor[0] = new kohiMD(PA_6);
    motor[1] = new kohiMD(PA_7);
    motor[2] = new kohiMD(PA_9);
    motor[3] = new kohiMD(PB_10);
    spin.setInputLimits(-180, 180);
    spin.setOutputLimits(-0.3,0.3);
    spin.setBias(0);
    spin.setMode(1);
    spin.setSetPoint(0);
    shot.setkickperiod(0.5);
    shot.setoutputtime(0.01);
    ui.beep(1000, 1.0);
}

void robot::chaseBall(float ball_theta, float ball_dis, float r)
{
    theta = ball_theta + ballExtra * ((r > 0) - (r <= 0));
    spin.setProcessValue(r);
    omni.computeCircular( ,spin.compute());
}

void robot::lostBall()
{
    
}

void robot::moveGoal(float r, float goal_size, float goal_)
{
    
}

void robot::detour()
{
    
}

void robot::outLine()
/* ゴールから見て 
 * 右のライン -> 90°
 * 左のライン -> -90°
 * 上のライン -> 180°
 * 下のライン -> 0°
 */
{
    while(/*線を踏んだか見る奴*/){
        omni.compute
    }
}



void robot::shotBall()
{
    shot.outPut;
}

void test()
{
    
    while(1) {
        for (int i=0; i<4; i++) {
            motor[i]->setSpeed(0.2);
            wait(1.5);
        }
        wait(1.5);
        for (int i=0; i<4; i++) {
            motor[i]->setSpeed(-0.2);
            wait(1.5);
        }
        
    }
}