2017_Bteam_alpha_master_ashi
Dependencies: Alpha_Movements BoolProcess DataCaller MD_PID mbed angle
Fork of 2017_Bteam_alpha_master by
Revision 10:94527f9ac652, committed 2017-09-27
- Comitter:
- hirotayamato
- Date:
- Wed Sep 27 06:50:34 2017 +0000
- Parent:
- 9:ad7803030f2d
- Commit message:
- 2017_Bteam_alpha_master_ashi
Changed in this revision
diff -r ad7803030f2d -r 94527f9ac652 2017_4/2017_4.cpp --- a/2017_4/2017_4.cpp Thu Sep 21 05:21:14 2017 +0000 +++ b/2017_4/2017_4.cpp Wed Sep 27 06:50:34 2017 +0000 @@ -9,26 +9,25 @@ int arg_rev) { md_fr = Create_MD_PID(pin_channelA_FR, pin_channelB_FR, NC, 500, QEI::X4_ENCODING, - 0.095 * 0.5, 0, 0.0005 * 4, 500, + 0.0475 * 0.25, 0, 0.00025 * 2, 500, pin_pwm_FR, pin_dere_FR); md_fl = Create_MD_PID(pin_channelA_FL, pin_channelB_FL, NC, 500, QEI::X4_ENCODING, - 0.095 * 0.5, 0, 0.0005 * 4, 500, + 0.0475 * 0.25, 0, 0.00025 * 2, 500, pin_pwm_FL, pin_dere_FL); md_br = Create_MD_PID(pin_channelA_BR, pin_channelB_BR, NC, 500, QEI::X4_ENCODING, - 0.095 * 0.5, 0, 0.0005 * 4, 500, + 0.0475 * 0.25, 0, 0.00025 * 2, 500, pin_pwm_BR, pin_dere_BR); md_bl = Create_MD_PID(pin_channelA_BL, pin_channelB_BL, NC, 500, QEI::X4_ENCODING, - 0.095 * 0.5, 0, 0.0005 * 4, 500, + 0.0475 * 0.25, 0, 0.00025 * 2, 500, pin_pwm_BL, pin_dere_BL); rev = arg_rev; } -void Mecanamu_4::Drive( double arg_x, double arg_y, double arg_rota, - double F_Gain, double B_Gain, double R_Gain, double L_Gain) +void Mecanamu_4::Drive( int arg_a, double arg_x, double arg_y, double arg_rota) { double dere, sp; double duty[4]; @@ -50,11 +49,20 @@ } } } - - md_fr->Drive(duty[0] * F_Gain, 100); - md_fl->Drive(duty[1] * B_Gain, 100); - md_br->Drive(duty[2] * R_Gain, 100); - md_bl->Drive(duty[3] * L_Gain, 100); + + printf("%f, %f, %f, %f\r\n", duty[0], duty[1], duty[2], duty[3]); + + //if(arg_a){ + md_fr->Drive(arg_a, duty[0], 100); + md_fl->Drive(arg_a, duty[1], 100); + md_br->Drive(arg_a, duty[2], 100); + md_bl->Drive(arg_a, duty[3], 100); + /*}else{ + md_fr->Drive(arg_a, duty[0], 100); + md_fl->Drive(arg_a, duty[1], 100); + md_br->Drive(arg_a, duty[2], 100); + md_bl->Drive(arg_a, duty[3], 100); + }*/ } void Mecanamu_4::Matrix(double speed[3], double duty[4])
diff -r ad7803030f2d -r 94527f9ac652 2017_4/2017_4.h --- a/2017_4/2017_4.h Thu Sep 21 05:21:14 2017 +0000 +++ b/2017_4/2017_4.h Wed Sep 27 06:50:34 2017 +0000 @@ -11,8 +11,7 @@ PinName pin_pwm_BR, PinName pin_dere_BR, PinName pin_channelA_BR, PinName pin_channelB_BR, PinName pin_pwm_BL, PinName pin_dere_BL, PinName pin_channelA_BL, PinName pin_channelB_BL, int rev = 1); - void Drive( double arg_x, double arg_y, double arg_rota, - double F_Gain = 1.0, double B_Gain = 1.0, double R_Gain = 1.0, double L_Gain = 1.0); + void Drive( int arg_a, double arg_x, double arg_y, double arg_rota); private: void Matrix(double speed[3], double duty[4]); int rev;
diff -r ad7803030f2d -r 94527f9ac652 DataCaller.lib --- a/DataCaller.lib Thu Sep 21 05:21:14 2017 +0000 +++ b/DataCaller.lib Wed Sep 27 06:50:34 2017 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/hirotayamato/code/DataCaller/#ba94b0b83542 +https://os.mbed.com/users/hirotayamato/code/DataCaller/#09321a407a82
diff -r ad7803030f2d -r 94527f9ac652 MD_PID.lib --- a/MD_PID.lib Thu Sep 21 05:21:14 2017 +0000 +++ b/MD_PID.lib Wed Sep 27 06:50:34 2017 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/hirotayamato/code/MD_PID/#b621815834c1 +https://developer.mbed.org/users/hirotayamato/code/MD_PID/#d930cbffd2c9
diff -r ad7803030f2d -r 94527f9ac652 angle.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/angle.lib Wed Sep 27 06:50:34 2017 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/Komazawa_sun/code/angle/#3e9f5fcfc775
diff -r ad7803030f2d -r 94527f9ac652 main.cpp --- a/main.cpp Thu Sep 21 05:21:14 2017 +0000 +++ b/main.cpp Wed Sep 27 06:50:34 2017 +0000 @@ -6,28 +6,36 @@ #include "ArrowShooter.h" +#include "ShooterAngle.h" + #include "2017_4.h" #define SDA PB_7 #define SCL PB_6 + I2C *master; DataPool *alpha; Mecanamu_4 Mecanamu(PA_8, PB_0, PA_12, PA_7, PA_11, PB_1, PA_6, PA_5, PB_5, PF_0, PA_4, PA_3, PB_4, PF_1, PA_1, PA_0, 1); + Serial pc(USBTX, USBRX); double fire_work_time; int fire_work_allow = 0; +const int angle_max = 57; +const int angle_min = 22; + int main() { master = new I2C(SDA, SCL); alpha = new AlphaTransporter(master); ArrowShooter shooter(master); + ShooterAngle angle(master, angle_max, angle_min); - Mecanamu.Drive(0, 0, 0); - float x, y, t; + Mecanamu.Drive(0, 0, 0, 0); + float a, x, y, t; while(1) { alpha->set(); @@ -44,12 +52,15 @@ if(fire_work_time >= 3.7) fire_work_allow = 0; + a = alpha->read(3); x = alpha->read(0) / 128.00; y = alpha->read(1) / 128.00; t = alpha->read(2) / 128.00; - Mecanamu.Drive(x, y, t); + + Mecanamu.Drive(1, x, y, t); + wait(0.01); - + angle.setAngle(alpha->read(17)); //printf("%lf, %lf, %lf\r\n", x, y, t); } }