yei
Dependencies: interface mbed enc_1multi calPID motorout KondoServoLibrary
Fork of cat18_operate by
main.cpp
- Committer:
- shimizuta
- Date:
- 2018-08-14
- Revision:
- 16:b2358fd35999
- Parent:
- 13:126c3f7f9b89
- Child:
- 18:05f5a3323bda
File content as of revision 16:b2358fd35999:
#include <mbed.h> #include "debug.h"//DEBUG("",変数);でデバッグ。 #include "state.h" #include "go.h" #include "servo.h" #include "interrupt.h" #include "workposition.h" #include "controller.h" //debug用に追加 #include "interface.h" #include "coordinate.h" ///setup関連を集めた void Setups(); void Tests(); Interface interface(USBTX, USBRX); int main() { DEBUG("setup start\r\n"); Setups(); //スタート指示受付 while(CanStart() == 0) {}; DEBUG("main start"); InterruptSetup(); int worknum = 0; while( (worknum = CalPickPlace()) != 23 ) { //ワークに向かう DEBUG("worknum %d, color %d, area %d, position %f, %f, %f\r\n", worknum, work[worknum].color, work[worknum].areaname, work[worknum].position[0],work[worknum].position[1],work[worknum].position[2]); DEBUG("go to work\r\n"); if(Go(work[worknum]) != 0) continue; DEBUG("close\r\n"); //掴む Close(); DEBUG("above\r\n"); wait(1); //上に持ち上げる Above(); //取り上げたことを保存 work[worknum].is_exist = 0; //シュート位置計算 DEBUG("cal put place\r\n"); int boxspace = CalPutPlace(work[worknum].color); //ボックスに行く(失敗(-1)したらcontinue) DEBUG("go to box %d\r\n",boxspace); if(Go(shootingbox[boxspace]) != 0) continue; DEBUG("open\r\n"); //放す Open(); wait(0.5); DEBUG("above\r\n"); //上に持ち上げる Above(); wait(0.1); DEBUG("finish\r\n"); //置いたことを保存 shootingbox[boxspace].is_exist = 1; shootingbox[boxspace].color = work[worknum].color; } } void Setups() { GoSetup(); SetupPosition(); StartCheck(); } void Tests() { static int count = 0; count ++; if (count > 100000) { count =0; } }