Fork de Timer après le match à 61 points

Dependencies:   RoboClaw mbed

Fork of Timer by ARES

Committer:
Jagang
Date:
Thu May 05 03:47:05 2016 +0000
Revision:
71:5590dbe8393a
Parent:
58:02dc8328975a
Child:
74:07cdad6e861a
Uodate Controlleur, ajout des mouvement d et c, ajout des AX12

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
Jagang 58:02dc8328975a 4 #include "ControlleurPince.h"
Jagang 58:02dc8328975a 5
sype 41:b5a2fbc20beb 6 /* Déclaration des différents éléments de l'IHM */
sype 46:5658af4e5149 7
sype 51:1056dd73a748 8 DigitalIn CAMP(PA_15);
sype 51:1056dd73a748 9 DigitalIn START(PB_7);
sype 46:5658af4e5149 10 DigitalOut LEDR(PC_2);
sype 46:5658af4e5149 11 DigitalOut LEDV(PC_3);
sype 46:5658af4e5149 12
sype 51:1056dd73a748 13 BusOut drapeau(PC_8, PC_6, PC_5);
sype 51:1056dd73a748 14
sype 10:ae3178aa94e9 15 InterruptIn mybutton(USER_BUTTON);
sype 10:ae3178aa94e9 16 DigitalIn button(USER_BUTTON);
sype 46:5658af4e5149 17
sype 46:5658af4e5149 18 DigitalIn ChannelA1(PA_1);
sype 46:5658af4e5149 19 DigitalIn ChannelB1(PA_0);
sype 46:5658af4e5149 20 DigitalIn ChannelA2(PA_5);
sype 46:5658af4e5149 21 DigitalIn ChannelB2(PA_6);
sype 46:5658af4e5149 22
sype 41:b5a2fbc20beb 23 DigitalOut bleu(PC_5);
sype 41:b5a2fbc20beb 24 DigitalOut blanc(PC_6);
sype 41:b5a2fbc20beb 25 DigitalOut rouge(PC_8);
sype 41:b5a2fbc20beb 26
Jagang 71:5590dbe8393a 27 AX12 left_hand(PA_9, PA_10, 3, 250000);
Jagang 71:5590dbe8393a 28 AX12 right_hand(PA_9, PA_10, 2, 250000);
sype 41:b5a2fbc20beb 29
sype 41:b5a2fbc20beb 30 /* Sharp */
sype 41:b5a2fbc20beb 31 AnalogIn capt1(PA_4);
sype 41:b5a2fbc20beb 32 AnalogIn capt2(PB_0);
sype 41:b5a2fbc20beb 33 AnalogIn capt3(PC_1);
sype 41:b5a2fbc20beb 34 AnalogIn capt4(PC_0);
sype 41:b5a2fbc20beb 35
sype 41:b5a2fbc20beb 36 /* Moteurs pas à pas */
Jagang 58:02dc8328975a 37 Stepper RMot(NC, PA_8, PC_7, PB_15, 4);
Jagang 58:02dc8328975a 38 Stepper ZMot(NC, PB_4, PB_10, PB_14, 5);
Jagang 58:02dc8328975a 39 Stepper LMot(NC, PB_5, PB_3, PB_13, 4);
sype 41:b5a2fbc20beb 40 /* Fins de course */
sype 41:b5a2fbc20beb 41 InterruptIn EndR(PB_15);
sype 41:b5a2fbc20beb 42 InterruptIn EndZ(PB_14);
sype 41:b5a2fbc20beb 43 InterruptIn EndL(PB_13);
sype 51:1056dd73a748 44 DigitalIn EnR(PB_15);
sype 51:1056dd73a748 45 DigitalIn EnZ(PB_14);
sype 51:1056dd73a748 46 DigitalIn EnL(PB_13);
sype 41:b5a2fbc20beb 47
Jagang 71:5590dbe8393a 48 ControlleurPince controlleurPince(RMot, ZMot, LMot, EnR, EnZ, EnL, left_hand, right_hand);
Jagang 58:02dc8328975a 49
sype 0:ad9600df4a70 50 Ticker ticker;
IceTeam 47:be4eebf40568 51 //Serial logger(USBTX, USBRX);
sype 51:1056dd73a748 52 Serial logger(PA_2, PA_3);
sype 46:5658af4e5149 53 RoboClaw roboclaw(ADR, 460800, PA_11, PA_12);
IceTeam 39:309f38d1e49c 54 Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw);
sype 10:ae3178aa94e9 55
sype 51:1056dd73a748 56 int SIMON_i = 0, SIMON_state = 0, SCouleur = VERT, SStart = 0, SSchema = 1;
sype 51:1056dd73a748 57 bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false, SGauche = false, SDevant = false, SDroite = false;
sype 0:ad9600df4a70 58
sype 2:abdf8c6823a1 59 void init(void);
sype 46:5658af4e5149 60 void update_main(void);
sype 0:ad9600df4a70 61
sype 43:d5aaff7d2bec 62 /* Debut du programme */
sype 0:ad9600df4a70 63 int main(void)
sype 10:ae3178aa94e9 64 {
Jagang 71:5590dbe8393a 65 roboclaw.ForwardM1(0);
Jagang 71:5590dbe8393a 66 roboclaw.ForwardM2(0);
Jagang 71:5590dbe8393a 67
Jagang 58:02dc8328975a 68 //logger.printf("Depart homologation !\n\r");
Jagang 58:02dc8328975a 69 //homologation();
Jagang 71:5590dbe8393a 70
Jagang 71:5590dbe8393a 71 controlleurPince.init();
Jagang 58:02dc8328975a 72 controlleurPince.home();
Jagang 58:02dc8328975a 73 wait(1);
Jagang 71:5590dbe8393a 74 controlleurPince.open();
Jagang 71:5590dbe8393a 75 logger.printf("z 10 \r\n");
Jagang 71:5590dbe8393a 76 controlleurPince.setPos(10,-1);
Jagang 71:5590dbe8393a 77 wait(1);
Jagang 71:5590dbe8393a 78 logger.printf("z 20 \r\n");
Jagang 71:5590dbe8393a 79 controlleurPince.setPos(20,-1);
Jagang 71:5590dbe8393a 80 wait(1);
Jagang 71:5590dbe8393a 81 controlleurPince.close();
Jagang 71:5590dbe8393a 82 logger.printf("d 30 \r\n");
Jagang 71:5590dbe8393a 83 controlleurPince.setPos(-1,30);
Jagang 58:02dc8328975a 84 wait(1);
Jagang 71:5590dbe8393a 85 logger.printf("c 50 \r\n");
Jagang 71:5590dbe8393a 86 controlleurPince.setPos(-1,-1,50);
Jagang 71:5590dbe8393a 87 wait(1);
Jagang 71:5590dbe8393a 88 logger.printf("d 0 \r\n");
Jagang 71:5590dbe8393a 89 controlleurPince.setPos(-1,0);
Jagang 71:5590dbe8393a 90
Jagang 71:5590dbe8393a 91 while(1);
Jagang 71:5590dbe8393a 92
Jagang 71:5590dbe8393a 93
Jagang 71:5590dbe8393a 94 /*wait(1);
Jagang 71:5590dbe8393a 95 logger.printf("set pos 20 ...\n\r");
Jagang 58:02dc8328975a 96 controlleurPince.setPos(20.f,0.f,0.f);
Jagang 58:02dc8328975a 97 wait(1);
Jagang 71:5590dbe8393a 98 logger.printf("set pos 70 ...\n\r");
Jagang 58:02dc8328975a 99 controlleurPince.setPos(70.f,0.f,0.f);
Jagang 58:02dc8328975a 100 wait(1);
Jagang 71:5590dbe8393a 101 logger.printf("set pos 20 ...\n\r");
Jagang 58:02dc8328975a 102 controlleurPince.setPos(20.f,0.f,0.f);
Jagang 71:5590dbe8393a 103 logger.printf("Done ...\n\r");*/
IceTeam 54:be4ea8da9057 104
sype 51:1056dd73a748 105 /*drapeau = 0;
sype 51:1056dd73a748 106 init();
sype 51:1056dd73a748 107
sype 51:1056dd73a748 108 map m(&odo);
IceTeam 47:be4eebf40568 109 m.addObs(obsCarr (1250, 1000, 220, 220));
IceTeam 47:be4eebf40568 110 m.addObs(obsCarr (1500, 750, 220, 220));
IceTeam 47:be4eebf40568 111 m.addObs(obsCarr (1500, 1250, 220, 220));
sype 51:1056dd73a748 112
IceTeam 47:be4eebf40568 113 init();
IceTeam 47:be4eebf40568 114
IceTeam 52:98f8a6ccb6ae 115 int cote = MAP_RIGHTSIDE;
IceTeam 47:be4eebf40568 116 /*map m(&odo);
IceTeam 52:98f8a6ccb6ae 117 m.Build(cote);
IceTeam 47:be4eebf40568 118 m.Execute(1000,1000);
IceTeam 47:be4eebf40568 119 m.Execute(1500,1000);
IceTeam 47:be4eebf40568 120 m.Execute(1500,1500);
IceTeam 47:be4eebf40568 121 m.Execute(110,1000);
sype 51:1056dd73a748 122
IceTeam 47:be4eebf40568 123 odo.GotoThet(0);
sype 49:5e2f7323f280 124 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 125 roboclaw.ForwardM2(0);
sype 51:1056dd73a748 126 logger.printf ("Chemin Fini !");
sype 51:1056dd73a748 127
sype 51:1056dd73a748 128 while(1);*/
sype 2:abdf8c6823a1 129 }
sype 2:abdf8c6823a1 130
sype 2:abdf8c6823a1 131 void init(void)
sype 0:ad9600df4a70 132 {
sype 37:da3a2c781672 133 logger.baud(9600);
sype 37:da3a2c781672 134 logger.printf("Hello from main !\n\r");
sype 51:1056dd73a748 135
sype 51:1056dd73a748 136 init_interrupt();
sype 51:1056dd73a748 137 goHome();
sype 51:1056dd73a748 138
sype 51:1056dd73a748 139 SCouleur = VERT;
sype 51:1056dd73a748 140 LEDV = 1;
sype 51:1056dd73a748 141 LEDR = 0;
sype 51:1056dd73a748 142
sype 49:5e2f7323f280 143 odo.setPos(110, 1000, 0);
sype 51:1056dd73a748 144 roboclaw.ResetEnc();
sype 46:5658af4e5149 145 roboclaw.ForwardM1(0);
sype 51:1056dd73a748 146 roboclaw.ForwardM2(0);
sype 10:ae3178aa94e9 147 wait_ms(500);
sype 51:1056dd73a748 148 while(1);
sype 51:1056dd73a748 149 //depart();
sype 44:b1fd7489369f 150 init_interrupt();
sype 41:b5a2fbc20beb 151 wait_ms(100);
sype 51:1056dd73a748 152 while(START==0);
IceTeam 39:309f38d1e49c 153 logger.printf("End init\n\r");
sype 0:ad9600df4a70 154 }
sype 46:5658af4e5149 155
sype 46:5658af4e5149 156 void update_main(void)
sype 46:5658af4e5149 157 {
sype 49:5e2f7323f280 158 odo.update_odo();
sype 51:1056dd73a748 159 checkAround();
sype 46:5658af4e5149 160 }