mbedを用いた制御学生の制御
/
Kouryuu_reciverv1
アナログスティックの傾いてる角度を算出し、それにおうじてオムニの進む方向をコントロールしています。関数の使い回しはご自由にどうぞ。
Diff: main.cpp
- Revision:
- 8:5c54756c501b
- Parent:
- 7:0e9cbd33abfe
- Child:
- 10:9de2ce23c712
diff -r 0e9cbd33abfe -r 5c54756c501b main.cpp --- a/main.cpp Mon Mar 09 09:01:33 2015 +0000 +++ b/main.cpp Tue Mar 10 08:59:52 2015 +0000 @@ -17,6 +17,7 @@ double get_sen(void) { double degree; + int degreed; double phi,theta,tp; double val[3]; int i = 0; @@ -53,7 +54,8 @@ }else{ degree = (pi+theta)/pi*180+180; } - //printf("degree-->%f\n\r",degree); + degreed = degree; + printf("degree-->%d\n\r",degreed); return degree; } double get_theta(double stickx,double sticky) @@ -190,9 +192,9 @@ if (asen < 0){ asen = 360; } - if (sen > asen+10){ + if (sen > asen+20){ hun = 1; - }else if (sen <asen-10){ + }else if (sen <asen-20){ hun = 2; }else { hun = 0; @@ -204,7 +206,7 @@ if (ec == 0){ em.reset(); theta = get_theta(sx,sy); - pc.printf("%f\n\r",theta); + //pc.printf("%f\n\r",theta); if (sw1 == -1){ omni_cont(hun,theta,&motor[0],&motor[1],&motor[2],&motp[0],&motp[1],&motp[2]); mo1 = motor[0]; @@ -219,16 +221,16 @@ mo1 = 1; mo2 = 1; mo3 = 1; - mop1 = 1; - mop2 = 1; - mop3 = 1; + mop1 = 0.5; + mop2 = 0.5; + mop3 = 0.5; }else if(hun == 2){ mo1 = 2; mo2 = 2; mo3 = 2; - mop1 = 1; - mop2 = 1; - mop3 = 1; + mop1 = 0.5; + mop2 = 0.5; + mop3 = 0.5; }else { mo1 = 0; mo2 = 0;