ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
main.cpp@90:78d2c1527c95, 2016-05-06 (annotated)
- Committer:
- IceTeam
- Date:
- Fri May 06 12:34:25 2016 +0000
- Revision:
- 90:78d2c1527c95
- Parent:
- 89:46730de0d013
- Child:
- 91:65fb6b9f3932
Fonctionnel 61 max :);
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 81:e7b03e81b025 | 1 | #include "entete.h" |
IceTeam | 85:38cbf5fd22e1 | 2 | #include "AX12/AX12.h" |
sype | 41:b5a2fbc20beb | 3 | |
IceTeam | 83:714fa414b2bf | 4 | DigitalIn CAMP(PA_15); |
IceTeam | 83:714fa414b2bf | 5 | DigitalIn START(PB_7); |
IceTeam | 83:714fa414b2bf | 6 | DigitalOut LEDR(PC_2); |
IceTeam | 83:714fa414b2bf | 7 | DigitalOut LEDV(PC_3); |
IceTeam | 84:b54822c913b0 | 8 | DigitalIn button(USER_BUTTON); |
IceTeam | 83:714fa414b2bf | 9 | int SCouleur = VERT; |
IceTeam | 83:714fa414b2bf | 10 | |
IceTeam | 80:cd4960dfa47e | 11 | BusOut drapeau (PC_8, PC_6, PC_5); |
sype | 46:5658af4e5149 | 12 | RoboClaw roboclaw(ADR, 460800, PA_11, PA_12); |
IceTeam | 80:cd4960dfa47e | 13 | AnalogIn Rcapt1(PA_4); |
IceTeam | 80:cd4960dfa47e | 14 | int RvalRcapt1 = 0; |
IceTeam | 80:cd4960dfa47e | 15 | AnalogIn Rcapt2(PB_0); |
IceTeam | 80:cd4960dfa47e | 16 | int RvalRcapt2 = 0; |
IceTeam | 80:cd4960dfa47e | 17 | AnalogIn Rcapt3(PC_1); |
IceTeam | 80:cd4960dfa47e | 18 | int RvalRcapt3 = 0; |
IceTeam | 80:cd4960dfa47e | 19 | int Ravance = 1; |
IceTeam | 81:e7b03e81b025 | 20 | DigitalIn start(PB_7); |
IceTeam | 88:e4de39dd3e2e | 21 | AX12 umbrella(PA_9, PA_10, 2, 250000); |
IceTeam | 90:78d2c1527c95 | 22 | float R_SEUIL_SHARP = 1; |
IceTeam | 80:cd4960dfa47e | 23 | |
sype | 43:d5aaff7d2bec | 24 | /* Debut du programme */ |
sype | 0:ad9600df4a70 | 25 | int main(void) |
sype | 10:ae3178aa94e9 | 26 | { |
IceTeam | 80:cd4960dfa47e | 27 | Ticker ticker; |
IceTeam | 86:0c5e9ac3d8d8 | 28 | Timeout end; |
IceTeam | 80:cd4960dfa47e | 29 | ticker.attach(&Sharps, 0.01); |
IceTeam | 86:0c5e9ac3d8d8 | 30 | |
IceTeam | 85:38cbf5fd22e1 | 31 | umbrella.setMode(0); |
IceTeam | 85:38cbf5fd22e1 | 32 | umbrella.setMaxTorque(200); |
IceTeam | 86:0c5e9ac3d8d8 | 33 | umbrella.setGoal(150); |
IceTeam | 88:e4de39dd3e2e | 34 | wait(1); |
IceTeam | 90:78d2c1527c95 | 35 | umbrella.setGoal(160); |
IceTeam | 88:e4de39dd3e2e | 36 | wait(1); |
IceTeam | 90:78d2c1527c95 | 37 | umbrella.setGoal(150); |
IceTeam | 90:78d2c1527c95 | 38 | wait(1); |
IceTeam | 90:78d2c1527c95 | 39 | umbrella.setMaxTorque(0); |
IceTeam | 88:e4de39dd3e2e | 40 | |
IceTeam | 83:714fa414b2bf | 41 | depart(); |
IceTeam | 83:714fa414b2bf | 42 | if (SCouleur == VERT) { |
IceTeam | 90:78d2c1527c95 | 43 | end.attach(&endFonc, 60); |
IceTeam | 90:78d2c1527c95 | 44 | GotoDist(9.0); |
IceTeam | 90:78d2c1527c95 | 45 | GotoArr(9.2); |
IceTeam | 90:78d2c1527c95 | 46 | R_SEUIL_SHARP = 0.25; |
IceTeam | 90:78d2c1527c95 | 47 | GotoDist(2.5); |
IceTeam | 90:78d2c1527c95 | 48 | GotoThet(-3.14159); |
IceTeam | 90:78d2c1527c95 | 49 | GotoDist(4); |
IceTeam | 90:78d2c1527c95 | 50 | R_SEUIL_SHARP = 1; |
IceTeam | 90:78d2c1527c95 | 51 | GotoDist(3.5); |
IceTeam | 83:714fa414b2bf | 52 | } |
IceTeam | 86:0c5e9ac3d8d8 | 53 | else if (SCouleur == VIOLET) { |
IceTeam | 90:78d2c1527c95 | 54 | end.attach(&endFonc, 60); |
IceTeam | 90:78d2c1527c95 | 55 | GotoDist(9.0); |
IceTeam | 90:78d2c1527c95 | 56 | GotoArr(9.2); |
IceTeam | 90:78d2c1527c95 | 57 | R_SEUIL_SHARP = 0.25; |
IceTeam | 90:78d2c1527c95 | 58 | GotoDist(2.5); |
IceTeam | 89:46730de0d013 | 59 | GotoThet(3.14159); |
IceTeam | 90:78d2c1527c95 | 60 | GotoDist(4); |
IceTeam | 90:78d2c1527c95 | 61 | R_SEUIL_SHARP = 1; |
IceTeam | 90:78d2c1527c95 | 62 | GotoDist(3.5); |
IceTeam | 83:714fa414b2bf | 63 | } |
IceTeam | 88:e4de39dd3e2e | 64 | else if (SCouleur == NOIR) { |
IceTeam | 84:b54822c913b0 | 65 | TestDist3(2,2); |
IceTeam | 84:b54822c913b0 | 66 | TestThet3(1,1); |
IceTeam | 83:714fa414b2bf | 67 | } |
IceTeam | 83:714fa414b2bf | 68 | |
sype | 77:f19cc7f81f2a | 69 | while(1); |
sype | 2:abdf8c6823a1 | 70 | } |
IceTeam | 80:cd4960dfa47e | 71 | |
IceTeam | 80:cd4960dfa47e | 72 | void Sharps() { |
IceTeam | 80:cd4960dfa47e | 73 | if (Rcapt1.read() > R_SEUIL_SHARP) RvalRcapt1++; |
IceTeam | 80:cd4960dfa47e | 74 | else RvalRcapt1--; |
IceTeam | 80:cd4960dfa47e | 75 | RvalRcapt1 = RvalRcapt1 > 10 ? 10 : RvalRcapt1; |
IceTeam | 80:cd4960dfa47e | 76 | RvalRcapt1 = RvalRcapt1 < 0 ? 0 : RvalRcapt1; |
IceTeam | 80:cd4960dfa47e | 77 | |
IceTeam | 80:cd4960dfa47e | 78 | if (Rcapt2.read() > R_SEUIL_SHARP) RvalRcapt2++; |
IceTeam | 80:cd4960dfa47e | 79 | else RvalRcapt2--; |
IceTeam | 80:cd4960dfa47e | 80 | RvalRcapt2 = RvalRcapt2 > 10 ? 10 : RvalRcapt2; |
IceTeam | 80:cd4960dfa47e | 81 | RvalRcapt2 = RvalRcapt2 < 0 ? 0 : RvalRcapt2; |
IceTeam | 80:cd4960dfa47e | 82 | |
IceTeam | 80:cd4960dfa47e | 83 | if (Rcapt3.read() > R_SEUIL_SHARP) RvalRcapt3++; |
IceTeam | 80:cd4960dfa47e | 84 | else RvalRcapt3--; |
IceTeam | 80:cd4960dfa47e | 85 | RvalRcapt3 = RvalRcapt3 > 10 ? 10 : RvalRcapt3; |
IceTeam | 80:cd4960dfa47e | 86 | RvalRcapt3 = RvalRcapt3 < 0 ? 0 : RvalRcapt3; |
IceTeam | 80:cd4960dfa47e | 87 | |
IceTeam | 90:78d2c1527c95 | 88 | if ((RvalRcapt1 >= 5 || RvalRcapt2 >= 5 || RvalRcapt3 >= 5)) |
IceTeam | 80:cd4960dfa47e | 89 | Ravance = 0; |
IceTeam | 80:cd4960dfa47e | 90 | else |
IceTeam | 80:cd4960dfa47e | 91 | Ravance = 1; |
IceTeam | 80:cd4960dfa47e | 92 | |
IceTeam | 80:cd4960dfa47e | 93 | if (Ravance == 0) |
IceTeam | 80:cd4960dfa47e | 94 | drapeau = 1; |
IceTeam | 80:cd4960dfa47e | 95 | else |
IceTeam | 80:cd4960dfa47e | 96 | drapeau = 2; |
IceTeam | 81:e7b03e81b025 | 97 | } |
IceTeam | 81:e7b03e81b025 | 98 | |
IceTeam | 86:0c5e9ac3d8d8 | 99 | void endFonc () { |
IceTeam | 88:e4de39dd3e2e | 100 | roboclaw.ForwardM1(0); |
IceTeam | 88:e4de39dd3e2e | 101 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 102 | wait(1); |
IceTeam | 90:78d2c1527c95 | 103 | umbrella.setMaxTorque(400); |
IceTeam | 90:78d2c1527c95 | 104 | wait(1); |
IceTeam | 88:e4de39dd3e2e | 105 | umbrella.setGoal(300); |
IceTeam | 88:e4de39dd3e2e | 106 | while(1); |
IceTeam | 81:e7b03e81b025 | 107 | } |