Romain Ame
/
Timer71pt
Fork de Timer après le match à 61 points
Fork of Timer by
Diff: main.cpp
- Revision:
- 37:da3a2c781672
- Parent:
- 36:2d7357a385bc
- Child:
- 39:309f38d1e49c
- Child:
- 40:ca4dd3faffa8
--- a/main.cpp Sun Jan 31 16:11:32 2016 +0000 +++ b/main.cpp Sat Feb 06 10:11:28 2016 +0000 @@ -12,10 +12,8 @@ DigitalOut led(LED1); Ticker ticker; //Serial pc(USBTX, USBRX); -Serial pc(PA_9, PA_10); Serial logger (PA_9, PA_10); RoboClaw roboclaw(460800, PA_11, PA_12); -/* Changement entraxe : 252->253 */ Odometry odo(63.2, 63.3, ENTRAXE, 4096, roboclaw); int i = 0; @@ -28,12 +26,13 @@ /** Debut du programme */ int main(void) { - double angle_v = 2*PI/5; + init(); + /*double angle_v = 2*PI/5; double distance_v = 200.0; std::vector<SimplePoint> path; Map map; - init(); + //Construction des obstacles map.build(); @@ -60,31 +59,57 @@ //odo.GotoThet(PI); odo.GotoThet(0); //odo.TestEntraxe(3); - /* - odo.GotoXYT(1000, 1000, 0); - odo.GotoXYT(0, 1000, PI); - odo.GotoThet(0);*/ //odo.GotoThet(-PI/2); wait(2000); - //odo.GotoXYT(2250,500,0); - while(1); + //odo.GotoXYT(2250,500,0);*/ + while(1) + { + while(logger.readable()) + { + char c = logger.getc(); + if(c=='z') + { + roboclaw.SpeedAccelM1M2(ADR, accel_angle, speed_angle, accel_angle, speed_angle); + } + else if(c == 's') + { + roboclaw.ForwardM1(ADR, 0); + roboclaw.ForwardM2(ADR, 0); + } + else if(c == 'd') + { + roboclaw.SpeedAccelM1M2(ADR, accel_angle, -speed_angle, accel_angle, speed_angle); + } + else if(c == 'q') + { + roboclaw.SpeedAccelM1M2(ADR, accel_angle, speed_angle, accel_angle, -speed_angle); + } + else if(c == 'x') + { + roboclaw.SpeedAccelM1M2(ADR, accel_angle, -speed_angle, accel_angle, -speed_angle); + } + } + roboclaw.ForwardM1(ADR, 0); + roboclaw.ForwardM2(ADR, 0); + } } void init(void) { - pc.baud(9600); - pc.printf("Hello from main !\n\r"); + roboclaw.ForwardM1(ADR, 0); + roboclaw.ForwardM2(ADR, 0); + logger.baud(9600); + logger.printf("Hello from main !\n\r"); wait_ms(500); odo.setPos(0, 1000, 0); - roboclaw.ForwardM1(ADR, 0); - roboclaw.ForwardM2(ADR, 0); - + while(button); wait(1); mybutton.fall(&pressed); - mybutton.rise(&unpressed); + mybutton.rise(&unpr + essed); ticker.attach_us(&update_main,dt); // 100 Hz }