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.
Dependencies: DataPool MD_PID mbed
Diff: 2017_3_b/2017_3_b.cpp
- Revision:
- 2:158fea945e51
- Parent:
- 0:6ed41770a6b7
- Child:
- 5:8559e2a74af2
diff -r 4fad2ab313bd -r 158fea945e51 2017_3_b/2017_3_b.cpp --- a/2017_3_b/2017_3_b.cpp Tue Aug 22 06:00:58 2017 +0000 +++ b/2017_3_b/2017_3_b.cpp Fri Aug 25 07:40:49 2017 +0000 @@ -10,15 +10,15 @@ md_f = Create_MD_PID(pin_channelA_F, pin_channelB_F, NC, 500, QEI::X4_ENCODING, 0.095 * 2, 0, 0.002 * 4, 500, pin_pwm_F, pin_dere_F); - + md_l = Create_MD_PID(pin_channelA_L, pin_channelB_L, NC, 500, QEI::X4_ENCODING, 0.095 * 2, 0, 0.002 * 4, 500, pin_pwm_L, pin_dere_L); - + md_r = Create_MD_PID(pin_channelA_R, pin_channelB_R, NC, 500, QEI::X4_ENCODING, 0.095 * 2, 0, 0.002 * 4, 500, pin_pwm_R, pin_dere_R); - + rev = arg_rev; } @@ -27,14 +27,14 @@ double dere, sp; double duty[3]; double speed[3]; - + dere = atan2(arg_y, arg_x); sp = sqrt(pow(arg_x, 2.0) + pow(arg_y, 2.0)); - + speed[0] = cos(dere) * sp; // vx speed[1] = sin(dere) * sp; // vy - speed[2] = arg_rota; // omega - + speed[2] = arg_rota; // omega + Matrix(speed, duty); for(int i = 0; i < 3; i++){ if(fabs(duty[i]) > 1.0){ @@ -61,7 +61,7 @@ keisu[2][0] = 1.0 / 2.0; keisu[2][1] = sqrt(3.0) / 2.0; keisu[2][2] = 1.0; - + for(int i = 0; i < 3; i++){ duty[i] = 0.0; for(int j = 0; j < 3; j++){