Voili voilou

Dependencies:   RoboClaw StepperMotor mbed

Fork of Robot2016_2-0 by ARES

Committer:
IceTeam
Date:
Wed Apr 20 13:13:37 2016 +0000
Revision:
46:8eae88c45a78
Parent:
45:b53ae54062c6
Mise en static;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sype 41:b5a2fbc20beb 1 #include "func.h"
IceTeam 46:8eae88c45a78 2 #include "Map/map.h"
sype 0:ad9600df4a70 3
sype 10:ae3178aa94e9 4 #define ATTENTE 0
sype 10:ae3178aa94e9 5 #define GO 1
sype 10:ae3178aa94e9 6 #define STOP 2
sype 0:ad9600df4a70 7
sype 41:b5a2fbc20beb 8 /* Déclaration des différents éléments de l'IHM */
IceTeam 46:8eae88c45a78 9 class S {
IceTeam 46:8eae88c45a78 10 public:
IceTeam 46:8eae88c45a78 11 S () : mybutton(USER_BUTTON), button(USER_BUTTON), led(LED1), bleu(PC_5), blanc(PC_6), rouge(PC_8)
IceTeam 46:8eae88c45a78 12 left_hand(PA_15, PB_7, 4, 250000), right_hand(PA_15, PB_7, 1, 250000),
IceTeam 46:8eae88c45a78 13 capt1(PA_4), capt2(PB_0), capt3(PC_1), capt4(PC_0),
IceTeam 46:8eae88c45a78 14 RMot(NC, PB_10, PA_8), ZMot(NC, PB_5, PB_4), LMot(NC, PB_3, PA_10),
IceTeam 46:8eae88c45a78 15 EndR(PB_15), EndZ(PB_14), EndL(PB_13),
IceTeam 46:8eae88c45a78 16 logger(PA_9, PA_10), roboclaw(460800, PA_11, PA_12), odo(61.7, 61.8, ENTRAXE, 4096, roboclaw) {
IceTeam 46:8eae88c45a78 17
IceTeam 46:8eae88c45a78 18 i = 0;
IceTeam 46:8eae88c45a78 19 state = 0;
IceTeam 46:8eae88c45a78 20 EL = false;
IceTeam 46:8eae88c45a78 21 EZ = false
IceTeam 46:8eae88c45a78 22 ER = false;
IceTeam 46:8eae88c45a78 23 }
IceTeam 46:8eae88c45a78 24
IceTeam 46:8eae88c45a78 25 static InterruptIn mybutton;
IceTeam 46:8eae88c45a78 26 static DigitalIn button;
IceTeam 46:8eae88c45a78 27 static DigitalOut led;
IceTeam 46:8eae88c45a78 28 static DigitalOut bleu;
IceTeam 46:8eae88c45a78 29 static DigitalOut blanc;
IceTeam 46:8eae88c45a78 30 static DigitalOut rouge;
IceTeam 46:8eae88c45a78 31
IceTeam 46:8eae88c45a78 32 /* AX12 */
IceTeam 46:8eae88c45a78 33 static AX12 left_hand;
IceTeam 46:8eae88c45a78 34 static AX12 right_hand;
IceTeam 46:8eae88c45a78 35
IceTeam 46:8eae88c45a78 36 /* Sharp */
IceTeam 46:8eae88c45a78 37 static AnalogIn capt1;
IceTeam 46:8eae88c45a78 38 static AnalogIn capt2;
IceTeam 46:8eae88c45a78 39 static AnalogIn capt3;
IceTeam 46:8eae88c45a78 40 static AnalogIn capt4;
IceTeam 46:8eae88c45a78 41
IceTeam 46:8eae88c45a78 42 /* Moteurs pas à pas */
IceTeam 46:8eae88c45a78 43 static Stepper RMot;
IceTeam 46:8eae88c45a78 44 static Stepper ZMot;
IceTeam 46:8eae88c45a78 45 static Stepper LMot;
IceTeam 46:8eae88c45a78 46 /* Fins de course */
IceTeam 46:8eae88c45a78 47 static InterruptIn EndR;
IceTeam 46:8eae88c45a78 48 static InterruptIn EndZ;
IceTeam 46:8eae88c45a78 49 static InterruptIn EndL;
IceTeam 46:8eae88c45a78 50
IceTeam 46:8eae88c45a78 51 static Ticker ticker;
IceTeam 46:8eae88c45a78 52
IceTeam 46:8eae88c45a78 53 //Serial logger(USBTX, USBRX);
IceTeam 46:8eae88c45a78 54 static Serial logger;
IceTeam 46:8eae88c45a78 55 static RoboClaw roboclaw;
IceTeam 46:8eae88c45a78 56 static Odometry odo;
IceTeam 46:8eae88c45a78 57
IceTeam 46:8eae88c45a78 58 static int i;
IceTeam 46:8eae88c45a78 59 static state;
IceTeam 46:8eae88c45a78 60 static bool EL;
IceTeam 46:8eae88c45a78 61 static EZ;
IceTeam 46:8eae88c45a78 62 static ER;
IceTeam 46:8eae88c45a78 63 }
sype 0:ad9600df4a70 64
sype 2:abdf8c6823a1 65 void init(void);
sype 0:ad9600df4a70 66
sype 43:d5aaff7d2bec 67 /* Debut du programme */
sype 0:ad9600df4a70 68 int main(void)
sype 10:ae3178aa94e9 69 {
sype 38:da3a2c781672 70 init();
IceTeam 46:8eae88c45a78 71
IceTeam 46:8eae88c45a78 72 odo.setPos(110, 1000, 0);
IceTeam 46:8eae88c45a78 73 map m(&odo);
IceTeam 46:8eae88c45a78 74 m.addObs(obsCarr (1250, 1000, 220, 220));
IceTeam 46:8eae88c45a78 75 m.addObs(obsCarr (1500, 750, 220, 220));
IceTeam 46:8eae88c45a78 76 m.addObs(obsCarr (1500, 1250, 220, 220));
IceTeam 46:8eae88c45a78 77
IceTeam 46:8eae88c45a78 78 m.Execute(1000,1000);
IceTeam 46:8eae88c45a78 79 m.Execute(1500,1000);
IceTeam 46:8eae88c45a78 80 m.Execute(1500,1500);
IceTeam 46:8eae88c45a78 81 m.Execute(110,1000);
IceTeam 46:8eae88c45a78 82
IceTeam 46:8eae88c45a78 83 odo.GotoThet(0);
IceTeam 46:8eae88c45a78 84
sype 44:b1fd7489369f 85 while(1) JPO();
sype 2:abdf8c6823a1 86 }
sype 2:abdf8c6823a1 87
sype 2:abdf8c6823a1 88 void init(void)
sype 0:ad9600df4a70 89 {
sype 38:da3a2c781672 90 roboclaw.ForwardM1(ADR, 0);
sype 38:da3a2c781672 91 roboclaw.ForwardM2(ADR, 0);
sype 38:da3a2c781672 92 logger.baud(9600);
sype 38:da3a2c781672 93 logger.printf("Hello from main !\n\r");
sype 10:ae3178aa94e9 94 wait_ms(500);
sype 44:b1fd7489369f 95 bleu = 1, blanc = 1, rouge = 1;
sype 41:b5a2fbc20beb 96 wait_ms(1000);
sype 44:b1fd7489369f 97 bleu = 0, blanc = 0, rouge = 0;
sype 10:ae3178aa94e9 98
IceTeam 46:8eae88c45a78 99 while(S::button);
sype 10:ae3178aa94e9 100 wait(1);
sype 44:b1fd7489369f 101
sype 44:b1fd7489369f 102 init_ax12();
sype 44:b1fd7489369f 103 init_interrupt();
sype 41:b5a2fbc20beb 104 wait_ms(100);
IceTeam 39:309f38d1e49c 105 logger.printf("End init\n\r");
sype 0:ad9600df4a70 106 }