Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 50:3e73f68c3b37
- Parent:
- 49:6337717484fe
- Child:
- 51:8b66c953d73a
--- a/main.cpp Mon May 20 00:54:03 2019 +0000 +++ b/main.cpp Mon May 20 01:52:35 2019 +0000 @@ -12,35 +12,21 @@ void SetMode(); void Start(); void NoHandSignal(); -void LoadParameter(); + int start_state=0; -LocalFileSystem SeqFile("Local"); -struct Param { - float argument[2]; - float duty; - float condition; -}; -struct Param params[17]= {}; //とりあえずいっぱい作った + int main() { LoadParameter(); - //setup関連 can1.frequency(1000000); SetupMoves(); set_gyro(); - - /*while(1) - { - printf("switch 1:%d 2:%d 3:%d LR:%d \r\n", switch_modes[0].read(),switch_modes[1].read(),switch_modes[2].read(),switch_LR.read()); - wait(0.1); - }*/ - printf("hand read:%d\r\n",hand.read()); - + printf("reset standby\r\n"); reset();//足をリセット位置に移動 printf("bus standby\r\n"); @@ -53,11 +39,8 @@ motor_lo.setDutyLimit(0.1); motor_li.setDutyLimit(0.1); straight(); - - // mode選択 Start(); - //SetMode(); #ifndef BADRULEMODE if(RightOrLeft == 0) { if(start_state == 0) theta0 = -degree/100.0; @@ -118,7 +101,8 @@ printf("go straight!!!!!!!!!!\r\n"); motor_lo.setDutyLimit(params[0].duty); motor_li.setDutyLimit(params[0].duty); - for(int i = 0; i < (int)params[0].condition; i++) { + + while(checkUW(params[1].condition, degree0, ec_lo.getCount()) == 0){ straightAndInfinity(params[0].argument[0], params[0].argument[1]); } printf("get distance mode"); @@ -126,7 +110,7 @@ motor_lo.setDutyLimit(params[1].duty); motor_li.setDutyLimit(params[1].duty); for(int i=0; i<1; ++i) { - while(get_dist_back() < params[1].condition) {//300 + while(Hcsr04BackWithEc() < params[1].condition) {//300 straightAndInfinity(params[1].argument[0], params[1].argument[1]); } } @@ -295,18 +279,3 @@ wait(0.01); } } -void LoadParameter() -{ - FILE *fp; - if ((fp = fopen("/Local/params.csv", "r")) == NULL) {//ファイル操作はじめかつエラー処理 - printf("file open error!!\n"); - exit(EXIT_FAILURE); - } - //以下ファイル操作の中身 - int i; - while (fscanf(fp, "%f,%f,%f,%f", ¶ms[i].argument[0], ¶ms[i].argument[1], ¶ms[i].duty,¶ms[i].condition) != EOF) { - printf("%f,%f,%f,%f\r\n",params[i].argument[0],params[i].argument[1],params[i].duty,params[i].condition); - i++; - } - fclose(fp);//ファイル操作終わり -} \ No newline at end of file