Robot secondaire

Dependencies:   RoboClaw mbed StepperMotor

Fork of RoboClaw by Simon Emarre

Committer:
sype
Date:
Thu Apr 28 08:24:02 2016 +0000
Revision:
49:5e2f7323f280
Parent:
47:be4eebf40568
Parent:
48:03da1aead032
Child:
51:1056dd73a748
Child:
52:98f8a6ccb6ae
On monte le moteur, on d?-commente certaines lignes et c'est parti baby !

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 48:03da1aead032 6 InterruptIn CAMP(PA_15);
sype 48:03da1aead032 7 InterruptIn START(PB_7);
sype 46:5658af4e5149 8 DigitalOut LEDR(PC_2);
sype 46:5658af4e5149 9 DigitalOut LEDV(PC_3);
sype 46:5658af4e5149 10
sype 10:ae3178aa94e9 11 InterruptIn mybutton(USER_BUTTON);
sype 10:ae3178aa94e9 12 DigitalIn button(USER_BUTTON);
sype 46:5658af4e5149 13
sype 46:5658af4e5149 14 DigitalIn ChannelA1(PA_1);
sype 46:5658af4e5149 15 DigitalIn ChannelB1(PA_0);
sype 46:5658af4e5149 16 DigitalIn ChannelA2(PA_5);
sype 46:5658af4e5149 17 DigitalIn ChannelB2(PA_6);
sype 46:5658af4e5149 18
sype 41:b5a2fbc20beb 19 DigitalOut bleu(PC_5);
sype 41:b5a2fbc20beb 20 DigitalOut blanc(PC_6);
sype 41:b5a2fbc20beb 21 DigitalOut rouge(PC_8);
sype 41:b5a2fbc20beb 22
sype 46:5658af4e5149 23 /* AX12 - non fonctionnels, je pense que le souci vient de la bibliothèque car la trame n'est pas correcte (analyseur logique) */
sype 48:03da1aead032 24 //AX12 left_hand(PA_9, PA_10, 4, 250000);
sype 48:03da1aead032 25 //AX12 right_hand(PA_9, PA_10, 1, 250000);
sype 41:b5a2fbc20beb 26
sype 41:b5a2fbc20beb 27 /* Sharp */
sype 41:b5a2fbc20beb 28 AnalogIn capt1(PA_4);
sype 41:b5a2fbc20beb 29 AnalogIn capt2(PB_0);
sype 41:b5a2fbc20beb 30 AnalogIn capt3(PC_1);
sype 41:b5a2fbc20beb 31 AnalogIn capt4(PC_0);
sype 41:b5a2fbc20beb 32
sype 41:b5a2fbc20beb 33 /* Moteurs pas à pas */
sype 46:5658af4e5149 34 Stepper RMot(NC, PA_8, PC_7);
sype 46:5658af4e5149 35 Stepper ZMot(NC, PB_4, PB_10);
sype 46:5658af4e5149 36 Stepper LMot(NC, PB_5, PB_3);
sype 41:b5a2fbc20beb 37 /* Fins de course */
sype 41:b5a2fbc20beb 38 InterruptIn EndR(PB_15);
sype 41:b5a2fbc20beb 39 InterruptIn EndZ(PB_14);
sype 41:b5a2fbc20beb 40 InterruptIn EndL(PB_13);
sype 41:b5a2fbc20beb 41
sype 0:ad9600df4a70 42 Ticker ticker;
IceTeam 47:be4eebf40568 43 //Serial logger(USBTX, USBRX);
IceTeam 47:be4eebf40568 44 Serial logger(PA_9, PA_10);
sype 46:5658af4e5149 45 RoboClaw roboclaw(ADR, 460800, PA_11, PA_12);
IceTeam 39:309f38d1e49c 46 Odometry odo(61.7, 61.8, ENTRAXE, 4096, roboclaw);
sype 10:ae3178aa94e9 47
sype 48:03da1aead032 48 int SIMON_i = 0, SIMON_state = 0, SCouleur = 1, SStart = 0;
sype 46:5658af4e5149 49 bool SIMON_EL = false, SIMON_EZ = false, SIMON_ER = false;
sype 0:ad9600df4a70 50
sype 2:abdf8c6823a1 51 void init(void);
sype 46:5658af4e5149 52 void update_main(void);
sype 0:ad9600df4a70 53
sype 43:d5aaff7d2bec 54 /* Debut du programme */
sype 0:ad9600df4a70 55 int main(void)
sype 10:ae3178aa94e9 56 {
IceTeam 47:be4eebf40568 57 init();
IceTeam 47:be4eebf40568 58
IceTeam 47:be4eebf40568 59 /*map m(&odo);
IceTeam 47:be4eebf40568 60 m.addObs(obsCarr (1250, 1000, 220, 220));
IceTeam 47:be4eebf40568 61 m.addObs(obsCarr (1500, 750, 220, 220));
IceTeam 47:be4eebf40568 62 m.addObs(obsCarr (1500, 1250, 220, 220));
IceTeam 47:be4eebf40568 63
IceTeam 47:be4eebf40568 64 m.Execute(1000,1000);
IceTeam 47:be4eebf40568 65 m.Execute(1500,1000);
IceTeam 47:be4eebf40568 66 m.Execute(1500,1500);
IceTeam 47:be4eebf40568 67 m.Execute(110,1000);
IceTeam 47:be4eebf40568 68
IceTeam 47:be4eebf40568 69 odo.GotoThet(0);
sype 49:5e2f7323f280 70 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 71 roboclaw.ForwardM2(0);
IceTeam 47:be4eebf40568 72
IceTeam 47:be4eebf40568 73 logger.printf ("Chemin Fini !");*/
sype 48:03da1aead032 74 while(1);
sype 2:abdf8c6823a1 75 }
sype 2:abdf8c6823a1 76
sype 2:abdf8c6823a1 77 void init(void)
sype 0:ad9600df4a70 78 {
sype 37:da3a2c781672 79 logger.baud(9600);
sype 37:da3a2c781672 80 logger.printf("Hello from main !\n\r");
sype 49:5e2f7323f280 81
IceTeam 47:be4eebf40568 82 bleu = 1, blanc = 1, rouge = 1;
sype 49:5e2f7323f280 83
sype 49:5e2f7323f280 84 odo.setPos(110, 1000, 0);
sype 49:5e2f7323f280 85
sype 46:5658af4e5149 86 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 87 roboclaw.ForwardM2(0);
sype 10:ae3178aa94e9 88 wait_ms(500);
sype 49:5e2f7323f280 89
sype 44:b1fd7489369f 90 bleu = 0, blanc = 0, rouge = 0;
sype 10:ae3178aa94e9 91
sype 48:03da1aead032 92 while(SStart==0);
sype 44:b1fd7489369f 93
sype 46:5658af4e5149 94 roboclaw.ResetEnc();
sype 44:b1fd7489369f 95 init_interrupt();
sype 41:b5a2fbc20beb 96 wait_ms(100);
sype 49:5e2f7323f280 97
IceTeam 39:309f38d1e49c 98 logger.printf("End init\n\r");
sype 0:ad9600df4a70 99 }
sype 46:5658af4e5149 100
sype 46:5658af4e5149 101 void update_main(void)
sype 46:5658af4e5149 102 {
sype 49:5e2f7323f280 103 odo.update_odo();
sype 46:5658af4e5149 104 //checkAround();
sype 46:5658af4e5149 105 }