改良版位置補正プログラム動作未確認
Dependencies: mbed move4wheel2 EC CruizCore_R1370P
Diff: movement/movement.cpp
- Revision:
- 3:8a0faa3b08c3
- Parent:
- 1:3c11e07da92a
- Child:
- 4:317c53a674fa
--- a/movement/movement.cpp Tue Feb 26 05:10:27 2019 +0000 +++ b/movement/movement.cpp Fri Mar 01 00:48:07 2019 +0000 @@ -13,8 +13,8 @@ char ashi_data[4]={0}; -Ec EC1(p8,p26,NC,500,0.05); -Ec EC2(p21,p22,NC,500,0.05); +Ec EC2(p26,p8,NC,500,0.05); +Ec EC1(p22,p21,NC,500,0.05); Ticker ec_ticker; //ec角速度計算用ticker R1370P gyro(p28,p27); @@ -235,12 +235,9 @@ calc_xy_enc(); - if(u != 1){ + if(u != 1 || v != 1){ calc_xy_usw(target_angle); //エンコーダの値しか使用しない場合は超音波センサーによる座標計算は行わずに計算量を減らす。 } - if(v != 1){ - calc_xy_usw(target_angle); - } now_x = u * info.nowX.enc + (1-u) * info.nowX.usw; now_y = v * info.nowY.enc + (1-v) * info.nowY.usw; @@ -450,7 +447,7 @@ calc_xy(tgt_angle, u, v); while(1){ //機体の位置を目標領域(目標座標+許容誤差)に収める - gogo_straight(u,v,now_x,now_y,tgt_x,tgt_y,100,0,5,0.1,10,0.1,500,tgt_angle); + gogo_straight(u,v,now_x,now_y,tgt_x,tgt_y,200,100,5,0.1,10,0.1,500,tgt_angle); MaxonControl(0,0,0,0); calc_xy(tgt_angle, u, v); @@ -475,7 +472,7 @@ MaxonControl(out,out,out,out); } - if(tgt_angle - 2 < now_angle && now_angle < tgt_angle + 2) break; //目標角度からの許容誤差内に機体の角度が収まった時、補正終了 + if(tgt_angle - 0.5 < now_angle && now_angle < tgt_angle + 0.5) break; //目標角度からの許容誤差内に機体の角度が収まった時、補正終了 } MaxonControl(0,0,0,0);