yei

Dependencies:   interface mbed enc_1multi calPID motorout KondoServoLibrary

Fork of cat18_operate by Catch the GIANT Caplico!

Committer:
shimizuta
Date:
Wed Sep 05 09:37:41 2018 +0000
Revision:
37:d4b711619962
Parent:
36:b8171eeefcd0
Child:
38:9bed85d32c97
a

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 30:af136b83b202 11 #include "discoveryboard.h"
shimizuta 10:6d1d44fa9739 12 //debug用に追加
shimizuta 10:6d1d44fa9739 13 #include "coordinate.h"
shimizuta 30:af136b83b202 14 //#define DEBUG_MODE
shimizuta 37:d4b711619962 15 const int kWait_ms = 500;
shimizuta 37:d4b711619962 16 const double kServoOffsetDegreeInBox = 10;
shimizuta 37:d4b711619962 17
shimizuta 37:d4b711619962 18
shimizuta 20:13934809e117 19 int worknum = 0;
shimizuta 0:c3a72fe24137 20 int main()
shimizuta 0:c3a72fe24137 21 {
shimizuta 30:af136b83b202 22
shimizuta 24:b4a89db4ed72 23 GoSetup();
shimizuta 29:ea48140fc85e 24 GoToFirstPosition();
shimizuta 24:b4a89db4ed72 25 SetupPosition();
shimizuta 24:b4a89db4ed72 26 if(PositionSetupIsInBan() == 1) return 1;//失敗したら強制終了
shimizuta 30:af136b83b202 27
shimizuta 4:187c62291654 28 //スタート指示受付
shimizuta 20:13934809e117 29 DEBUG("stand by\r\n");
yuto17320508 32:21229c96144a 30 while(CanStart() == 0) {};
shimizuta 20:13934809e117 31 DEBUG("main start\r\n");
shimizuta 10:6d1d44fa9739 32 InterruptSetup();
shimizuta 23:f45eb02433a5 33 ControllerSetup();
shimizuta 24:b4a89db4ed72 34 while((worknum = CalPickPlace()) != 23 ) {
shimizuta 18:05f5a3323bda 35 Close();
shimizuta 4:187c62291654 36 //ワークに向かう
shimizuta 37:d4b711619962 37 if(Go(work[worknum]) == -1) {
shimizuta 37:d4b711619962 38 work[worknum].is_exist = 0;
shimizuta 37:d4b711619962 39 continue;
shimizuta 37:d4b711619962 40 }
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 37:d4b711619962 52 OriginDegree[0] = kOriginDegree[0] - kServoOffsetDegreeInBox;
shimizuta 2:4515e8cc6b60 53 //ボックスに行く(失敗(-1)したらcontinue)
shimizuta 31:f7eb7c9fc8db 54 //3のときだけ特別に速度下げる
shimizuta 31:f7eb7c9fc8db 55 if(worknum == 3) kServoVelocity_mm = 100;
shimizuta 2:4515e8cc6b60 56 if(Go(shootingbox[boxspace]) != 0) continue;
yuto17320508 32:21229c96144a 57 ManualPutPlace(shootingbox[boxspace]);
shimizuta 31:f7eb7c9fc8db 58 kServoVelocity_mm = 300;
shimizuta 4:187c62291654 59 //放す
shimizuta 2:4515e8cc6b60 60 Open();
shimizuta 37:d4b711619962 61 wait_ms(kWait_ms);
shimizuta 37:d4b711619962 62 OriginDegree[0] = kOriginDegree[0];
shimizuta 4:187c62291654 63 //上に持ち上げる
shimizuta 18:05f5a3323bda 64 Above(BOX);
shimizuta 18:05f5a3323bda 65 wait_ms(kWait_ms);
shimizuta 4:187c62291654 66 //置いたことを保存
shimizuta 4:187c62291654 67 shootingbox[boxspace].is_exist = 1;
shimizuta 2:4515e8cc6b60 68 shootingbox[boxspace].color = work[worknum].color;
shimizuta 0:c3a72fe24137 69 }
shimizuta 24:b4a89db4ed72 70 }