Robot secondaire

Dependencies:   RoboClaw mbed StepperMotor

Fork of RoboClaw by Simon Emarre

Committer:
IceTeam
Date:
Tue May 03 12:37:31 2016 +0000
Revision:
52:98f8a6ccb6ae
Parent:
49:5e2f7323f280
Child:
53:bef06d5e827d
Debut ajout obstacle;

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 52:98f8a6ccb6ae 59 int cote = MAP_RIGHTSIDE;
IceTeam 47:be4eebf40568 60 /*map m(&odo);
IceTeam 52:98f8a6ccb6ae 61 m.Build(cote);
IceTeam 47:be4eebf40568 62 m.Execute(1000,1000);
IceTeam 47:be4eebf40568 63 m.Execute(1500,1000);
IceTeam 47:be4eebf40568 64 m.Execute(1500,1500);
IceTeam 47:be4eebf40568 65 m.Execute(110,1000);
IceTeam 47:be4eebf40568 66
IceTeam 47:be4eebf40568 67 odo.GotoThet(0);
sype 49:5e2f7323f280 68 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 69 roboclaw.ForwardM2(0);
IceTeam 47:be4eebf40568 70
IceTeam 47:be4eebf40568 71 logger.printf ("Chemin Fini !");*/
sype 48:03da1aead032 72 while(1);
sype 2:abdf8c6823a1 73 }
sype 2:abdf8c6823a1 74
sype 2:abdf8c6823a1 75 void init(void)
sype 0:ad9600df4a70 76 {
sype 37:da3a2c781672 77 logger.baud(9600);
sype 37:da3a2c781672 78 logger.printf("Hello from main !\n\r");
sype 49:5e2f7323f280 79
IceTeam 47:be4eebf40568 80 bleu = 1, blanc = 1, rouge = 1;
sype 49:5e2f7323f280 81
sype 49:5e2f7323f280 82 odo.setPos(110, 1000, 0);
sype 49:5e2f7323f280 83
sype 46:5658af4e5149 84 roboclaw.ForwardM1(0);
sype 49:5e2f7323f280 85 roboclaw.ForwardM2(0);
sype 10:ae3178aa94e9 86 wait_ms(500);
sype 49:5e2f7323f280 87
sype 44:b1fd7489369f 88 bleu = 0, blanc = 0, rouge = 0;
sype 10:ae3178aa94e9 89
sype 48:03da1aead032 90 while(SStart==0);
sype 44:b1fd7489369f 91
sype 46:5658af4e5149 92 roboclaw.ResetEnc();
sype 44:b1fd7489369f 93 init_interrupt();
sype 41:b5a2fbc20beb 94 wait_ms(100);
sype 49:5e2f7323f280 95
IceTeam 39:309f38d1e49c 96 logger.printf("End init\n\r");
sype 0:ad9600df4a70 97 }
sype 46:5658af4e5149 98
sype 46:5658af4e5149 99 void update_main(void)
sype 46:5658af4e5149 100 {
sype 49:5e2f7323f280 101 odo.update_odo();
sype 46:5658af4e5149 102 //checkAround();
sype 46:5658af4e5149 103 }