![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
f3rc 3班のエンコーダのプログラムです。
Diff: main.cpp
- Revision:
- 1:0ff59878537a
- Parent:
- 0:da183064372e
- Child:
- 2:a682612dd8b7
--- a/main.cpp Mon Sep 03 05:00:04 2018 +0000 +++ b/main.cpp Mon Sep 03 05:21:06 2018 +0000 @@ -24,11 +24,28 @@ //SpeedControl (p11,p12,/*z相*/,/*分解能*/,0.05,,) pwmでないのでscは使えないかも //SpeedControl (p13,p14,/*z相*/,/*分解能*/,0.05,,) pwmでないのでscは使えないかも -/*直進*/ +/*直進用*/ void straight(double t,int l) //t=時間 l=移動距離 { mortor1.period_us(50); mortor2.period_us(50); + double EC1_omega = wheel_1.getOmega(); //ec1の角速度 + double EC2_omega = wheel_2.getOmega(); //ec2の角速度 + double L_1 = EC1_omega*"ecの半径"*t; + double L_2 = EC2_omega*"ecの半径"*t; + while(L_1 <= l && L_2 <= l) { + motor1 = ; + motor2 = ; + motor1cw = ; + motor2cw = ; + } +} + +/*後退用*/ +void back(double t,int l) //t=時間 l=移動距離 +{ + mortor1.period_us(50); + mortor2.period_us(50); double EC1_omega = wheel_1.getOmega(); double EC2_omega = wheel_2.getOmega(); double L_1 = EC1_omega*"ecの半径"*t;