yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
shimizuta
Date:
Mon Aug 27 03:47:21 2018 +0000
Revision:
20:13934809e117
Parent:
19:48c3af917932
Child:
23:f45eb02433a5
There are a lot of change

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 20:13934809e117 7 #include "workinfo.h"
shimizuta 3:05b1dcb3634e 8 #include "controller.h"
shimizuta 20:13934809e117 9 #include "calplace.h"
shimizuta 10:6d1d44fa9739 10 //debug用に追加
shimizuta 20:13934809e117 11 //#include "interface.h"
shimizuta 10:6d1d44fa9739 12 #include "coordinate.h"
shimizuta 20:13934809e117 13 //#define FORDEBUG
shimizuta 18:05f5a3323bda 14 const int kWait_ms = 500;
shimizuta 20:13934809e117 15 int worknum = 0;
shimizuta 1:cc056c41ae30 16 ///setup関連を集めた
shimizuta 0:c3a72fe24137 17 void Setups();
shimizuta 0:c3a72fe24137 18 void Tests();
shimizuta 20:13934809e117 19 //Interface interface(USBTX, USBRX);
shimizuta 0:c3a72fe24137 20 int main()
shimizuta 0:c3a72fe24137 21 {
shimizuta 0:c3a72fe24137 22 Setups();
shimizuta 4:187c62291654 23 //スタート指示受付
shimizuta 20:13934809e117 24 DEBUG("stand by\r\n");
shimizuta 10:6d1d44fa9739 25 while(CanStart() == 0) {};
shimizuta 20:13934809e117 26 DEBUG("main start\r\n");
shimizuta 10:6d1d44fa9739 27 InterruptSetup();
shimizuta 18:05f5a3323bda 28 #ifdef FORDEBUG
shimizuta 18:05f5a3323bda 29 for(int i = kCommonStart; i < kCommonStart + kCommonAreaNum - 2; i++) work[i].is_exist = 0;
shimizuta 18:05f5a3323bda 30 #endif
shimizuta 4:187c62291654 31 while( (worknum = CalPickPlace()) != 23 ) {
shimizuta 18:05f5a3323bda 32 Close();
shimizuta 4:187c62291654 33 //ワークに向かう
shimizuta 2:4515e8cc6b60 34 if(Go(work[worknum]) != 0) continue;
shimizuta 4:187c62291654 35 //掴む
shimizuta 2:4515e8cc6b60 36 Close();
shimizuta 18:05f5a3323bda 37 wait_ms(kWait_ms);
shimizuta 4:187c62291654 38 //上に持ち上げる
shimizuta 18:05f5a3323bda 39 Above(work[worknum].areaname);
shimizuta 18:05f5a3323bda 40 wait_ms(kWait_ms);
shimizuta 4:187c62291654 41 //取り上げたことを保存
shimizuta 2:4515e8cc6b60 42 work[worknum].is_exist = 0;
shimizuta 4:187c62291654 43 //シュート位置計算
shimizuta 4:187c62291654 44 int boxspace = CalPutPlace(work[worknum].color);
shimizuta 2:4515e8cc6b60 45 //ボックスに行く(失敗(-1)したらcontinue)
shimizuta 2:4515e8cc6b60 46 if(Go(shootingbox[boxspace]) != 0) continue;
shimizuta 4:187c62291654 47 //放す
shimizuta 2:4515e8cc6b60 48 Open();
shimizuta 18:05f5a3323bda 49 wait_ms(kWait_ms);
shimizuta 4:187c62291654 50 //上に持ち上げる
shimizuta 18:05f5a3323bda 51 Above(BOX);
shimizuta 18:05f5a3323bda 52 wait_ms(kWait_ms);
shimizuta 4:187c62291654 53 //置いたことを保存
shimizuta 4:187c62291654 54 shootingbox[boxspace].is_exist = 1;
shimizuta 2:4515e8cc6b60 55 shootingbox[boxspace].color = work[worknum].color;
shimizuta 0:c3a72fe24137 56 }
shimizuta 0:c3a72fe24137 57 }
shimizuta 0:c3a72fe24137 58 void Setups()
shimizuta 0:c3a72fe24137 59 {
shimizuta 1:cc056c41ae30 60 GoSetup();
shimizuta 2:4515e8cc6b60 61 SetupPosition();
shimizuta 18:05f5a3323bda 62 StartCheck();
shimizuta 0:c3a72fe24137 63 }
shimizuta 0:c3a72fe24137 64 void Tests()
shimizuta 0:c3a72fe24137 65 {
shimizuta 0:c3a72fe24137 66 static int count = 0;
shimizuta 0:c3a72fe24137 67 count ++;
shimizuta 0:c3a72fe24137 68 if (count > 100000) {
shimizuta 0:c3a72fe24137 69 count =0;
shimizuta 0:c3a72fe24137 70 }
shimizuta 20:13934809e117 71 }