coucou

Dependencies:   RoboClaw mbed

Fork of Robot2016_2-0 by ARES

Committer:
IceTeam
Date:
Thu May 05 05:49:41 2016 +0200
Revision:
74:07cdad6e861a
Parent:
53:bef06d5e827d
Fusion

Who changed what in which revision?

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