yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
main.cpp@10:6d1d44fa9739, 2018-08-11 (annotated)
- Committer:
- shimizuta
- Date:
- Sat Aug 11 07:21:59 2018 +0000
- Revision:
- 10:6d1d44fa9739
- Parent:
- 8:cabc50cf3e1e
- Child:
- 13:126c3f7f9b89
add exact kArmLength
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 | 2:4515e8cc6b60 | 7 | #include "position.h" |
shimizuta | 3:05b1dcb3634e | 8 | #include "controller.h" |
shimizuta | 10:6d1d44fa9739 | 9 | //debug用に追加 |
shimizuta | 8:cabc50cf3e1e | 10 | #include "interface.h" |
shimizuta | 10:6d1d44fa9739 | 11 | #include "coordinate.h" |
shimizuta | 1:cc056c41ae30 | 12 | ///setup関連を集めた |
shimizuta | 0:c3a72fe24137 | 13 | void Setups(); |
shimizuta | 0:c3a72fe24137 | 14 | void Tests(); |
shimizuta | 8:cabc50cf3e1e | 15 | Interface interface(USBTX, USBRX); |
shimizuta | 0:c3a72fe24137 | 16 | int main() |
shimizuta | 0:c3a72fe24137 | 17 | { |
shimizuta | 0:c3a72fe24137 | 18 | DEBUG("setup start\r\n"); |
shimizuta | 0:c3a72fe24137 | 19 | Setups(); |
shimizuta | 4:187c62291654 | 20 | //スタート指示受付 |
shimizuta | 10:6d1d44fa9739 | 21 | while(CanStart() == 0) {}; |
shimizuta | 0:c3a72fe24137 | 22 | DEBUG("main start"); |
shimizuta | 10:6d1d44fa9739 | 23 | InterruptSetup(); |
shimizuta | 4:187c62291654 | 24 | int worknum = 0; |
shimizuta | 4:187c62291654 | 25 | while( (worknum = CalPickPlace()) != 23 ) { |
shimizuta | 4:187c62291654 | 26 | //ワークに向かう |
shimizuta | 2:4515e8cc6b60 | 27 | if(Go(work[worknum]) != 0) continue; |
shimizuta | 4:187c62291654 | 28 | //掴む |
shimizuta | 2:4515e8cc6b60 | 29 | Close(); |
shimizuta | 4:187c62291654 | 30 | //上に持ち上げる |
shimizuta | 2:4515e8cc6b60 | 31 | Above(); |
shimizuta | 4:187c62291654 | 32 | //取り上げたことを保存 |
shimizuta | 2:4515e8cc6b60 | 33 | work[worknum].is_exist = 0; |
shimizuta | 4:187c62291654 | 34 | //シュート位置計算 |
shimizuta | 4:187c62291654 | 35 | int boxspace = CalPutPlace(work[worknum].color); |
shimizuta | 2:4515e8cc6b60 | 36 | //ボックスに行く(失敗(-1)したらcontinue) |
shimizuta | 2:4515e8cc6b60 | 37 | if(Go(shootingbox[boxspace]) != 0) continue; |
shimizuta | 4:187c62291654 | 38 | //放す |
shimizuta | 2:4515e8cc6b60 | 39 | Open(); |
shimizuta | 4:187c62291654 | 40 | //上に持ち上げる |
shimizuta | 2:4515e8cc6b60 | 41 | Above(); |
shimizuta | 4:187c62291654 | 42 | //置いたことを保存 |
shimizuta | 4:187c62291654 | 43 | shootingbox[boxspace].is_exist = 1; |
shimizuta | 2:4515e8cc6b60 | 44 | shootingbox[boxspace].color = work[worknum].color; |
shimizuta | 0:c3a72fe24137 | 45 | } |
shimizuta | 0:c3a72fe24137 | 46 | } |
shimizuta | 0:c3a72fe24137 | 47 | void Setups() |
shimizuta | 0:c3a72fe24137 | 48 | { |
shimizuta | 1:cc056c41ae30 | 49 | GoSetup(); |
shimizuta | 2:4515e8cc6b60 | 50 | SetupPosition(); |
shimizuta | 10:6d1d44fa9739 | 51 | |
shimizuta | 0:c3a72fe24137 | 52 | } |
shimizuta | 0:c3a72fe24137 | 53 | void Tests() |
shimizuta | 0:c3a72fe24137 | 54 | { |
shimizuta | 0:c3a72fe24137 | 55 | static int count = 0; |
shimizuta | 0:c3a72fe24137 | 56 | count ++; |
shimizuta | 0:c3a72fe24137 | 57 | if (count > 100000) { |
shimizuta | 0:c3a72fe24137 | 58 | count =0; |
shimizuta | 0:c3a72fe24137 | 59 | } |
shimizuta | 0:c3a72fe24137 | 60 | } |
shimizuta | 1:cc056c41ae30 | 61 |