2017_Bteam_alpha_master_ashi
Dependencies: Alpha_Movements BoolProcess DataCaller MD_PID mbed angle
Fork of 2017_Bteam_alpha_master by
main.cpp@8:701a9c23b517, 2017-09-21 (annotated)
- Committer:
- hirotayamato
- Date:
- Thu Sep 21 05:18:54 2017 +0000
- Revision:
- 8:701a9c23b517
- Parent:
- 6:2317b3e22cb5
- Child:
- 10:94527f9ac652
2017_Bteam_alpha_master_ashi
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:12e4c91a3b04 | 9 | #include "2017_4.h" |
Komazawa_sun | 0:7318c0dde997 | 10 | |
Komazawa_sun | 0:7318c0dde997 | 11 | #define SDA PB_7 |
Komazawa_sun | 0:7318c0dde997 | 12 | #define SCL PB_6 |
Komazawa_sun | 0:7318c0dde997 | 13 | |
Komazawa_sun | 0:7318c0dde997 | 14 | I2C *master; |
Komazawa_sun | 0:7318c0dde997 | 15 | DataPool *alpha; |
Komazawa_sun | 0:7318c0dde997 | 16 | |
hirotayamato | 6:2317b3e22cb5 | 17 | 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); |
Komazawa_sun | 0:7318c0dde997 | 18 | Serial pc(USBTX, USBRX); |
Komazawa_sun | 0:7318c0dde997 | 19 | |
Komazawa_sun | 0:7318c0dde997 | 20 | double fire_work_time; |
Komazawa_sun | 0:7318c0dde997 | 21 | int fire_work_allow = 0; |
Komazawa_sun | 0:7318c0dde997 | 22 | |
Komazawa_sun | 0:7318c0dde997 | 23 | int main() |
Komazawa_sun | 0:7318c0dde997 | 24 | { |
Komazawa_sun | 0:7318c0dde997 | 25 | master = new I2C(SDA, SCL); |
Komazawa_sun | 0:7318c0dde997 | 26 | alpha = new AlphaTransporter(master); |
Komazawa_sun | 0:7318c0dde997 | 27 | ArrowShooter shooter(master); |
hirotayamato | 1:12e4c91a3b04 | 28 | |
hirotayamato | 3:8d143b23df2a | 29 | Mecanamu.Drive(0, 0, 0); |
hirotayamato | 1:12e4c91a3b04 | 30 | float x, y, t; |
Komazawa_sun | 0:7318c0dde997 | 31 | while(1) |
Komazawa_sun | 0:7318c0dde997 | 32 | { |
Komazawa_sun | 0:7318c0dde997 | 33 | alpha->set(); |
Komazawa_sun | 0:7318c0dde997 | 34 | if(alpha->read(3) == 1) |
Komazawa_sun | 0:7318c0dde997 | 35 | { |
Komazawa_sun | 0:7318c0dde997 | 36 | fire_work_allow = 1; |
Komazawa_sun | 0:7318c0dde997 | 37 | } |
Komazawa_sun | 0:7318c0dde997 | 38 | |
Komazawa_sun | 0:7318c0dde997 | 39 | if(fire_work_allow == 1) |
Komazawa_sun | 0:7318c0dde997 | 40 | { |
Komazawa_sun | 0:7318c0dde997 | 41 | fire_work_time = shooter.fire(); |
Komazawa_sun | 0:7318c0dde997 | 42 | fire_work_allow = 1; |
Komazawa_sun | 0:7318c0dde997 | 43 | } |
Komazawa_sun | 0:7318c0dde997 | 44 | if(fire_work_time >= 3.7) |
Komazawa_sun | 0:7318c0dde997 | 45 | fire_work_allow = 0; |
hirotayamato | 1:12e4c91a3b04 | 46 | |
hirotayamato | 3:8d143b23df2a | 47 | x = alpha->read(0) / 128.00; |
hirotayamato | 3:8d143b23df2a | 48 | y = alpha->read(1) / 128.00; |
hirotayamato | 3:8d143b23df2a | 49 | t = alpha->read(2) / 128.00; |
hirotayamato | 3:8d143b23df2a | 50 | Mecanamu.Drive(x, y, t); |
hirotayamato | 8:701a9c23b517 | 51 | wait(0.01); |
hirotayamato | 3:8d143b23df2a | 52 | |
hirotayamato | 6:2317b3e22cb5 | 53 | //printf("%lf, %lf, %lf\r\n", x, y, t); |
Komazawa_sun | 0:7318c0dde997 | 54 | } |
Komazawa_sun | 0:7318c0dde997 | 55 | } |