yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
calplace/calplace.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 | 1:cc056c41ae30 | 1 | #include "calplace.h" |
shimizuta | 0:c3a72fe24137 | 2 | #include <mbed.h> |
shimizuta | 2:4515e8cc6b60 | 3 | #include "position.h" |
shimizuta | 0:c3a72fe24137 | 4 | #include "debug.h"//DEBUG("",変数);でデバッグ。 |
shimizuta | 1:cc056c41ae30 | 5 | |
shimizuta | 1:cc056c41ae30 | 6 | ///色から置く場所を計算するプログラム |
shimizuta | 2:4515e8cc6b60 | 7 | int CalThrowPlace(Color color) |
shimizuta | 2:4515e8cc6b60 | 8 | { |
shimizuta | 1:cc056c41ae30 | 9 | return 0; |
shimizuta | 1:cc056c41ae30 | 10 | } |
shimizuta | 0:c3a72fe24137 | 11 | |
shimizuta | 2:4515e8cc6b60 | 12 | int CalPickPlace() //どれを取るのがいいか検索する |
shimizuta | 2:4515e8cc6b60 | 13 | { |
shimizuta | 2:4515e8cc6b60 | 14 | int i; |
shimizuta | 2:4515e8cc6b60 | 15 | int best=23; |
shimizuta | 2:4515e8cc6b60 | 16 | //priorityの値を入れる |
shimizuta | 2:4515e8cc6b60 | 17 | for(i=0; i<=22; i++) { |
shimizuta | 2:4515e8cc6b60 | 18 | if(work[i].is_exist) { |
shimizuta | 2:4515e8cc6b60 | 19 | if(work[i].priority<work[best].priority) { |
shimizuta | 2:4515e8cc6b60 | 20 | best=i; |
shimizuta | 2:4515e8cc6b60 | 21 | } |
shimizuta | 2:4515e8cc6b60 | 22 | } |
shimizuta | 2:4515e8cc6b60 | 23 | } |
shimizuta | 2:4515e8cc6b60 | 24 | return best; |
shimizuta | 2:4515e8cc6b60 | 25 | } |
shimizuta | 0:c3a72fe24137 | 26 | |
shimizuta | 2:4515e8cc6b60 | 27 | |
shimizuta | 2:4515e8cc6b60 | 28 | |
shimizuta | 2:4515e8cc6b60 | 29 | int CalPutPlace(Color workcolor) |
shimizuta | 2:4515e8cc6b60 | 30 | { |
shimizuta | 2:4515e8cc6b60 | 31 | int is_decided = 0; |
shimizuta | 2:4515e8cc6b60 | 32 | int num = 0; |
shimizuta | 2:4515e8cc6b60 | 33 | for(int j=0; j<4 && is_decided == 0; j++) { |
shimizuta | 2:4515e8cc6b60 | 34 | for(int i=0; i<2 && is_decided == 0; i++) { |
shimizuta | 2:4515e8cc6b60 | 35 | num = j*3+i; |
shimizuta | 2:4515e8cc6b60 | 36 | if(!shootingbox[num].is_exist) is_decided = 0; |
shimizuta | 2:4515e8cc6b60 | 37 | if(workcolor != shootingbox[num].color) break; |
shimizuta | 2:4515e8cc6b60 | 38 | } |
shimizuta | 2:4515e8cc6b60 | 39 | } |
shimizuta | 2:4515e8cc6b60 | 40 | return num; |
shimizuta | 2:4515e8cc6b60 | 41 | } |