fdlsj

Dependencies:   mbed

Fork of f3rc2 by Tk A

main.cpp

Committer:
sakanakuuun
Date:
2016-08-30
Revision:
2:1a2984dfac3e
Parent:
1:a1e592eca305

File content as of revision 2:1a2984dfac3e:

//受渡前での妨害に対応したい

#include"header.h"

int team;//(-1)は青

int main(void){
    
    teamSW.mode(PullUp); 
    if(teamSW){
        team=1;
        teamledred=1;
        teamledblue=0;
    }else{
        team=-1;
        teamledred=0;
        teamledblue=1;
    }
    initmotor();
    initencorder();
    
    move(0,0);
    close_arm();
    /*以下redteamのフィールドマップを読み込む(mm)
    
    blue team の場合はすべてのy座標に(-1)をかける
    
    */
        
    //オブジェクトの位置
    //原点はスタートゾーンの中心
    int targetx[9] = { 600,600,600,1200,900,1200,900,1200,900 };
    int targety[9] = { team*300,team*600,team*900,team*1200,team*900,team*600,team*600,0,team*300 };
    
    //ハブの位置
    int hub1x = 600;
    int hub1y = 0;

    int hub2x = 900;
    int hub2y = 0;


    int goalx = 0, goaly = team*1200;//受け渡しゾーンの中心
    //定義終了
    
    int retry=0;        
    
    
    //ここでretryに数値を代入
            
    switch(retry){
        case 0:
            open_hand();
            moveto(hub1x, hub1y);
        
            moveto(targetx[0], targety[0]);
            close_hand();
            lift(1);
    
        case 1:
            open_hand();
            moveto(targetx[1], targety[1]);
            close_hand();
            lift(1);
    
        case 2:
            open_hand();
            moveto(targetx[2], targety[2]);
            close_hand();
    
            moveto(goalx,goaly);
            open_arm();
            release();
            back();
            //3つリリースした
        case 3:
            open_arm();
            open_hand();
            moveto(targetx[3], targety[3]);
            close_arm();
            close_hand();
            lift(2);
    
        case 4:
            open_hand();
            moveto(targetx[4], targety[4]);
            close_hand();
    
            moveto(goalx,goaly);
            open_arm();
            release();
            back();
            //3つリリースした
    
        case 5:
            moveto(targetx[3], targety[3]);//ハブとして利用
    
            open_arm();
            open_hand();
            moveto(targetx[5], targety[5]);
            
            close_arm();
            close_hand();
            lift(2);
    
        case 6:
            open_hand();
            moveto(targetx[6], targety[6]);
            close_hand();
    
    
            moveto(goalx,goaly);
            open_arm();
            release();
    
            back();
    
        case 7:
            moveto(targetx[3], targety[3]);//ハブとして利用
    
            open_arm();
            open_hand();
            moveto(targetx[7], targety[7]);
            close_hand();
            lift(2);
    
            moveto(hub2x, hub2y);
    
        case 8:
            open_hand();
            moveto(targetx[8], targety[8]);
            close_hand();
    
    
            moveto(goalx,goaly);
            open_arm();
    
            back();
    
            moveto(1800,team*1200);//invade
    
            return 0;//終了
    }
}