-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55ed9bc
commit 033fc5e
Showing
2 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,36 @@ | ||
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 | ||
|
||
sys.path.append('../../../plays_py/scripts/utils/') | ||
sys.path.insert(0, '../../../navigation_py/scripts/navigation/src') | ||
sys.path.insert(0, '../../../navigation_py/scripts/navigation') | ||
def debug(param, state, bot_id): | ||
botPos = Vector2D(state.homePos[bot_id].x, state.homePos[bot_id].y) | ||
ballPos = Vector2D(state.ballPos.x, state.ballPos.y) | ||
print '#'*50 | ||
print 'In sTurnToAngle' | ||
print 'Current bot pos: {}, {}'.format(state.homePos[bot_id].x, state.homePos[bot_id].y) | ||
print 'Target alignment: {}'.format(param.TurnToAngleP.finalSlope) | ||
print 'Bot Orientation: {}'.format(state.homePos[bot_id].theta) | ||
print '#'*50 | ||
|
||
from utils.geometry import * | ||
from utils.config import * | ||
def execute(param, state, bot_id,pub, dribbler=False): | ||
finalSlope = param.TurnToAngleP.finalslope # Yet to be defined | ||
ballPos = Vector2D(int(state.ballPos.x),int(state.ballPos.y)) | ||
botPos = Vector2D(int(state.homePos[bot_id].x),int(state.homePos[bot_id].y)) | ||
obj=Vector2D() | ||
|
||
turnAngleLeft = obj.normalizeAngle(finalSlope - state.homePos[bot_id].theta); # Angle left to turn | ||
|
||
omega = 3*turnAngleLeft * MAX_BOT_OMEGA/(2*math.pi); # Speedup turn | ||
if(omega < 1.43*MIN_BOT_OMEGA and omega > -1.43*MIN_BOT_OMEGA): # This is a rare used skill so believe in Accuracy more than speed. Hence reducing minimum Omega | ||
if(omega < 0): omega = -1.43*MIN_BOT_OMEGA | ||
else: omega = 1.43*MIN_BOT_OMEGA | ||
debug(param,state,bot_id) | ||
finalSlope = param.TurnToAngleP.finalSlope # Yet to be defined | ||
ballPos = Vector2D(int(state.ballPos.x),int(state.ballPos.y)) | ||
botPos = Vector2D(int(state.homePos[bot_id].x),int(state.homePos[bot_id].y)) | ||
obj=Vector2D() | ||
|
||
turnAngleLeft = obj.normalizeAngle(finalSlope - state.homePos[bot_id].theta); # Angle left to turn | ||
|
||
omega = 3*turnAngleLeft * MAX_BOT_OMEGA/(2*math.pi); # Speedup turn | ||
if(omega < 1.43*MIN_BOT_OMEGA and omega > -1.43*MIN_BOT_OMEGA): # This is a rare used skill so believe in Accuracy more than speed. Hence reducing minimum Omega | ||
if(omega < 0): omega = -1.43*MIN_BOT_OMEGA | ||
else: omega = 1.43*MIN_BOT_OMEGA | ||
|
||
dist = ballPos.dist(botPos) | ||
if(dist < DRIBBLER_BALL_THRESH): | ||
skill_node.send_command(pub, state.isteamyellow, bot_id, 0, 0, omega, 0,True) | ||
else: | ||
skill_node.send_command(pub, state.isteamyellow, bot_id, 0, 0, omega, 0,False) | ||
dist = ballPos.dist(botPos) | ||
if(dist < DRIBBLER_BALL_THRESH): | ||
skill_node.send_command(pub, state.isteamyellow, bot_id, 0, 0, omega, 0,True) | ||
else: | ||
skill_node.send_command(pub, state.isteamyellow, bot_id, 0, 0, omega, 0,False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters