mbedを用いた制御学生の制御
/
Kouryuu_reciverv1
アナログスティックの傾いてる角度を算出し、それにおうじてオムニの進む方向をコントロールしています。関数の使い回しはご自由にどうぞ。
Diff: main.cpp
- Revision:
- 9:687dddda7432
- Parent:
- 6:78538ae01ce6
- Child:
- 11:00c82b2d3c0f
diff -r 78538ae01ce6 -r 687dddda7432 main.cpp --- a/main.cpp Mon Mar 09 06:05:45 2015 +0000 +++ b/main.cpp Tue Mar 10 12:58:46 2015 +0000 @@ -1,7 +1,7 @@ #include "mbed.h" #define pi 3.141592653589793 -Serial sousin(p9,p10); -Serial hunter(p28,p27); +Serial sousin(p28,p27); +Serial hunter(p9,p10); Serial pc(USBTX,USBRX); Timer em; DigitalOut check (LED1); @@ -92,9 +92,9 @@ }else{ t1 = 0; } - md1 = sin(theta)*0.9+t1; - md2 = sin(theta-pi*2/3)*0.9+t1; - md3 = sin(theta-pi*4/3)*0.9+t1; + md1 = -(sin(theta)*0.9+t1); + md2 = (sin(theta-pi*2/3)*0.9+t1); + md3 = (sin(theta-pi*4/3)*0.9+t1); if (md1 < 0){ *m1 = 2; *mp1 = -md1;