yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
main.cpp@2:4515e8cc6b60, 2018-08-05 (annotated)
- Committer:
- shimizuta
- Date:
- Sun Aug 05 03:32:55 2018 +0000
- Revision:
- 2:4515e8cc6b60
- Parent:
- 1:cc056c41ae30
- Child:
- 3:05b1dcb3634e
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 | 1:cc056c41ae30 | 5 | #include "hand.h" |
shimizuta | 1:cc056c41ae30 | 6 | #include "calplace.h" |
shimizuta | 2:4515e8cc6b60 | 7 | #include "interrupt.h" |
shimizuta | 2:4515e8cc6b60 | 8 | #include "position.h" |
shimizuta | 1:cc056c41ae30 | 9 | ///setup関連を集めた |
shimizuta | 0:c3a72fe24137 | 10 | void Setups(); |
shimizuta | 0:c3a72fe24137 | 11 | void Tests(); |
shimizuta | 1:cc056c41ae30 | 12 | //const int kWorkNum = 12;//ワークの数 |
shimizuta | 1:cc056c41ae30 | 13 | |
shimizuta | 0:c3a72fe24137 | 14 | int main() |
shimizuta | 0:c3a72fe24137 | 15 | { |
shimizuta | 0:c3a72fe24137 | 16 | DEBUG("setup start\r\n"); |
shimizuta | 0:c3a72fe24137 | 17 | Setups(); |
shimizuta | 0:c3a72fe24137 | 18 | DEBUG("main start"); |
shimizuta | 0:c3a72fe24137 | 19 | while(1) { |
shimizuta | 1:cc056c41ae30 | 20 | int worknum = CalPickPlace();//目標ワーク計算 |
shimizuta | 2:4515e8cc6b60 | 21 | //ワークのところまで行く。腕も準備 |
shimizuta | 2:4515e8cc6b60 | 22 | if(Go(work[worknum]) != 0) continue; |
shimizuta | 2:4515e8cc6b60 | 23 | Close(); |
shimizuta | 2:4515e8cc6b60 | 24 | Above(); |
shimizuta | 2:4515e8cc6b60 | 25 | work[worknum].is_exist = 0; |
shimizuta | 2:4515e8cc6b60 | 26 | int boxspace = CalPutPlace(work[worknum].color);//シュート位置計算 |
shimizuta | 2:4515e8cc6b60 | 27 | //ボックスに行く(失敗(-1)したらcontinue) |
shimizuta | 2:4515e8cc6b60 | 28 | if(Go(shootingbox[boxspace]) != 0) continue; |
shimizuta | 2:4515e8cc6b60 | 29 | Open(); |
shimizuta | 2:4515e8cc6b60 | 30 | Above(); |
shimizuta | 2:4515e8cc6b60 | 31 | shootingbox[boxspace].is_exist = 1;//置いたことを保存 |
shimizuta | 2:4515e8cc6b60 | 32 | shootingbox[boxspace].color = work[worknum].color; |
shimizuta | 0:c3a72fe24137 | 33 | } |
shimizuta | 0:c3a72fe24137 | 34 | } |
shimizuta | 0:c3a72fe24137 | 35 | void Setups() |
shimizuta | 0:c3a72fe24137 | 36 | { |
shimizuta | 1:cc056c41ae30 | 37 | GoSetup(); |
shimizuta | 2:4515e8cc6b60 | 38 | SetupPosition(); |
shimizuta | 2:4515e8cc6b60 | 39 | InterruptSetup(); |
shimizuta | 0:c3a72fe24137 | 40 | } |
shimizuta | 0:c3a72fe24137 | 41 | void Tests() |
shimizuta | 0:c3a72fe24137 | 42 | { |
shimizuta | 0:c3a72fe24137 | 43 | static int count = 0; |
shimizuta | 0:c3a72fe24137 | 44 | count ++; |
shimizuta | 0:c3a72fe24137 | 45 | if (count > 100000) { |
shimizuta | 0:c3a72fe24137 | 46 | count =0; |
shimizuta | 0:c3a72fe24137 | 47 | } |
shimizuta | 0:c3a72fe24137 | 48 | } |
shimizuta | 1:cc056c41ae30 | 49 |