-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsKickToPoint.py
60 lines (48 loc) · 2.19 KB
/
sKickToPoint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import skill_node
import math
import sys
from utils.config import *
from utils.geometry import *
from navigation_py.wrapperpy import *
from navigation_py.obstacle import Obstacle
import skills_union
import sGoToBall
import sGoToPoint
import sTurnToPoint
def execute(param, state, bot_id, pub):
# print "in kicktopoint"
botPos=Vector2D(int(state.homePos[bot_id].x), int(state.homePos[bot_id].y))
ballPos=Vector2D(int(state.ballPos.x), int(state.ballPos.y))
destPoint=Vector2D(int(param.KickToPointP.x), int(param.KickToPointP.y))
ob = Vector2D()
finalSlope = destPoint.angle(botPos)
turnAngleLeft = ob.normalizeAngle(finalSlope - state.homePos[bot_id].theta) #Angle left to turn
ballBotAngle = ob.normalizeAngle(ballPos.angle(botPos)-state.homePos[bot_id].theta)
dist = ballPos.dist(botPos)
if dist > BOT_BALL_THRESH+10 :
print("before kick (GoToBall) dist remaining : ",dist-BOT_BALL_THRESH, " : ", BOT_BALL_THRESH)
param.GoToPointP.x = state.ballPos.x
param.GoToPointP.y = state.ballPos.y
param.GoToPointP.finalSlope = ballPos.angle(state.homePos[bot_id])
sGoToPoint.execute(param, state, bot_id, pub)
return
# print("After gotoball")
if ballBotAngle > SATISFIABLE_THETA/2 :
sParam = skills_union.SParam()
sParam.TurnToPointP.x = ballPos.x
sParam.TurnToPointP.y = ballPos.y
sParam.TurnToPointP.max_omega = MAX_BOT_OMEGA
print("before kick (TurnToBall) angle remaining : ",ballBotAngle)
sTurnToPoint.execute(sParam, state, bot_id, pub)
return
if math.fabs(turnAngleLeft) > SATISFIABLE_THETA/2 : # SATISFIABLE_THETA in config file
sParam = skills_union.SParam()
sParam.TurnToPointP.x = destPoint.x
sParam.TurnToPointP.y = destPoint.y
sParam.TurnToPointP.max_omega = MAX_BOT_OMEGA
print("before kick (Turn) angle remaining : ",turnAngleLeft)
sTurnToPoint.execute(sParam, state, bot_id, pub)
return
# print("after turn")
print ("____KICK____ DIST :",dist," ANGLE : ",turnAngleLeft)
skill_node.send_command(pub, state.isteamyellow, bot_id ,0, 0, 0, param.KickToPointP.power, False)