ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
main.cpp@47:be4eebf40568, 2016-04-25 (annotated)
- Committer:
- IceTeam
- Date:
- Mon Apr 25 12:42:32 2016 +0000
- Revision:
- 47:be4eebf40568
- Parent:
- 45:b53ae54062c6
- Child:
- 49:5e2f7323f280
Petit commit de batard;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sype | 41:b5a2fbc20beb | 1 | #include "func.h" |
IceTeam | 47:be4eebf40568 | 2 | #include "map.h" |
sype | 0:ad9600df4a70 | 3 | |
sype | 10:ae3178aa94e9 | 4 | #define ATTENTE 0 |
sype | 10:ae3178aa94e9 | 5 | #define GO 1 |
sype | 10:ae3178aa94e9 | 6 | #define STOP 2 |
sype | 0:ad9600df4a70 | 7 | |
sype | 41:b5a2fbc20beb | 8 | /* Déclaration des différents éléments de l'IHM */ |
sype | 10:ae3178aa94e9 | 9 | InterruptIn mybutton(USER_BUTTON); |
sype | 10:ae3178aa94e9 | 10 | DigitalIn button(USER_BUTTON); |
sype | 2:abdf8c6823a1 | 11 | DigitalOut led(LED1); |
sype | 41:b5a2fbc20beb | 12 | DigitalOut bleu(PC_5); |
sype | 41:b5a2fbc20beb | 13 | DigitalOut blanc(PC_6); |
sype | 41:b5a2fbc20beb | 14 | DigitalOut rouge(PC_8); |
sype | 41:b5a2fbc20beb | 15 | |
sype | 41:b5a2fbc20beb | 16 | /* AX12 */ |
sype | 41:b5a2fbc20beb | 17 | AX12 left_hand(PA_15, PB_7, 4, 250000); |
sype | 41:b5a2fbc20beb | 18 | AX12 right_hand(PA_15, PB_7, 1, 250000); |
sype | 41:b5a2fbc20beb | 19 | |
sype | 41:b5a2fbc20beb | 20 | /* Sharp */ |
sype | 41:b5a2fbc20beb | 21 | AnalogIn capt1(PA_4); |
sype | 41:b5a2fbc20beb | 22 | AnalogIn capt2(PB_0); |
sype | 41:b5a2fbc20beb | 23 | AnalogIn capt3(PC_1); |
sype | 41:b5a2fbc20beb | 24 | AnalogIn capt4(PC_0); |
sype | 41:b5a2fbc20beb | 25 | |
sype | 41:b5a2fbc20beb | 26 | /* Moteurs pas à pas */ |
sype | 41:b5a2fbc20beb | 27 | Stepper RMot(NC, PB_10, PA_8); |
sype | 41:b5a2fbc20beb | 28 | Stepper ZMot(NC, PB_5, PB_4); |
sype | 41:b5a2fbc20beb | 29 | Stepper LMot(NC, PB_3, PA_10); |
sype | 41:b5a2fbc20beb | 30 | /* Fins de course */ |
sype | 41:b5a2fbc20beb | 31 | InterruptIn EndR(PB_15); |
sype | 41:b5a2fbc20beb | 32 | InterruptIn EndZ(PB_14); |
sype | 41:b5a2fbc20beb | 33 | InterruptIn EndL(PB_13); |
sype | 41:b5a2fbc20beb | 34 | |
sype | 0:ad9600df4a70 | 35 | Ticker ticker; |
sype | 41:b5a2fbc20beb | 36 | |
IceTeam | 47:be4eebf40568 | 37 | //Serial logger(USBTX, USBRX); |
IceTeam | 47:be4eebf40568 | 38 | Serial logger(PA_9, PA_10); |
sype | 10:ae3178aa94e9 | 39 | RoboClaw roboclaw(460800, PA_11, PA_12); |
IceTeam | 39:309f38d1e49c | 40 | Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw); |
sype | 10:ae3178aa94e9 | 41 | |
sype | 41:b5a2fbc20beb | 42 | int i = 0, state = 0; |
sype | 41:b5a2fbc20beb | 43 | bool EL = false, EZ = false, ER = false; |
sype | 0:ad9600df4a70 | 44 | |
sype | 2:abdf8c6823a1 | 45 | void init(void); |
sype | 0:ad9600df4a70 | 46 | |
sype | 43:d5aaff7d2bec | 47 | /* Debut du programme */ |
sype | 0:ad9600df4a70 | 48 | int main(void) |
sype | 10:ae3178aa94e9 | 49 | { |
IceTeam | 47:be4eebf40568 | 50 | init(); |
IceTeam | 47:be4eebf40568 | 51 | |
IceTeam | 47:be4eebf40568 | 52 | /*map m(&odo); |
IceTeam | 47:be4eebf40568 | 53 | m.addObs(obsCarr (1250, 1000, 220, 220)); |
IceTeam | 47:be4eebf40568 | 54 | m.addObs(obsCarr (1500, 750, 220, 220)); |
IceTeam | 47:be4eebf40568 | 55 | m.addObs(obsCarr (1500, 1250, 220, 220)); |
IceTeam | 47:be4eebf40568 | 56 | |
IceTeam | 47:be4eebf40568 | 57 | m.Execute(1000,1000); |
IceTeam | 47:be4eebf40568 | 58 | m.Execute(1500,1000); |
IceTeam | 47:be4eebf40568 | 59 | m.Execute(1500,1500); |
IceTeam | 47:be4eebf40568 | 60 | m.Execute(110,1000); |
IceTeam | 47:be4eebf40568 | 61 | |
IceTeam | 47:be4eebf40568 | 62 | odo.GotoThet(0); |
IceTeam | 47:be4eebf40568 | 63 | |
IceTeam | 47:be4eebf40568 | 64 | roboclaw.ForwardM1(ADR, 0); |
IceTeam | 47:be4eebf40568 | 65 | roboclaw.ForwardM2(ADR, 0); |
IceTeam | 47:be4eebf40568 | 66 | |
IceTeam | 47:be4eebf40568 | 67 | logger.printf ("Chemin Fini !");*/ |
IceTeam | 47:be4eebf40568 | 68 | odo.GotoXY(500,1000); |
IceTeam | 47:be4eebf40568 | 69 | while (1); |
sype | 2:abdf8c6823a1 | 70 | } |
sype | 2:abdf8c6823a1 | 71 | |
sype | 2:abdf8c6823a1 | 72 | void init(void) |
sype | 0:ad9600df4a70 | 73 | { |
IceTeam | 47:be4eebf40568 | 74 | odo.setPos(110, 1000, 0); |
sype | 37:da3a2c781672 | 75 | roboclaw.ForwardM1(ADR, 0); |
sype | 37:da3a2c781672 | 76 | roboclaw.ForwardM2(ADR, 0); |
sype | 37:da3a2c781672 | 77 | logger.baud(9600); |
sype | 37:da3a2c781672 | 78 | logger.printf("Hello from main !\n\r"); |
IceTeam | 47:be4eebf40568 | 79 | bleu = 1, blanc = 1, rouge = 1; |
sype | 10:ae3178aa94e9 | 80 | wait_ms(500); |
sype | 44:b1fd7489369f | 81 | bleu = 0, blanc = 0, rouge = 0; |
sype | 10:ae3178aa94e9 | 82 | |
sype | 10:ae3178aa94e9 | 83 | while(button); |
sype | 10:ae3178aa94e9 | 84 | wait(1); |
sype | 44:b1fd7489369f | 85 | |
sype | 44:b1fd7489369f | 86 | init_ax12(); |
sype | 44:b1fd7489369f | 87 | init_interrupt(); |
sype | 41:b5a2fbc20beb | 88 | wait_ms(100); |
IceTeam | 39:309f38d1e49c | 89 | logger.printf("End init\n\r"); |
sype | 0:ad9600df4a70 | 90 | } |