ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
deplacement.cpp@96:1e91cac784fe, 2016-05-06 (annotated)
- Committer:
- IceTeam
- Date:
- Fri May 06 21:21:49 2016 +0000
- Revision:
- 96:1e91cac784fe
- Parent:
- 94:86b9bd6d5c28
- Child:
- 97:42167cfeb8d7
Coucou vers ordi de simon
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 | 93:c0b040954eac | 16 | wait_ms(1); |
IceTeam | 86:0c5e9ac3d8d8 | 17 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 18 | while (Ravance != 1); |
IceTeam | 93:c0b040954eac | 19 | wait_ms(1); |
IceTeam | 86:0c5e9ac3d8d8 | 20 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 21 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 22 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 23 | } |
IceTeam | 86:0c5e9ac3d8d8 | 24 | } |
IceTeam | 86:0c5e9ac3d8d8 | 25 | |
IceTeam | 86:0c5e9ac3d8d8 | 26 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 27 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 28 | |
IceTeam | 86:0c5e9ac3d8d8 | 29 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 30 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 31 | |
IceTeam | 86:0c5e9ac3d8d8 | 32 | wait(waiting_time); |
IceTeam | 86:0c5e9ac3d8d8 | 33 | } |
IceTeam | 86:0c5e9ac3d8d8 | 34 | |
IceTeam | 88:e4de39dd3e2e | 35 | void GotoArr(float timer) { |
IceTeam | 88:e4de39dd3e2e | 36 | Timer t; |
IceTeam | 88:e4de39dd3e2e | 37 | |
IceTeam | 88:e4de39dd3e2e | 38 | roboclaw.SpeedAccelM1(accel_dista, -vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 39 | roboclaw.SpeedAccelM2(accel_dista, -vitesse_dista); |
IceTeam | 93:c0b040954eac | 40 | wait_ms(1); |
IceTeam | 88:e4de39dd3e2e | 41 | |
IceTeam | 88:e4de39dd3e2e | 42 | t.reset(); |
IceTeam | 88:e4de39dd3e2e | 43 | t.start(); |
IceTeam | 88:e4de39dd3e2e | 44 | |
IceTeam | 88:e4de39dd3e2e | 45 | while (t.read() < timer) { |
IceTeam | 88:e4de39dd3e2e | 46 | if (Ravance != 1) { |
IceTeam | 88:e4de39dd3e2e | 47 | roboclaw.ForwardM1(0); |
IceTeam | 93:c0b040954eac | 48 | wait_ms(1); |
IceTeam | 88:e4de39dd3e2e | 49 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 50 | t.stop(); |
IceTeam | 88:e4de39dd3e2e | 51 | while (Ravance != 1); |
IceTeam | 93:c0b040954eac | 52 | wait_ms(1); |
IceTeam | 93:c0b040954eac | 53 | roboclaw.SpeedAccelM1(accel_dista, -vitesse_dista); |
IceTeam | 93:c0b040954eac | 54 | roboclaw.SpeedAccelM2(accel_dista, -vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 55 | t.start(); |
IceTeam | 88:e4de39dd3e2e | 56 | } |
IceTeam | 88:e4de39dd3e2e | 57 | } |
IceTeam | 88:e4de39dd3e2e | 58 | |
IceTeam | 88:e4de39dd3e2e | 59 | roboclaw.ForwardM1(0); |
IceTeam | 93:c0b040954eac | 60 | wait_ms(1); |
IceTeam | 88:e4de39dd3e2e | 61 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 62 | |
IceTeam | 88:e4de39dd3e2e | 63 | t.stop(); |
IceTeam | 88:e4de39dd3e2e | 64 | t.reset(); |
IceTeam | 88:e4de39dd3e2e | 65 | |
IceTeam | 88:e4de39dd3e2e | 66 | wait(waiting_time); |
IceTeam | 89:46730de0d013 | 67 | } |
IceTeam | 89:46730de0d013 | 68 | |
IceTeam | 89:46730de0d013 | 69 | void GotoThet(double theta_) { |
IceTeam | 89:46730de0d013 | 70 | roboclaw.ResetEnc(); |
IceTeam | 90:78d2c1527c95 | 71 | wait_ms(10); |
IceTeam | 96:1e91cac784fe | 72 | int distance_ticks_left = -theta_*ENTRAXE/(2*(DIAMETRE_ROUE_GAUCHE*3.14159/4096)); |
IceTeam | 96:1e91cac784fe | 73 | int distance_ticks_right = theta_*ENTRAXE/(2*(DIAMETRE_ROUE_DROITE*3.14159/4096)); |
IceTeam | 89:46730de0d013 | 74 | |
IceTeam | 89:46730de0d013 | 75 | if (theta_ < 0) |
IceTeam | 94:86b9bd6d5c28 | 76 | roboclaw.SpeedAccelDeccelPositionM1M2(accel_angle, vitesse_angle, deccel_angle, distance_ticks_right, accel_angle, vitesse_angle, deccel_angle, distance_ticks_left, 1); |
IceTeam | 89:46730de0d013 | 77 | else |
IceTeam | 94:86b9bd6d5c28 | 78 | roboclaw.SpeedAccelDeccelPositionM1M2(accel_angle, vitesse_angle, deccel_angle, distance_ticks_right, accel_angle, vitesse_angle, deccel_angle, distance_ticks_left, 1); |
IceTeam | 89:46730de0d013 | 79 | |
IceTeam | 94:86b9bd6d5c28 | 80 | wait(3); |
IceTeam | 89:46730de0d013 | 81 | roboclaw.ForwardM1(0); |
IceTeam | 89:46730de0d013 | 82 | roboclaw.ForwardM2(0); |
IceTeam | 94:86b9bd6d5c28 | 83 | } |
IceTeam | 94:86b9bd6d5c28 | 84 | |
IceTeam | 96:1e91cac784fe | 85 | void GotoDistPos(double distance) |
IceTeam | 94:86b9bd6d5c28 | 86 | { |
IceTeam | 96:1e91cac784fe | 87 | roboclaw.ResetEnc(); |
IceTeam | 96:1e91cac784fe | 88 | wait_ms(1); |
IceTeam | 96:1e91cac784fe | 89 | int32_t distance_ticks_left = distance/((DIAMETRE_ROUE_GAUCHE*3.14156)/4096); |
IceTeam | 96:1e91cac784fe | 90 | int32_t distance_ticks_right = distance/((DIAMETRE_ROUE_GAUCHE*3.14156)/4096); |
IceTeam | 94:86b9bd6d5c28 | 91 | |
IceTeam | 96:1e91cac784fe | 92 | roboclaw.SpeedAccelDeccelPositionM1M2(accel_dista, vitesse_dista, deccel_dista, distance_ticks_right, accel_dista, vitesse_dista, deccel_dista, distance_ticks_left, 1); |
IceTeam | 96:1e91cac784fe | 93 | |
IceTeam | 96:1e91cac784fe | 94 | while(abs(roboclaw.ReadEncM1() - distance_ticks_right) > 20 && abs(roboclaw.ReadEncM2() - distance_ticks_left) > 20); |
IceTeam | 94:86b9bd6d5c28 | 95 | |
IceTeam | 96:1e91cac784fe | 96 | wait(0.1); |
IceTeam | 86:0c5e9ac3d8d8 | 97 | } |