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