Romain Ame / Mbed 2 deprecated Robot2016_2-0_STATIC

Dependencies:   RoboClaw StepperMotor mbed

Fork of Robot2016_2-0 by ARES

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "func.h"
00002 #include "Map/map.h"
00003 
00004 #define ATTENTE 0
00005 #define GO 1
00006 #define STOP 2
00007 
00008 /* Déclaration des différents éléments de l'IHM */
00009 class S { 
00010 public:
00011     S () :  mybutton(USER_BUTTON), button(USER_BUTTON), led(LED1), bleu(PC_5), blanc(PC_6), rouge(PC_8)
00012             left_hand(PA_15, PB_7, 4, 250000), right_hand(PA_15, PB_7, 1, 250000),
00013             capt1(PA_4), capt2(PB_0), capt3(PC_1), capt4(PC_0),
00014             RMot(NC, PB_10, PA_8), ZMot(NC, PB_5, PB_4), LMot(NC, PB_3, PA_10),
00015             EndR(PB_15), EndZ(PB_14), EndL(PB_13),
00016             logger(PA_9, PA_10), roboclaw(460800, PA_11, PA_12), odo(61.7, 61.8, ENTRAXE, 4096, roboclaw) {
00017         
00018         i = 0;
00019         state = 0;
00020         EL = false;
00021         EZ = false
00022         ER = false;            
00023     }
00024             
00025     static InterruptIn mybutton;
00026     static DigitalIn button;
00027     static DigitalOut led;
00028     static DigitalOut bleu;
00029     static DigitalOut blanc;
00030     static DigitalOut rouge;
00031     
00032     /* AX12 */
00033     static AX12 left_hand;
00034     static AX12 right_hand;
00035     
00036     /* Sharp */
00037     static AnalogIn capt1;
00038     static AnalogIn capt2;
00039     static AnalogIn capt3;
00040     static AnalogIn capt4;
00041     
00042     /* Moteurs pas à pas */
00043     static Stepper RMot;
00044     static Stepper ZMot;
00045     static Stepper LMot;
00046     /* Fins de course */
00047     static InterruptIn EndR;
00048     static InterruptIn EndZ;
00049     static InterruptIn EndL;
00050     
00051     static Ticker ticker;
00052     
00053     //Serial logger(USBTX, USBRX);
00054     static Serial logger;
00055     static RoboClaw roboclaw;
00056     static Odometry odo;
00057     
00058     static int i;
00059     static state;
00060     static bool EL;
00061     static EZ;
00062     static ER;
00063 }    
00064 
00065 void init(void);
00066 
00067 /* Debut du programme */
00068 int main(void)
00069 {
00070     init();
00071     
00072     odo.setPos(110, 1000, 0);
00073     map m(&odo);
00074     m.addObs(obsCarr (1250, 1000, 220, 220));
00075     m.addObs(obsCarr (1500, 750, 220, 220));
00076     m.addObs(obsCarr (1500, 1250, 220, 220));
00077     
00078     m.Execute(1000,1000);
00079     m.Execute(1500,1000);
00080     m.Execute(1500,1500);
00081     m.Execute(110,1000);
00082     
00083     odo.GotoThet(0);
00084     
00085     while(1) JPO();
00086 }
00087 
00088 void init(void)
00089 {
00090     roboclaw.ForwardM1(ADR, 0);
00091     roboclaw.ForwardM2(ADR, 0);
00092     logger.baud(9600);
00093     logger.printf("Hello from main !\n\r");
00094     wait_ms(500);
00095     bleu = 1, blanc = 1, rouge = 1;
00096     wait_ms(1000);
00097     bleu = 0, blanc = 0, rouge = 0;
00098     
00099     while(S::button);
00100     wait(1);
00101     
00102     init_ax12();
00103     init_interrupt();
00104     wait_ms(100);
00105     logger.printf("End init\n\r");
00106 }