-
Notifications
You must be signed in to change notification settings - Fork 2
Add sGoalKeeping #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Working
Are you sure you want to change the base?
Add sGoalKeeping #17
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import skill_node | ||
| import math | ||
|
|
||
| def execute(param, state, botID): | ||
| pCopy = copy(param) | ||
| ballInitialpos=Vector2D() | ||
| botPos=Vector2D(int(state.homePos[botID].x), int(state.homePos[botID].y)) | ||
| ballPos=Vector2D(int(state.ballPos.x), int(state.ballPos.y)) | ||
| ballFinalpos=Vector2D(); botDestination=Vector2D(); point=Vector2D(); nextWP=Vector2D(); nextNWP=Vector2D() | ||
| ''' | ||
| if(execute.framecount == 1): | ||
| ballInitialpos = ballPos; | ||
| execute.framecount+=1 | ||
| return | ||
| elif ((framecount % 5) == 0): | ||
| execute.framecount = 1 | ||
| ballFinalpos = ballPos | ||
| else: | ||
| execute.framecount+=1 | ||
| return | ||
| ''' | ||
|
|
||
| # if bot moves parallel to x axis (y is constant) | ||
| botDestination_y = state.homePos[botID].y | ||
| botDestination_x = ((botDestination.y - ballFinalpos.y) * (ballFinalpos.x - ballInitialpos.x) / (ballFinalpos.y - ballInitialpos.y)) + ballFinalpos.x | ||
|
|
||
| # if bot moves parallel to y axis (x is constant) | ||
| ''' | ||
| botDestination_x = state.homePos[botID].x | ||
| botDestination_y = (ballFinalpos.y - ballInitialpos.y)/(ballFinalpos.x - ballInitialpos.x)*(botDestination.x - ballFinalpos.x) + ballFinalpos.y | ||
| ''' | ||
|
|
||
| pCopy.GoalKeepingP.x = botDestination.x | ||
| pCopy.GoalKeepingP.y = botDestination.y | ||
| pCopy.GoalKeepingP.finalslope = 0 | ||
| # goToPointFast(pCopy) # Python equivalent not found | ||
|
|
||
| point.x = pCopy.GoalKeepingP.x; | ||
| point.y = pCopy.GoalKeepingP.y; | ||
|
|
||
| obs=[] | ||
| o=obstacle() | ||
|
|
||
|
|
||
| for i,bot in enumerate(state.homePos): | ||
| if state.homeDetected[i]: | ||
| obs.append(Obstacle(bot.x, bot.y, 0, 0, 2*BOT_RADIUS)) | ||
|
|
||
| for i in xrange (len(state.homeDetected), len(state.homeDetected) + len(state.awayDetected)): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this part needs some discussion.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is what you are looking for : for j in range(0,len(state.awayDetected)):
if state.awayDetected[j]:
o = Obstacle()
o.x=state.awayPos[j].x
o.y=state.awayPos[j].y
o.radius=3.3*BOT_RADIUS
obs.push_back(o) |
||
| o.x = state.awayPos[i - len(state.homeDetected)].x; | ||
| o.y = state.awayPos[i - len(state.homeDetected)].y; | ||
| o.radius = 2 * BOT_RADIUS; | ||
| obs.append(o); | ||
|
|
||
|
|
||
| pathplanner = MergeSCurve() | ||
| pathplanner.plan(botPos,pointPos,nextWP,nextNWP,obs,len(obs),botID,True) | ||
|
|
||
| angle = nextWP.angle(botPos) | ||
| dist = point.dist(botPos) | ||
| theta = (state.homePos[botID].theta - angle) | ||
| rot_theta = (state.homePos[botID].theta - pCopy.GoalKeepingP.finalslope) * (180 / math.pi); | ||
| if(rot_theta > 0): | ||
| if(rot_theta < DRIBBLER_BALL_ANGLE_RANGE): | ||
| v_t = 0 | ||
| if(rot_theta < 45): | ||
| v_t = -rot_theta / 10 | ||
| else: | ||
| v_t = -4.5 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the indentation here |
||
| profileFactor = MAX_BOT_SPEED | ||
| if(profileFactor < MIN_BOT_SPEED): | ||
| profileFactor = MIN_BOT_SPEED | ||
| v_x = profileFactor * math.sin(theta) | ||
| v_y = profileFactor * math.cos(theta) | ||
|
|
||
| if(dist < BOT_BALL_THRESH): | ||
| skill_node.send_command(state.isteamyellow, botID, 0, 0, 0, 0, False) | ||
| else: | ||
| skill_node.send_command(state.isteamyellow, botID, v_x, v_y, v_t, 0, False) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not treat bot_id itself as obstacle. Change the condition from
to