Romain Ame
/
Stressed
coucou
Fork of Robot2016_2-0 by
main.cpp.orig@53:bef06d5e827d, 2016-05-04 (annotated)
- Committer:
- IceTeam
- Date:
- Wed May 04 16:21:48 2016 +0000
- Revision:
- 53:bef06d5e827d
- Child:
- 74:07cdad6e861a
Ajout d?part homologation;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 53:bef06d5e827d | 1 | #include "func.h" |
IceTeam | 53:bef06d5e827d | 2 | #include "map.h" |
IceTeam | 53:bef06d5e827d | 3 | |
IceTeam | 53:bef06d5e827d | 4 | /* Déclaration des différents éléments de l'IHM */ |
IceTeam | 53:bef06d5e827d | 5 | |
IceTeam | 53:bef06d5e827d | 6 | DigitalIn CAMP(PA_15); |
IceTeam | 53:bef06d5e827d | 7 | DigitalIn START(PB_7); |
IceTeam | 53:bef06d5e827d | 8 | DigitalOut LEDR(PC_2); |
IceTeam | 53:bef06d5e827d | 9 | DigitalOut LEDV(PC_3); |
IceTeam | 53:bef06d5e827d | 10 | |
IceTeam | 53:bef06d5e827d | 11 | BusOut drapeau(PC_8, PC_6, PC_5); |
IceTeam | 53:bef06d5e827d | 12 | |
IceTeam | 53:bef06d5e827d | 13 | InterruptIn mybutton(USER_BUTTON); |
IceTeam | 53:bef06d5e827d | 14 | DigitalIn button(USER_BUTTON); |
IceTeam | 53:bef06d5e827d | 15 | |
IceTeam | 53:bef06d5e827d | 16 | DigitalIn ChannelA1(PA_1); |
IceTeam | 53:bef06d5e827d | 17 | DigitalIn ChannelB1(PA_0); |
IceTeam | 53:bef06d5e827d | 18 | DigitalIn ChannelA2(PA_5); |
IceTeam | 53:bef06d5e827d | 19 | DigitalIn ChannelB2(PA_6); |
IceTeam | 53:bef06d5e827d | 20 | |
IceTeam | 53:bef06d5e827d | 21 | DigitalOut bleu(PC_5); |
IceTeam | 53:bef06d5e827d | 22 | DigitalOut blanc(PC_6); |
IceTeam | 53:bef06d5e827d | 23 | DigitalOut rouge(PC_8); |
IceTeam | 53:bef06d5e827d | 24 | |
IceTeam | 53:bef06d5e827d | 25 | //AX12 left_hand(PA_9, PA_10, 4, 250000); |
IceTeam | 53:bef06d5e827d | 26 | //AX12 right_hand(PA_9, PA_10, 1, 250000); |
IceTeam | 53:bef06d5e827d | 27 | |
IceTeam | 53:bef06d5e827d | 28 | /* Sharp */ |
IceTeam | 53:bef06d5e827d | 29 | AnalogIn capt1(PA_4); |
IceTeam | 53:bef06d5e827d | 30 | AnalogIn capt2(PB_0); |
IceTeam | 53:bef06d5e827d | 31 | AnalogIn capt3(PC_1); |
IceTeam | 53:bef06d5e827d | 32 | AnalogIn capt4(PC_0); |
IceTeam | 53:bef06d5e827d | 33 | |
IceTeam | 53:bef06d5e827d | 34 | /* Moteurs pas à pas */ |
IceTeam | 53:bef06d5e827d | 35 | Stepper RMot(NC, PA_8, PC_7, 4); |
IceTeam | 53:bef06d5e827d | 36 | Stepper ZMot(NC, PB_4, PB_10, 5); |
IceTeam | 53:bef06d5e827d | 37 | Stepper LMot(NC, PB_5, PB_3, 4); |
IceTeam | 53:bef06d5e827d | 38 | /* Fins de course */ |
IceTeam | 53:bef06d5e827d | 39 | InterruptIn EndR(PB_15); |
IceTeam | 53:bef06d5e827d | 40 | InterruptIn EndZ(PB_14); |
IceTeam | 53:bef06d5e827d | 41 | InterruptIn EndL(PB_13); |
IceTeam | 53:bef06d5e827d | 42 | DigitalIn EnR(PB_15); |
IceTeam | 53:bef06d5e827d | 43 | DigitalIn EnZ(PB_14); |
IceTeam | 53:bef06d5e827d | 44 | DigitalIn EnL(PB_13); |
IceTeam | 53:bef06d5e827d | 45 | |
IceTeam | 53:bef06d5e827d | 46 | Ticker ticker; |
IceTeam | 53:bef06d5e827d | 47 | //Serial logger(USBTX, USBRX); |
IceTeam | 53:bef06d5e827d | 48 | Serial logger(PA_2, PA_3); |
IceTeam | 53:bef06d5e827d | 49 | RoboClaw roboclaw(ADR, 460800, PA_11, PA_12); |
IceTeam | 53:bef06d5e827d | 50 | Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw); |
IceTeam | 53:bef06d5e827d | 51 | |
IceTeam | 53:bef06d5e827d | 52 | int SIMON_i = 0, SIMON_state = 0, SCouleur = VERT, SStart = 0, SSchema = 1; |
IceTeam | 53:bef06d5e827d | 53 | bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false, SGauche = false, SDevant = false, SDroite = false; |
IceTeam | 53:bef06d5e827d | 54 | |
IceTeam | 53:bef06d5e827d | 55 | void init(void); |
IceTeam | 53:bef06d5e827d | 56 | void update_main(void); |
IceTeam | 53:bef06d5e827d | 57 | |
IceTeam | 53:bef06d5e827d | 58 | /* Debut du programme */ |
IceTeam | 53:bef06d5e827d | 59 | int main(void) |
IceTeam | 53:bef06d5e827d | 60 | { |
IceTeam | 53:bef06d5e827d | 61 | logger.printf("Depart homologation !\n\r"); |
IceTeam | 53:bef06d5e827d | 62 | homologation(); |
IceTeam | 53:bef06d5e827d | 63 | /*drapeau = 0; |
IceTeam | 53:bef06d5e827d | 64 | init(); |
IceTeam | 53:bef06d5e827d | 65 | |
IceTeam | 53:bef06d5e827d | 66 | map m(&odo); |
IceTeam | 53:bef06d5e827d | 67 | m.addObs(obsCarr (1250, 1000, 220, 220)); |
IceTeam | 53:bef06d5e827d | 68 | m.addObs(obsCarr (1500, 750, 220, 220)); |
IceTeam | 53:bef06d5e827d | 69 | m.addObs(obsCarr (1500, 1250, 220, 220)); |
IceTeam | 53:bef06d5e827d | 70 | |
IceTeam | 53:bef06d5e827d | 71 | m.Execute(1000,1000); |
IceTeam | 53:bef06d5e827d | 72 | m.Execute(1500,1000); |
IceTeam | 53:bef06d5e827d | 73 | m.Execute(1500,1500); |
IceTeam | 53:bef06d5e827d | 74 | m.Execute(110,1000); |
IceTeam | 53:bef06d5e827d | 75 | |
IceTeam | 53:bef06d5e827d | 76 | odo.GotoThet(0); |
IceTeam | 53:bef06d5e827d | 77 | roboclaw.ForwardM1(0); |
IceTeam | 53:bef06d5e827d | 78 | roboclaw.ForwardM2(0); |
IceTeam | 53:bef06d5e827d | 79 | logger.printf ("Chemin Fini !"); |
IceTeam | 53:bef06d5e827d | 80 | |
IceTeam | 53:bef06d5e827d | 81 | while(1);*/ |
IceTeam | 53:bef06d5e827d | 82 | } |
IceTeam | 53:bef06d5e827d | 83 | |
IceTeam | 53:bef06d5e827d | 84 | void init(void) |
IceTeam | 53:bef06d5e827d | 85 | { |
IceTeam | 53:bef06d5e827d | 86 | logger.baud(9600); |
IceTeam | 53:bef06d5e827d | 87 | logger.printf("Hello from main !\n\r"); |
IceTeam | 53:bef06d5e827d | 88 | |
IceTeam | 53:bef06d5e827d | 89 | init_interrupt(); |
IceTeam | 53:bef06d5e827d | 90 | goHome(); |
IceTeam | 53:bef06d5e827d | 91 | |
IceTeam | 53:bef06d5e827d | 92 | SCouleur = VERT; |
IceTeam | 53:bef06d5e827d | 93 | LEDV = 1; |
IceTeam | 53:bef06d5e827d | 94 | LEDR = 0; |
IceTeam | 53:bef06d5e827d | 95 | |
IceTeam | 53:bef06d5e827d | 96 | odo.setPos(110, 1000, 0); |
IceTeam | 53:bef06d5e827d | 97 | roboclaw.ResetEnc(); |
IceTeam | 53:bef06d5e827d | 98 | roboclaw.ForwardM1(0); |
IceTeam | 53:bef06d5e827d | 99 | roboclaw.ForwardM2(0); |
IceTeam | 53:bef06d5e827d | 100 | wait_ms(500); |
IceTeam | 53:bef06d5e827d | 101 | while(1); |
IceTeam | 53:bef06d5e827d | 102 | //depart(); |
IceTeam | 53:bef06d5e827d | 103 | init_interrupt(); |
IceTeam | 53:bef06d5e827d | 104 | wait_ms(100); |
IceTeam | 53:bef06d5e827d | 105 | while(START==0); |
IceTeam | 53:bef06d5e827d | 106 | logger.printf("End init\n\r"); |
IceTeam | 53:bef06d5e827d | 107 | } |
IceTeam | 53:bef06d5e827d | 108 | |
IceTeam | 53:bef06d5e827d | 109 | void update_main(void) |
IceTeam | 53:bef06d5e827d | 110 | { |
IceTeam | 53:bef06d5e827d | 111 | odo.update_odo(); |
IceTeam | 53:bef06d5e827d | 112 | checkAround(); |
IceTeam | 53:bef06d5e827d | 113 | } |