yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
main.cpp@36:b8171eeefcd0, 2018-09-05 (annotated)
- Committer:
- shimizuta
- Date:
- Wed Sep 05 03:58:53 2018 +0000
- Revision:
- 36:b8171eeefcd0
- Parent:
- 35:f01c5dc7592f
- Child:
- 37:d4b711619962
a
Who changed what in which revision?
User | Revision | Line number | New 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 | 30:af136b83b202 | 15 | const int kWait_ms = 250; |
shimizuta | 20:13934809e117 | 16 | int worknum = 0; |
shimizuta | 0:c3a72fe24137 | 17 | int main() |
shimizuta | 0:c3a72fe24137 | 18 | { |
shimizuta | 30:af136b83b202 | 19 | |
shimizuta | 24:b4a89db4ed72 | 20 | GoSetup(); |
shimizuta | 29:ea48140fc85e | 21 | GoToFirstPosition(); |
shimizuta | 24:b4a89db4ed72 | 22 | SetupPosition(); |
shimizuta | 24:b4a89db4ed72 | 23 | if(PositionSetupIsInBan() == 1) return 1;//失敗したら強制終了 |
shimizuta | 30:af136b83b202 | 24 | |
shimizuta | 4:187c62291654 | 25 | //スタート指示受付 |
shimizuta | 20:13934809e117 | 26 | DEBUG("stand by\r\n"); |
yuto17320508 | 32:21229c96144a | 27 | while(CanStart() == 0) {}; |
shimizuta | 20:13934809e117 | 28 | DEBUG("main start\r\n"); |
shimizuta | 10:6d1d44fa9739 | 29 | InterruptSetup(); |
shimizuta | 23:f45eb02433a5 | 30 | ControllerSetup(); |
shimizuta | 24:b4a89db4ed72 | 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 | //掴む |
yoka06 | 26:5e292422cc08 | 36 | wait_ms(kWait_ms); |
shimizuta | 2:4515e8cc6b60 | 37 | Close(); |
shimizuta | 18:05f5a3323bda | 38 | wait_ms(kWait_ms); |
shimizuta | 4:187c62291654 | 39 | //上に持ち上げる |
shimizuta | 18:05f5a3323bda | 40 | Above(work[worknum].areaname); |
shimizuta | 18:05f5a3323bda | 41 | wait_ms(kWait_ms); |
shimizuta | 4:187c62291654 | 42 | //取り上げたことを保存 |
shimizuta | 2:4515e8cc6b60 | 43 | work[worknum].is_exist = 0; |
shimizuta | 4:187c62291654 | 44 | //シュート位置計算 |
shimizuta | 4:187c62291654 | 45 | int boxspace = CalPutPlace(work[worknum].color); |
shimizuta | 2:4515e8cc6b60 | 46 | //ボックスに行く(失敗(-1)したらcontinue) |
shimizuta | 31:f7eb7c9fc8db | 47 | //3のときだけ特別に速度下げる |
shimizuta | 31:f7eb7c9fc8db | 48 | if(worknum == 3) kServoVelocity_mm = 100; |
shimizuta | 2:4515e8cc6b60 | 49 | if(Go(shootingbox[boxspace]) != 0) continue; |
shimizuta | 34:722ab43f7cbd | 50 | __disable_irq();//割込み禁止 |
yuto17320508 | 32:21229c96144a | 51 | ManualPutPlace(shootingbox[boxspace]); |
shimizuta | 31:f7eb7c9fc8db | 52 | kServoVelocity_mm = 300; |
shimizuta | 4:187c62291654 | 53 | //放す |
shimizuta | 2:4515e8cc6b60 | 54 | Open(); |
shimizuta | 34:722ab43f7cbd | 55 | wait_ms(1000); |
shimizuta | 4:187c62291654 | 56 | //上に持ち上げる |
shimizuta | 36:b8171eeefcd0 | 57 | pre_skip = -1; |
shimizuta | 36:b8171eeefcd0 | 58 | do_skip = 0; |
shimizuta | 34:722ab43f7cbd | 59 | __enable_irq();//割込み許可 |
shimizuta | 36:b8171eeefcd0 | 60 | |
shimizuta | 18:05f5a3323bda | 61 | Above(BOX); |
shimizuta | 18:05f5a3323bda | 62 | wait_ms(kWait_ms); |
shimizuta | 4:187c62291654 | 63 | //置いたことを保存 |
shimizuta | 4:187c62291654 | 64 | shootingbox[boxspace].is_exist = 1; |
shimizuta | 2:4515e8cc6b60 | 65 | shootingbox[boxspace].color = work[worknum].color; |
shimizuta | 0:c3a72fe24137 | 66 | } |
shimizuta | 24:b4a89db4ed72 | 67 | } |