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.
Dependencies: mbed SpeedController Encoder CruizCore_R1370P
Diff: main.cpp
- Revision:
- 17:bafc6a46b3df
- Parent:
- 16:7ce4ab00621a
- Child:
- 18:1d89ec4148ec
--- a/main.cpp Thu Mar 05 09:56:08 2020 +0000 +++ b/main.cpp Thu Mar 05 11:22:58 2020 +0000 @@ -96,9 +96,9 @@ //目的地決定 int plot[5][2]= { {0,0} - ,{0,15000} - ,{5000,15000} - ,{5000,0} + ,{0,10000} + ,{2500,1000} + ,{2500,0} ,{0,0} }; @@ -116,7 +116,11 @@ } void setOmega(int max) { - max_=max; + if(max >= 0) { + max_=max; + } else { + max_ = -1 * max; + } } void setVxy(double vx,double vy) { @@ -159,13 +163,13 @@ { double distance,z,zMax; distance = sqrt((double)dx_*dx_+dy_*dy_); - z=0.003*distance; - zMax=20; + z=0.005*distance; + zMax=10; if(z>zMax) { z=zMax; } - if(time_<2) { - z=z*(time_/2); + if(time_<1) { + z=z*time_; } return z; } @@ -229,16 +233,15 @@ omega.setVxy(vx,vy); omega.calOmega(); - if(dx<50 && dx>-50 && dy<50 && dy>-50) { + if(dx<500 && dx>-500 && dy<500 && dy>-500) { n++; printf("reach"); ticker.detach(); for(int j=0; j<4; j++) { motor[j].stop(); } + wait(1); time.reset(); - wait(1); - time.start(); } if(n>4) {