ARES
/
Timer
Time is good
Fork of Robot2016_2-0 by
deplacement.cpp@89:46730de0d013, 2016-05-06 (annotated)
- Committer:
- IceTeam
- Date:
- Fri May 06 11:54:27 2016 +0000
- Revision:
- 89:46730de0d013
- Parent:
- 88:e4de39dd3e2e
- Child:
- 90:78d2c1527c95
Rajout de GotoThet - Attention il y a un petit saut au d?but
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 | 88:e4de39dd3e2e | 36 | if (signe == GAUCHE) { |
IceTeam | 88:e4de39dd3e2e | 37 | //roboclaw.SpeedAccelM1(accel_angle, vitesse_angle); |
IceTeam | 88:e4de39dd3e2e | 38 | //roboclaw.SpeedAccelM2(accel_angle, -vitesse_angle); |
IceTeam | 88:e4de39dd3e2e | 39 | roboclaw.SpeedM1(vitesse_angle); |
IceTeam | 88:e4de39dd3e2e | 40 | roboclaw.SpeedM2(-vitesse_angle); |
IceTeam | 86:0c5e9ac3d8d8 | 41 | } |
IceTeam | 88:e4de39dd3e2e | 42 | if (signe == DROITE) { |
IceTeam | 88:e4de39dd3e2e | 43 | roboclaw.SpeedAccelM1(accel_angle, -vitesse_angle); |
IceTeam | 88:e4de39dd3e2e | 44 | roboclaw.SpeedAccelM2(accel_angle, vitesse_angle); |
IceTeam | 86:0c5e9ac3d8d8 | 45 | } |
IceTeam | 86:0c5e9ac3d8d8 | 46 | |
IceTeam | 86:0c5e9ac3d8d8 | 47 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 48 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 49 | |
IceTeam | 86:0c5e9ac3d8d8 | 50 | while (t.read() < timer) { |
IceTeam | 86:0c5e9ac3d8d8 | 51 | if (Ravance != 1) { |
IceTeam | 86:0c5e9ac3d8d8 | 52 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 53 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 54 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 55 | while (Ravance != 1); |
IceTeam | 86:0c5e9ac3d8d8 | 56 | t.start(); |
IceTeam | 86:0c5e9ac3d8d8 | 57 | } |
IceTeam | 86:0c5e9ac3d8d8 | 58 | if (signe < 0) { |
IceTeam | 86:0c5e9ac3d8d8 | 59 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 60 | roboclaw.SpeedAccelM2(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 61 | } |
IceTeam | 86:0c5e9ac3d8d8 | 62 | else { |
IceTeam | 86:0c5e9ac3d8d8 | 63 | roboclaw.SpeedAccelM1(-accel_dista, -vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 64 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 86:0c5e9ac3d8d8 | 65 | } |
IceTeam | 86:0c5e9ac3d8d8 | 66 | } |
IceTeam | 86:0c5e9ac3d8d8 | 67 | |
IceTeam | 86:0c5e9ac3d8d8 | 68 | roboclaw.ForwardM1(0); |
IceTeam | 86:0c5e9ac3d8d8 | 69 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 70 | |
IceTeam | 86:0c5e9ac3d8d8 | 71 | t.stop(); |
IceTeam | 86:0c5e9ac3d8d8 | 72 | t.reset(); |
IceTeam | 86:0c5e9ac3d8d8 | 73 | |
IceTeam | 86:0c5e9ac3d8d8 | 74 | wait(waiting_time); |
IceTeam | 88:e4de39dd3e2e | 75 | } |
IceTeam | 88:e4de39dd3e2e | 76 | |
IceTeam | 88:e4de39dd3e2e | 77 | void GotoArr(float timer) { |
IceTeam | 88:e4de39dd3e2e | 78 | Timer t; |
IceTeam | 88:e4de39dd3e2e | 79 | |
IceTeam | 88:e4de39dd3e2e | 80 | roboclaw.SpeedAccelM1(accel_dista, -vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 81 | roboclaw.SpeedAccelM2(accel_dista, -vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 82 | |
IceTeam | 88:e4de39dd3e2e | 83 | t.reset(); |
IceTeam | 88:e4de39dd3e2e | 84 | t.start(); |
IceTeam | 88:e4de39dd3e2e | 85 | |
IceTeam | 88:e4de39dd3e2e | 86 | while (t.read() < timer) { |
IceTeam | 88:e4de39dd3e2e | 87 | if (Ravance != 1) { |
IceTeam | 88:e4de39dd3e2e | 88 | roboclaw.ForwardM1(0); |
IceTeam | 88:e4de39dd3e2e | 89 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 90 | t.stop(); |
IceTeam | 88:e4de39dd3e2e | 91 | while (Ravance != 1); |
IceTeam | 88:e4de39dd3e2e | 92 | roboclaw.SpeedAccelM1(accel_dista, vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 93 | roboclaw.SpeedAccelM2(accel_dista, vitesse_dista); |
IceTeam | 88:e4de39dd3e2e | 94 | t.start(); |
IceTeam | 88:e4de39dd3e2e | 95 | } |
IceTeam | 88:e4de39dd3e2e | 96 | } |
IceTeam | 88:e4de39dd3e2e | 97 | |
IceTeam | 88:e4de39dd3e2e | 98 | roboclaw.ForwardM1(0); |
IceTeam | 88:e4de39dd3e2e | 99 | roboclaw.ForwardM2(0); |
IceTeam | 88:e4de39dd3e2e | 100 | |
IceTeam | 88:e4de39dd3e2e | 101 | t.stop(); |
IceTeam | 88:e4de39dd3e2e | 102 | t.reset(); |
IceTeam | 88:e4de39dd3e2e | 103 | |
IceTeam | 88:e4de39dd3e2e | 104 | wait(waiting_time); |
IceTeam | 89:46730de0d013 | 105 | } |
IceTeam | 89:46730de0d013 | 106 | |
IceTeam | 89:46730de0d013 | 107 | void GotoThet(double theta_) { |
IceTeam | 89:46730de0d013 | 108 | roboclaw.ResetEnc(); |
IceTeam | 89:46730de0d013 | 109 | float diameter_left = 61.7; |
IceTeam | 89:46730de0d013 | 110 | float diameter_right = 61.8; |
IceTeam | 89:46730de0d013 | 111 | int distance_ticks_left = -theta_*ENTRAXE/(2*(diameter_left*3.14159/4096)); |
IceTeam | 89:46730de0d013 | 112 | int distance_ticks_right = theta_*ENTRAXE/(2*(diameter_right*3.14159/4096)); |
IceTeam | 89:46730de0d013 | 113 | |
IceTeam | 89:46730de0d013 | 114 | if (theta_ < 0) |
IceTeam | 89:46730de0d013 | 115 | roboclaw.SpeedAccelDeccelPositionM1M2(-accel_angle, vitesse_angle, deccel_angle, distance_ticks_right, accel_angle, vitesse_angle, deccel_angle, distance_ticks_left, 1); |
IceTeam | 89:46730de0d013 | 116 | else |
IceTeam | 89:46730de0d013 | 117 | roboclaw.SpeedAccelDeccelPositionM1M2(-accel_angle, vitesse_angle, deccel_angle, distance_ticks_right, -accel_angle, vitesse_angle, deccel_angle, distance_ticks_left, 1); |
IceTeam | 89:46730de0d013 | 118 | |
IceTeam | 89:46730de0d013 | 119 | wait(10); |
IceTeam | 89:46730de0d013 | 120 | roboclaw.ForwardM1(0); |
IceTeam | 89:46730de0d013 | 121 | roboclaw.ForwardM2(0); |
IceTeam | 86:0c5e9ac3d8d8 | 122 | } |