yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
kageyuta
Date:
Sat Aug 11 06:09:04 2018 +0000
Revision:
9:a553ace4d9d1
Parent:
8:cabc50cf3e1e
kage;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimizuta 0:c3a72fe24137 1 #include <mbed.h>
shimizuta 0:c3a72fe24137 2 #include "debug.h"//DEBUG("",変数);でデバッグ。
shimizuta 1:cc056c41ae30 3 #include "state.h"
shimizuta 1:cc056c41ae30 4 #include "go.h"
shimizuta 3:05b1dcb3634e 5 #include "servo.h"
shimizuta 2:4515e8cc6b60 6 #include "interrupt.h"
shimizuta 2:4515e8cc6b60 7 #include "position.h"
shimizuta 3:05b1dcb3634e 8 #include "controller.h"
shimizuta 8:cabc50cf3e1e 9 #include "interface.h"
kageyuta 9:a553ace4d9d1 10 #include "coordinate.h"
shimizuta 1:cc056c41ae30 11 ///setup関連を集めた
shimizuta 0:c3a72fe24137 12 void Setups();
shimizuta 0:c3a72fe24137 13 void Tests();
shimizuta 8:cabc50cf3e1e 14 Interface interface(USBTX, USBRX);
shimizuta 0:c3a72fe24137 15 int main()
shimizuta 0:c3a72fe24137 16 {
kageyuta 9:a553ace4d9d1 17
kageyuta 9:a553ace4d9d1 18
shimizuta 0:c3a72fe24137 19 DEBUG("setup start\r\n");
shimizuta 0:c3a72fe24137 20 Setups();
shimizuta 4:187c62291654 21 //スタート指示受付
shimizuta 3:05b1dcb3634e 22 while(CanStart() == 0){};
shimizuta 0:c3a72fe24137 23 DEBUG("main start");
kageyuta 9:a553ace4d9d1 24 for(int i=0;i<23;i++){
kageyuta 9:a553ace4d9d1 25 DEBUG("work %d : %d\r\n",i,work[i].is_exist);
kageyuta 9:a553ace4d9d1 26 }
shimizuta 4:187c62291654 27 int worknum = 0;
shimizuta 4:187c62291654 28 while( (worknum = CalPickPlace()) != 23 ) {
shimizuta 4:187c62291654 29 //ワークに向かう
shimizuta 2:4515e8cc6b60 30 if(Go(work[worknum]) != 0) continue;
shimizuta 4:187c62291654 31 //掴む
shimizuta 2:4515e8cc6b60 32 Close();
shimizuta 4:187c62291654 33 //上に持ち上げる
shimizuta 2:4515e8cc6b60 34 Above();
shimizuta 4:187c62291654 35 //取り上げたことを保存
shimizuta 2:4515e8cc6b60 36 work[worknum].is_exist = 0;
shimizuta 4:187c62291654 37 //シュート位置計算
shimizuta 4:187c62291654 38 int boxspace = CalPutPlace(work[worknum].color);
shimizuta 2:4515e8cc6b60 39 //ボックスに行く(失敗(-1)したらcontinue)
shimizuta 2:4515e8cc6b60 40 if(Go(shootingbox[boxspace]) != 0) continue;
shimizuta 4:187c62291654 41 //放す
shimizuta 2:4515e8cc6b60 42 Open();
shimizuta 4:187c62291654 43 //上に持ち上げる
shimizuta 2:4515e8cc6b60 44 Above();
shimizuta 4:187c62291654 45 //置いたことを保存
shimizuta 4:187c62291654 46 shootingbox[boxspace].is_exist = 1;
shimizuta 2:4515e8cc6b60 47 shootingbox[boxspace].color = work[worknum].color;
shimizuta 0:c3a72fe24137 48 }
shimizuta 0:c3a72fe24137 49 }
shimizuta 0:c3a72fe24137 50 void Setups()
shimizuta 0:c3a72fe24137 51 {
shimizuta 1:cc056c41ae30 52 GoSetup();
shimizuta 2:4515e8cc6b60 53 SetupPosition();
kageyuta 9:a553ace4d9d1 54 //InterruptSetup();
shimizuta 0:c3a72fe24137 55 }
shimizuta 0:c3a72fe24137 56 void Tests()
shimizuta 0:c3a72fe24137 57 {
shimizuta 0:c3a72fe24137 58 static int count = 0;
shimizuta 0:c3a72fe24137 59 count ++;
shimizuta 0:c3a72fe24137 60 if (count > 100000) {
shimizuta 0:c3a72fe24137 61 count =0;
shimizuta 0:c3a72fe24137 62 }
shimizuta 0:c3a72fe24137 63 }
shimizuta 1:cc056c41ae30 64