Fork de Timer après le match à 61 points

Dependencies:   RoboClaw mbed

Fork of Timer by ARES

Committer:
IceTeam
Date:
Thu May 05 13:17:00 2016 +0000
Revision:
78:c28bdbf29b6e
Parent:
77:f19cc7f81f2a
Child:
79:b11b50108ae5
Des trucs qui compilent

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sype 41:b5a2fbc20beb 1 #include "func.h"
IceTeam 47:be4eebf40568 2 #include "map.h"
sype 0:ad9600df4a70 3
sype 41:b5a2fbc20beb 4 /* Déclaration des différents éléments de l'IHM */
sype 46:5658af4e5149 5
sype 51:1056dd73a748 6 DigitalIn CAMP(PA_15);
sype 51:1056dd73a748 7 DigitalIn START(PB_7);
sype 46:5658af4e5149 8 DigitalOut LEDR(PC_2);
sype 46:5658af4e5149 9 DigitalOut LEDV(PC_3);
sype 46:5658af4e5149 10
sype 51:1056dd73a748 11 BusOut drapeau(PC_8, PC_6, PC_5);
sype 51:1056dd73a748 12
sype 10:ae3178aa94e9 13 InterruptIn mybutton(USER_BUTTON);
sype 10:ae3178aa94e9 14 DigitalIn button(USER_BUTTON);
sype 46:5658af4e5149 15
sype 46:5658af4e5149 16 DigitalIn ChannelA1(PA_1);
sype 46:5658af4e5149 17 DigitalIn ChannelB1(PA_0);
sype 46:5658af4e5149 18 DigitalIn ChannelA2(PA_5);
sype 46:5658af4e5149 19 DigitalIn ChannelB2(PA_6);
sype 46: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 51:1056dd73a748 35 Stepper RMot(NC, PA_8, PC_7, 4);
sype 51:1056dd73a748 36 Stepper ZMot(NC, PB_4, PB_10, 5);
sype 51: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 51:1056dd73a748 42 DigitalIn EnR(PB_15);
sype 51:1056dd73a748 43 DigitalIn EnZ(PB_14);
sype 51:1056dd73a748 44 DigitalIn EnL(PB_13);
sype 41:b5a2fbc20beb 45
sype 0:ad9600df4a70 46 Ticker ticker;
IceTeam 47:be4eebf40568 47 //Serial logger(USBTX, USBRX);
sype 51:1056dd73a748 48 Serial logger(PA_2, PA_3);
sype 46: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 51:1056dd73a748 52 int SIMON_i = 0, SIMON_state = 0, SCouleur = VERT, SStart = 0, SSchema = 1;
IceTeam 78:c28bdbf29b6e 53 bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false;
IceTeam 78:c28bdbf29b6e 54 int SGauche = false, SDevant = false, SDroite = false;
IceTeam 78:c28bdbf29b6e 55 bool Sharps_actives = false;
IceTeam 78:c28bdbf29b6e 56 bool SHomologation = false;
IceTeam 78:c28bdbf29b6e 57
IceTeam 78:c28bdbf29b6e 58 float seuils[3] = {0.25, 0.40, 0.25};
sype 0:ad9600df4a70 59
sype 2:abdf8c6823a1 60 void init(void);
sype 46:5658af4e5149 61 void update_main(void);
sype 0:ad9600df4a70 62
sype 43:d5aaff7d2bec 63 /* Debut du programme */
sype 0:ad9600df4a70 64 int main(void)
sype 10:ae3178aa94e9 65 {
sype 77:f19cc7f81f2a 66 /*logger.printf("Depart homologation !\n\r");
sype 77:f19cc7f81f2a 67 LEDV = 1;
sype 77:f19cc7f81f2a 68 LEDR = 0;
sype 77:f19cc7f81f2a 69 odo.setPos(110, 1000, 0);
sype 77:f19cc7f81f2a 70 roboclaw.ResetEnc();
sype 77:f19cc7f81f2a 71 roboclaw.ForwardM1(0);
sype 77:f19cc7f81f2a 72 roboclaw.ForwardM2(0);
sype 77:f19cc7f81f2a 73 wait_ms(100);
sype 77:f19cc7f81f2a 74 while(START==0);
sype 77:f19cc7f81f2a 75 odo.GotoXY(1000, 1000);*/
IceTeam 78:c28bdbf29b6e 76
IceTeam 78:c28bdbf29b6e 77 roboclaw.ResetEnc();
IceTeam 78:c28bdbf29b6e 78 roboclaw.ForwardM1(0);
IceTeam 78:c28bdbf29b6e 79 roboclaw.ForwardM2(0);
IceTeam 78:c28bdbf29b6e 80 logger.printf("Depart");
sype 77:f19cc7f81f2a 81 odo.setPos(110,850,0);
IceTeam 78:c28bdbf29b6e 82
sype 77:f19cc7f81f2a 83 init_interrupt();
IceTeam 78:c28bdbf29b6e 84
sype 77:f19cc7f81f2a 85 while(START==0);
IceTeam 78:c28bdbf29b6e 86
IceTeam 78:c28bdbf29b6e 87 logger.printf("Depart");
sype 77:f19cc7f81f2a 88 odo.GotoXY(450,850);
IceTeam 78:c28bdbf29b6e 89 logger.printf("Premier point atteint");
sype 77:f19cc7f81f2a 90 odo.GotoXY(1050,1100);
IceTeam 78:c28bdbf29b6e 91 Sharps_actives = true;
IceTeam 78:c28bdbf29b6e 92 logger.printf("Second point atteint");
IceTeam 78:c28bdbf29b6e 93 odo.GotoXY(400,850);
IceTeam 78:c28bdbf29b6e 94 logger.printf("Troisieme point atteint");
IceTeam 78:c28bdbf29b6e 95 odo.GotoXY(400,1000);
IceTeam 78:c28bdbf29b6e 96
sype 77:f19cc7f81f2a 97 LEDV = 1;
sype 77:f19cc7f81f2a 98 while(1);
sype 77:f19cc7f81f2a 99 //homologation();
sype 51:1056dd73a748 100 /*drapeau = 0;
sype 51:1056dd73a748 101 init();
sype 51:1056dd73a748 102
sype 51:1056dd73a748 103 map m(&odo);
IceTeam 47:be4eebf40568 104 m.addObs(obsCarr (1250, 1000, 220, 220));
IceTeam 47:be4eebf40568 105 m.addObs(obsCarr (1500, 750, 220, 220));
IceTeam 47:be4eebf40568 106 m.addObs(obsCarr (1500, 1250, 220, 220));
sype 51:1056dd73a748 107
IceTeam 47:be4eebf40568 108 m.Execute(1000,1000);
IceTeam 47:be4eebf40568 109 m.Execute(1500,1000);
IceTeam 47:be4eebf40568 110 m.Execute(1500,1500);
IceTeam 47:be4eebf40568 111 m.Execute(110,1000);
sype 51:1056dd73a748 112
IceTeam 47:be4eebf40568 113 odo.GotoThet(0);
sype 49:5e2f7323f280 114 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 115 roboclaw.ForwardM2(0);
sype 51:1056dd73a748 116 logger.printf ("Chemin Fini !");
sype 51:1056dd73a748 117
sype 51:1056dd73a748 118 while(1);*/
sype 2:abdf8c6823a1 119 }
sype 2:abdf8c6823a1 120
sype 2:abdf8c6823a1 121 void init(void)
sype 0:ad9600df4a70 122 {
sype 37:da3a2c781672 123 logger.baud(9600);
sype 37:da3a2c781672 124 logger.printf("Hello from main !\n\r");
sype 51:1056dd73a748 125
sype 51:1056dd73a748 126 init_interrupt();
sype 51:1056dd73a748 127
sype 51:1056dd73a748 128 SCouleur = VERT;
sype 51:1056dd73a748 129 LEDV = 1;
sype 51:1056dd73a748 130 LEDR = 0;
sype 51:1056dd73a748 131
sype 49:5e2f7323f280 132 odo.setPos(110, 1000, 0);
sype 51:1056dd73a748 133 roboclaw.ResetEnc();
sype 46:5658af4e5149 134 roboclaw.ForwardM1(0);
sype 51:1056dd73a748 135 roboclaw.ForwardM2(0);
sype 10:ae3178aa94e9 136 wait_ms(500);
sype 51:1056dd73a748 137 while(1);
IceTeam 78:c28bdbf29b6e 138 /*depart();
sype 44:b1fd7489369f 139 init_interrupt();
sype 41:b5a2fbc20beb 140 wait_ms(100);
sype 51:1056dd73a748 141 while(START==0);
IceTeam 78:c28bdbf29b6e 142 logger.printf("End init\n\r");*/
sype 0:ad9600df4a70 143 }
sype 46:5658af4e5149 144
sype 46:5658af4e5149 145 void update_main(void)
sype 46:5658af4e5149 146 {
sype 49:5e2f7323f280 147 odo.update_odo();
IceTeam 78:c28bdbf29b6e 148
sype 51:1056dd73a748 149 checkAround();
IceTeam 78:c28bdbf29b6e 150
IceTeam 78:c28bdbf29b6e 151 if (Sharps_actives && max(SGauche,SDevant,SDroite)>0 && odo.getCurrentStep() != STEP_T)
IceTeam 78:c28bdbf29b6e 152 {
IceTeam 78:c28bdbf29b6e 153 odo.pause();
IceTeam 78:c28bdbf29b6e 154 }
IceTeam 78:c28bdbf29b6e 155 /*else
IceTeam 78:c28bdbf29b6e 156 {
IceTeam 78:c28bdbf29b6e 157 odo.resume();
IceTeam 78:c28bdbf29b6e 158 }*/
sype 46:5658af4e5149 159 }