yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
shimizuta
Date:
Tue Sep 04 12:53:50 2018 +0000
Revision:
29:ea48140fc85e
Parent:
28:bcfc84b481bc
Child:
30:af136b83b202
add left workarea

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 23:f45eb02433a5 10 #include "check.h"
shimizuta 10:6d1d44fa9739 11 //debug用に追加
shimizuta 10:6d1d44fa9739 12 #include "coordinate.h"
shimizuta 28:bcfc84b481bc 13 #define DEBUG_MODE
shimizuta 18:05f5a3323bda 14 const int kWait_ms = 500;
shimizuta 20:13934809e117 15 int worknum = 0;
shimizuta 0:c3a72fe24137 16 int main()
shimizuta 0:c3a72fe24137 17 {
shimizuta 24:b4a89db4ed72 18 GoSetup();
shimizuta 29:ea48140fc85e 19 GoToFirstPosition();
shimizuta 24:b4a89db4ed72 20 SetupPosition();
shimizuta 24:b4a89db4ed72 21 if(PositionSetupIsInBan() == 1) return 1;//失敗したら強制終了
shimizuta 24:b4a89db4ed72 22
shimizuta 4:187c62291654 23 //スタート指示受付
shimizuta 20:13934809e117 24 DEBUG("stand by\r\n");
shimizuta 23:f45eb02433a5 25 if(WasLoad() == 0) {
shimizuta 23:f45eb02433a5 26 wait(1);
shimizuta 23:f45eb02433a5 27 while(CanStart() == 0) {};
shimizuta 23:f45eb02433a5 28 }
shimizuta 20:13934809e117 29 DEBUG("main start\r\n");
shimizuta 10:6d1d44fa9739 30 InterruptSetup();
shimizuta 23:f45eb02433a5 31 ControllerSetup();
shimizuta 24:b4a89db4ed72 32 while((worknum = CalPickPlace()) != 23 ) {
shimizuta 18:05f5a3323bda 33 Close();
shimizuta 4:187c62291654 34 //ワークに向かう
shimizuta 2:4515e8cc6b60 35 if(Go(work[worknum]) != 0) continue;
shimizuta 28:bcfc84b481bc 36 #ifdef DEBUGMODE
shimizuta 29:ea48140fc85e 37 DEBUG("ManualModeWithPc start\r\n");
shimizuta 28:bcfc84b481bc 38 while(ManualModeWithPc() == 0){};
shimizuta 29:ea48140fc85e 39 DEBUG("ManualModeWithPc return work %d %f, %f, %f\r\n", worknum, GetNowTipLocateX(), GetNowTipLocateY(), GetNowTipLocateZ());
shimizuta 28:bcfc84b481bc 40 #endif
shimizuta 4:187c62291654 41 //掴む
yoka06 26:5e292422cc08 42 wait_ms(kWait_ms);
shimizuta 2:4515e8cc6b60 43 Close();
shimizuta 18:05f5a3323bda 44 wait_ms(kWait_ms);
shimizuta 4:187c62291654 45 //上に持ち上げる
shimizuta 18:05f5a3323bda 46 Above(work[worknum].areaname);
shimizuta 18:05f5a3323bda 47 wait_ms(kWait_ms);
shimizuta 4:187c62291654 48 //取り上げたことを保存
shimizuta 2:4515e8cc6b60 49 work[worknum].is_exist = 0;
shimizuta 4:187c62291654 50 //シュート位置計算
shimizuta 4:187c62291654 51 int boxspace = CalPutPlace(work[worknum].color);
shimizuta 2:4515e8cc6b60 52 //ボックスに行く(失敗(-1)したらcontinue)
shimizuta 2:4515e8cc6b60 53 if(Go(shootingbox[boxspace]) != 0) continue;
shimizuta 4:187c62291654 54 //放す
shimizuta 2:4515e8cc6b60 55 Open();
shimizuta 18:05f5a3323bda 56 wait_ms(kWait_ms);
shimizuta 4:187c62291654 57 //上に持ち上げる
shimizuta 18:05f5a3323bda 58 Above(BOX);
shimizuta 18:05f5a3323bda 59 wait_ms(kWait_ms);
shimizuta 4:187c62291654 60 //置いたことを保存
shimizuta 4:187c62291654 61 shootingbox[boxspace].is_exist = 1;
shimizuta 2:4515e8cc6b60 62 shootingbox[boxspace].color = work[worknum].color;
shimizuta 0:c3a72fe24137 63 }
shimizuta 24:b4a89db4ed72 64 }