1
-
2
1
print "In test GoToPoint"
3
2
from kubs import kubs , cmd_node
4
3
from velocity .run import *
4
+ import velocity
5
5
import rospy ,sys ,os
6
6
import math
7
7
import time
@@ -73,7 +73,6 @@ def GUI_Callback(data):
73
73
74
74
75
75
76
-
77
76
def function (id_ ,state ):
78
77
kub = kubs .kubs (id_ ,state ,pub )
79
78
kub .update_state (state )
@@ -90,15 +89,12 @@ def function(id_,state):
90
89
g_fsm .spin ()
91
90
#
92
91
93
-
94
-
95
-
96
92
def kp_callback (data ):
97
93
global st , planned , ramp_rampt , ramp_dnt , ramp_upt , case , tnow
98
94
99
95
ballpos = data .ballPos
100
- theta = angle_diff (target , ballpos )
101
- go_at = getPointBehindTheBall (ballpos , theta , 2 )
96
+ theta = angle_diff (ballpos , target ) #Point1: ballpos; Point2: target
97
+ go_at = getPointBehindTheBall (ballpos , theta , - 2 ) #Modify getPoint*Behind*TheBall late on**. Factor should be negative.
102
98
103
99
print (radian_2_deg (theta ))
104
100
print (go_at .x )
@@ -108,21 +104,19 @@ def kp_callback(data):
108
104
t = t .secs + 1.0 * t .nsecs / pow (10 ,9 )
109
105
print (" t - start = " ,t - start_time )
110
106
[vx , vy , vw , REPLANNED ] = Get_Vel (start_time , t , BOT_ID , go_at , data .homePos , data .awayPos , True , 1.2 )
111
- #vx, vy, vw, replanned
107
+ #vx, vy, vw, replanned
112
108
print ("------------------- REPLANNED = " ,REPLANNED )
113
109
if (REPLANNED ):
114
110
reset ()
115
111
116
112
print ("vx = " ,vx )
117
113
print ("vy = " ,vy )
118
-
119
- mvx = vx
120
- mvy = vy
121
114
122
115
# print("kubs_id = ",kub.kubs_id)
123
116
124
117
curPos = Vector2D (int (data .homePos [BOT_ID ].x ),int (data .homePos [BOT_ID ].y ))
125
118
#if vicinity_points(go_at, curPos, 4) == False:
119
+ d = distance_ (curPos ,go_at )
126
120
try :
127
121
kub .move (vx , vy )
128
122
print (vw )
@@ -133,39 +127,50 @@ def kp_callback(data):
133
127
print ("In except" ,e )
134
128
pass
135
129
print (dist (go_at , curPos ))
136
-
137
- if vx == 0 and vy == 0 :
138
-
139
130
131
+
132
+ #READY TO TAKE STANCE
133
+ if vx == 0 and vy == 0 and d < 1.2 * BOT_BALL_THRESH :
134
+
140
135
print (data .homePos [BOT_ID ].theta )
141
- print (theta )
136
+ print ("Target Alignment : " , theta )
142
137
totalAngle = theta
143
138
MAX_w = (MAX_BOT_OMEGA + MIN_BOT_OMEGA )/ 1.2
144
- # theta_left = float(homePos[kub_id].theta-totalAngle)
145
- theta_lft = normalize_angle (normalize_angle (data .homePos [BOT_ID ].theta )- totalAngle )* - 1.0 + 3.1412
146
-
147
- if abs (theta_lft )< ROTATION_FACTOR / 100 :
139
+ MIN_w = (MIN_BOT_OMEGA )
140
+
141
+ # theta2 = totalAngle :-- target angular alignment ; theta1 = current_bot_theta; New x-axis: Bot_theta_line
142
+ # rotating standard axes
143
+ deltheta = totalAngle - normalize_angle (data .homePos [BOT_ID ].theta )
144
+ modtheta = min (abs (deltheta ),abs ((2 * math .pi )- deltheta )) #shortest turn
145
+ sign = (normalize_angle (deltheta ))/ (abs (normalize_angle (deltheta )))
146
+
147
+ print "Remaining angle: " ,modtheta ," " ,sign
148
+
149
+ theta_lft = modtheta * sign
150
+
151
+ if abs (theta_lft )< ROTATION_FACTOR / 10 :
148
152
vw = 0.0
149
153
READY_TO_KICK = True
150
154
else :
151
155
READY_TO_KICK = False
152
- vw = (theta_lft / 2 * math .pi )* MAX_w
153
-
154
- if abs (vw )< 1 * MIN_BOT_OMEGA and READY_TO_KICK == False :
155
- vw = 1 * MIN_BOT_OMEGA * (1 if vw > 0 else - 1 )
156
+ vw = 3.0 * (theta_lft )/ (math .pi )* MAX_w
157
+ #vw = (theta_lft/2*math.pi)*MAX_w
156
158
159
+ if abs (vw )< 1 * MIN_w and READY_TO_KICK == False :
160
+ vw = 1 * MIN_w * (1 if vw > 0 else - 1 )
161
+
162
+ if abs (vw ) > MAX_w and READY_TO_KICK == False :
163
+ vw = (vw / abs (vw ))* MAX_w
157
164
158
165
if vw != 0 :
159
166
print ("TURNING" )
167
+ #print("vw Hoon Main =",vw)
168
+ print ("BOT THETA: " ,data .homePos [BOT_ID ].theta )
169
+ print "\n Angle Remaining : " ,theta_lft
160
170
else :
161
- print ("DONE" )
171
+ print ("DONE !! " )
162
172
163
- mvw = vw
164
-
165
-
166
-
167
- print "Omega Return" ,vw
168
- print "TRY: " ,mvw
173
+ print "Omega Return: " ,vw
169
174
print READY_TO_KICK
170
175
print "___________________________________________________________________"
171
176
kub .reset ()
@@ -180,7 +185,7 @@ def kp_callback(data):
180
185
181
186
182
187
if __name__ == "__main__" :
183
- global start_time , st , planned , case , mvw
188
+ global start_time , st , planned , case
184
189
case = - 1
185
190
st = None
186
191
planned = False
@@ -199,15 +204,17 @@ def kp_callback(data):
199
204
200
205
sub2 = rospy .Subscriber ('/gui_params' , point_SF , GUI_Callback , queue_size = 1000 )
201
206
202
- print ("Ho gya!!" )
207
+ print ("Ho gya align !!" )
203
208
rospy .spin ()
204
209
205
210
sub1 .unregister ()
206
211
sub2 .unregister ()
207
- print "AB MAIN KARUNGAAA -------- KICKKK !!!"
212
+ print "AB MAIN KARUNGA -------- KICKKK !!!"
208
213
209
214
command = "python KickP.py %s %s %s" % (BOT_ID ,target .x ,target .y )
210
- print (command )
215
+ print ("______________________________________________________________" )
216
+ print ("/n" ,command ,"/n" )
217
+ print ("______________________________________________________________\n " )
211
218
os .system (command )
212
219
213
220
0 commit comments