ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
deplacement.cpp@86:0c5e9ac3d8d8, 2016-05-06 (annotated)
- Committer:
- IceTeam
- Date:
- Fri May 06 10:05:33 2016 +0200
- Revision:
- 86:0c5e9ac3d8d8
- Child:
- 88:e4de39dd3e2e
Gestion du Timeout pour la funny action
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IceTeam | 86:0c5e9ac3d8d8 | 1 | #include "entete.h" |
IceTeam | 86:0c5e9ac3d8d8 | 2 | |
IceTeam | 86:0c5e9ac3d8d8 | 3 | void GotoDist(float timer) { |
IceTeam | 86:0c5e9ac3d8d8 | 4 | Timer t; |
IceTeam | 86:0c5e9ac3d8d8 | 5 | |
IceTeam | 86:0c5e9ac3d8d8 | 6 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 7 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 8 | |
IceTeam | 86:0c5e9ac3d8d8 | 9 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 10 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 11 | |
IceTeam | 86:0c5e9ac3d8d8 | 12 | while (t.read() < timer) { |
IceTeam | 86:0c5e9ac3d8d8 | 13 | if (Ravance != 1) { |
IceTeam | 86:0c5e9ac3d8d8 | 14 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 15 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 16 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 17 | while (Ravance != 1); |
IceTeam | 86:0c5e9ac3d8d8 | 18 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 19 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 20 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 21 | } |
IceTeam | 86:0c5e9ac3d8d8 | 22 | } |
IceTeam | 86:0c5e9ac3d8d8 | 23 | |
IceTeam | 86:0c5e9ac3d8d8 | 24 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 25 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 26 | |
IceTeam | 86:0c5e9ac3d8d8 | 27 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 28 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 29 | |
IceTeam | 86:0c5e9ac3d8d8 | 30 | wait(waiting_time); |
IceTeam | 86:0c5e9ac3d8d8 | 31 | } |
IceTeam | 86:0c5e9ac3d8d8 | 32 | |
IceTeam | 86:0c5e9ac3d8d8 | 33 | void GotoThet (float timer, int signe) { |
IceTeam | 86:0c5e9ac3d8d8 | 34 | Timer t; |
IceTeam | 86:0c5e9ac3d8d8 | 35 | |
IceTeam | 86:0c5e9ac3d8d8 | 36 | if (signe < 0) { |
IceTeam | 86:0c5e9ac3d8d8 | 37 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 38 | roboclaw.SpeedAccelM2(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 39 | } |
IceTeam | 86:0c5e9ac3d8d8 | 40 | else { |
IceTeam | 86:0c5e9ac3d8d8 | 41 | roboclaw.SpeedAccelM1(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 42 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 43 | } |
IceTeam | 86:0c5e9ac3d8d8 | 44 | |
IceTeam | 86:0c5e9ac3d8d8 | 45 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 46 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 47 | |
IceTeam | 86:0c5e9ac3d8d8 | 48 | while (t.read() < timer) { |
IceTeam | 86:0c5e9ac3d8d8 | 49 | if (Ravance != 1) { |
IceTeam | 86:0c5e9ac3d8d8 | 50 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 51 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 52 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 53 | while (Ravance != 1); |
IceTeam | 86:0c5e9ac3d8d8 | 54 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 55 | } |
IceTeam | 86:0c5e9ac3d8d8 | 56 | if (signe < 0) { |
IceTeam | 86:0c5e9ac3d8d8 | 57 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 58 | roboclaw.SpeedAccelM2(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 59 | } |
IceTeam | 86:0c5e9ac3d8d8 | 60 | else { |
IceTeam | 86:0c5e9ac3d8d8 | 61 | roboclaw.SpeedAccelM1(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 62 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 63 | } |
IceTeam | 86:0c5e9ac3d8d8 | 64 | } |
IceTeam | 86:0c5e9ac3d8d8 | 65 | |
IceTeam | 86:0c5e9ac3d8d8 | 66 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 67 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 68 | |
IceTeam | 86:0c5e9ac3d8d8 | 69 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 70 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 71 | |
IceTeam | 86:0c5e9ac3d8d8 | 72 | wait(waiting_time); |
IceTeam | 86:0c5e9ac3d8d8 | 73 | } |