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:
- 19:b162e7f4cc06
- Parent:
- 18:d0a6771fa38d
- Child:
- 20:e30e6e175991
diff -r d0a6771fa38d -r b162e7f4cc06 main.cpp --- a/main.cpp Thu May 02 09:39:31 2019 +0000 +++ b/main.cpp Fri May 03 00:30:11 2019 +0000 @@ -68,20 +68,24 @@ set_gyro(); printf("dist:%.3f\r\n", get_dist_forward()); //直進スタート + motor_lo.setDutyLimit(0.6);//0.5 + motor_li.setDutyLimit(0.6); for(int i=0;i<3;++i){ - while(get_dist_back() < 280) + while(get_dist_back() < 290) { straightAndInfinity(0, 5); //wait(0.01); - printf("forward:%.3f back:%.3f\r\n", get_dist_forward(),get_dist_back()); +// printf("forward:%.3f back:%.3f\r\n", get_dist_forward(),get_dist_back()); } } //printf("back dist:%.3f\r\n", get_dist_back()); //段差前旋回 - motor_lo.setDutyLimit(0.4);//0.5 - motor_li.setDutyLimit(0.4); + motor_lo.setDutyLimit(0.3);//0.5 + motor_li.setDutyLimit(0.3); turn(40.0); //段差乗り越え + motor_lo.setDutyLimit(0.3);//0.5 + motor_li.setDutyLimit(0.3); for(int i= 0;i<5;++i) straight(); while(get_dist_back() > 40) straight(); //段差後旋回 @@ -130,15 +134,15 @@ motor_lo.setDutyLimit(0.2);//0.5 motor_li.setDutyLimit(0.2); - for(int i=0; i<15; ++i)straightAndInfinity(0, 5); + for(int i=0; i<15; ++i)straightAndInfinity(-90, 5); printf("wall standby"); while(get_dist_back() < 250) { - straightAndInfinity(0, 5); + straightAndInfinity(-90, 5); printf("forward:%.3f back:%.3f\r\n", get_dist_forward(),get_dist_back()); } for(int i=0; i<2; ++i) { while(get_dist_forward() > 65) { - straightAndInfinity(0, 5); + straightAndInfinity(-90, 5); printf("forward:%.3f back:%.3f\r\n", get_dist_forward(),get_dist_back()); } } @@ -312,7 +316,7 @@ double get_dist_back() { sensor_back.start(); - wait_ms(10);//10 //sensor.start()で信号を送ったあと反射波が帰ってきてから距離データが更新されるため、少し待つ必要がある。 + //wait_ms(20);//10 //sensor.start()で信号を送ったあと反射波が帰ってきてから距離データが更新されるため、少し待つ必要がある。 //何ループも回す場合は不要。また、時間は適当だから調整が必要。 float dist = sensor_back.get_dist_cm(); if(dist < 0.1) dist = 2000.0; @@ -321,7 +325,7 @@ double get_dist_forward() { sensor_forward.start(); - wait_ms(10);//10 + //wait_ms(20);//10 float dist = sensor_forward.get_dist_cm(); if(dist < 0.1) dist = 2000.0; return dist;