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:
- 6:28b7339892f9
- Parent:
- 5:62de7a36d3af
- Child:
- 7:ed304ba2712a
--- a/main.cpp Tue Sep 27 05:24:37 2016 +0000 +++ b/main.cpp Tue Sep 27 07:57:15 2016 +0000 @@ -26,13 +26,14 @@ void output() { + v=v*10; printf("\n|v|: %lf theta: %lf\n",v,argv); //最終的にだすやつ x = argv; y = v; i=2; - + joystick.update(throttle, rudder, x, y, button, hat); wait(1); - button = (i<<8) & 0x0F; + button = (0x0002) & 0x0F; joystick.update(throttle, rudder, x, y, button, hat); } @@ -78,7 +79,7 @@ timeouter1.attach(&reset, 5); } time1=tmr.read_ms(); - printf("1: %d %d[ms]", cm1,time1); + printf("1: %d %d[s]", cm1,time1); count1++; timecount1++; @@ -89,7 +90,7 @@ timesum1=timesum1+time1; //time1を合計する timeavg1=timesum1/timecount1; //time1の平均 - printf(" timeavg1: %f[ms]\n",timeavg1); + printf(" timeavg1: %f[s]\n",timeavg1); } wait_ms(10); @@ -115,7 +116,7 @@ cm2 = microsecondsToCentimeters(USSDistance2); if(15<cm2&&cm2<40) { time2=tmr.read_ms(); - printf(" 2: %d %d[ms]",cm2,time2); + printf(" 2: %d %d[s]",cm2,time2); count2++; timecount2++; @@ -126,16 +127,16 @@ timesum2=timesum2+time2; //time2を合計する timeavg2=timesum2/timecount2; //time2の平均 - printf(" timeavg2:%f[ms]\n",timeavg2); + printf(" timeavg2:%f[s]\n",timeavg2); deltat=timeavg2-timeavg1; //Δtを求める printf("\ndeltat: %f\n",deltat); a=pow((avg2-avg1)/deltat,2); - b=pow(10/deltat,2); + b=pow(0.1/deltat,2); v=sqrt(a+b); //|v|を求める - argv=atan(10/(avg2-avg1)); //θを求める + argv=atan(0.1/(avg2-avg1)); //θを求める } wait_ms(10); }