yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

main.cpp

Committer:
shimizuta
Date:
2018-09-05
Revision:
35:f01c5dc7592f
Parent:
34:722ab43f7cbd
Child:
36:b8171eeefcd0

File content as of revision 35:f01c5dc7592f:

#include <mbed.h>
#include "debug.h"//DEBUG("",変数);でデバッグ。
#include "state.h"
#include "go.h"
#include "servo.h"
#include "interrupt.h"
#include "workinfo.h"
#include "controller.h"
#include "calplace.h"
#include "check.h"
#include "discoveryboard.h"
//debug用に追加
#include "coordinate.h"
//#define DEBUG_MODE
const int kWait_ms = 250;
int worknum = 0;
int main()
{

    GoSetup();
    GoToFirstPosition();
    SetupPosition();
    if(PositionSetupIsInBan() == 1) return 1;//失敗したら強制終了

    //スタート指示受付
    DEBUG("stand by\r\n");
    while(CanStart() == 0) {};
    DEBUG("main start\r\n");
    InterruptSetup();
    ControllerSetup();
    while((worknum = CalPickPlace()) != 23 ) {
        Close();
        //ワークに向かう
        if(Go(work[worknum]) != 0) continue;
        //掴む
        wait_ms(kWait_ms);
        Close();
        wait_ms(kWait_ms);
        //上に持ち上げる
        Above(work[worknum].areaname);
        wait_ms(kWait_ms);
        //取り上げたことを保存
        work[worknum].is_exist = 0;
        //シュート位置計算
        int boxspace = CalPutPlace(work[worknum].color);
        //ボックスに行く(失敗(-1)したらcontinue)
        //3のときだけ特別に速度下げる
        if(worknum == 3) kServoVelocity_mm = 100;
        if(Go(shootingbox[boxspace]) != 0) continue;
        pre_skip = 0;
        do_skip = 0;
        __disable_irq();//割込み禁止
        ManualPutPlace(shootingbox[boxspace]);
        kServoVelocity_mm = 300;
        //放す
        Open();
        wait_ms(1000);
        //上に持ち上げる
        __enable_irq();//割込み許可
        pre_skip = 0;
        do_skip = 0;
        Above(BOX);
        wait_ms(kWait_ms);
        //置いたことを保存
        shootingbox[boxspace].is_exist = 1;
        shootingbox[boxspace].color = work[worknum].color;
    }
}