2017_Bteam_alpha_master_ashi

Dependencies:   Alpha_Movements BoolProcess DataCaller MD_PID mbed angle

Fork of 2017_Bteam_alpha_master by taiyou komazawa

Committer:
hirotayamato
Date:
Wed Sep 27 06:50:34 2017 +0000
Revision:
10:94527f9ac652
Parent:
8:701a9c23b517
2017_Bteam_alpha_master_ashi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Komazawa_sun 0:7318c0dde997 1 #include "mbed.h"
Komazawa_sun 0:7318c0dde997 2
Komazawa_sun 0:7318c0dde997 3 #include "DataPool.h"
Komazawa_sun 0:7318c0dde997 4 #include "AlphaTransporter.h"
Komazawa_sun 0:7318c0dde997 5 #include "BoolProcess.h"
Komazawa_sun 0:7318c0dde997 6
Komazawa_sun 0:7318c0dde997 7 #include "ArrowShooter.h"
Komazawa_sun 0:7318c0dde997 8
hirotayamato 10:94527f9ac652 9 #include "ShooterAngle.h"
hirotayamato 10:94527f9ac652 10
hirotayamato 1:12e4c91a3b04 11 #include "2017_4.h"
Komazawa_sun 0:7318c0dde997 12
Komazawa_sun 0:7318c0dde997 13 #define SDA PB_7
Komazawa_sun 0:7318c0dde997 14 #define SCL PB_6
Komazawa_sun 0:7318c0dde997 15
hirotayamato 10:94527f9ac652 16
Komazawa_sun 0:7318c0dde997 17 I2C *master;
Komazawa_sun 0:7318c0dde997 18 DataPool *alpha;
Komazawa_sun 0:7318c0dde997 19
hirotayamato 6:2317b3e22cb5 20 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);
hirotayamato 10:94527f9ac652 21
Komazawa_sun 0:7318c0dde997 22 Serial pc(USBTX, USBRX);
Komazawa_sun 0:7318c0dde997 23
Komazawa_sun 0:7318c0dde997 24 double fire_work_time;
Komazawa_sun 0:7318c0dde997 25 int fire_work_allow = 0;
Komazawa_sun 0:7318c0dde997 26
hirotayamato 10:94527f9ac652 27 const int angle_max = 57;
hirotayamato 10:94527f9ac652 28 const int angle_min = 22;
hirotayamato 10:94527f9ac652 29
Komazawa_sun 0:7318c0dde997 30 int main()
Komazawa_sun 0:7318c0dde997 31 {
Komazawa_sun 0:7318c0dde997 32 master = new I2C(SDA, SCL);
Komazawa_sun 0:7318c0dde997 33 alpha = new AlphaTransporter(master);
Komazawa_sun 0:7318c0dde997 34 ArrowShooter shooter(master);
hirotayamato 10:94527f9ac652 35 ShooterAngle angle(master, angle_max, angle_min);
hirotayamato 1:12e4c91a3b04 36
hirotayamato 10:94527f9ac652 37 Mecanamu.Drive(0, 0, 0, 0);
hirotayamato 10:94527f9ac652 38 float a, x, y, t;
Komazawa_sun 0:7318c0dde997 39 while(1)
Komazawa_sun 0:7318c0dde997 40 {
Komazawa_sun 0:7318c0dde997 41 alpha->set();
Komazawa_sun 0:7318c0dde997 42 if(alpha->read(3) == 1)
Komazawa_sun 0:7318c0dde997 43 {
Komazawa_sun 0:7318c0dde997 44 fire_work_allow = 1;
Komazawa_sun 0:7318c0dde997 45 }
Komazawa_sun 0:7318c0dde997 46
Komazawa_sun 0:7318c0dde997 47 if(fire_work_allow == 1)
Komazawa_sun 0:7318c0dde997 48 {
Komazawa_sun 0:7318c0dde997 49 fire_work_time = shooter.fire();
Komazawa_sun 0:7318c0dde997 50 fire_work_allow = 1;
Komazawa_sun 0:7318c0dde997 51 }
Komazawa_sun 0:7318c0dde997 52 if(fire_work_time >= 3.7)
Komazawa_sun 0:7318c0dde997 53 fire_work_allow = 0;
hirotayamato 1:12e4c91a3b04 54
hirotayamato 10:94527f9ac652 55 a = alpha->read(3);
hirotayamato 3:8d143b23df2a 56 x = alpha->read(0) / 128.00;
hirotayamato 3:8d143b23df2a 57 y = alpha->read(1) / 128.00;
hirotayamato 3:8d143b23df2a 58 t = alpha->read(2) / 128.00;
hirotayamato 10:94527f9ac652 59
hirotayamato 10:94527f9ac652 60 Mecanamu.Drive(1, x, y, t);
hirotayamato 10:94527f9ac652 61
hirotayamato 8:701a9c23b517 62 wait(0.01);
hirotayamato 10:94527f9ac652 63 angle.setAngle(alpha->read(17));
hirotayamato 6:2317b3e22cb5 64 //printf("%lf, %lf, %lf\r\n", x, y, t);
Komazawa_sun 0:7318c0dde997 65 }
Komazawa_sun 0:7318c0dde997 66 }