Skip to content
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

Defending added with minor fixes in util.functions #65

Open
wants to merge 2 commits into
base: fsm
Choose a base branch
from
Open

Defending added with minor fixes in util.functions #65

wants to merge 2 commits into from

Conversation

kushal2000
Copy link
Contributor

Three new files added :

  1. Defending.py : Controls top and bottom defenders via multiprocessing.
  2. Top.py : Code for the defender which stays on top.
  3. Bottom.py : Code for the defender which stays below.

Also minor bugs fixed in utils.functions

@thebhatman
Copy link
Member

Since there have been recent commits and Merges in fsm branch, there are merge conflicts. Resolve them.

@@ -94,8 +94,8 @@ def intersection_with_circle(self, circle):

# CHECK ----> SLOPE
def intersection_with_line(self, line2):
if not isinstance(line, line2):
raise ValueError("Expected Line instance, got %s" %type(line2).__name__)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this error handling is commented out?? If this is because of syntax error, isinstance(line2, Line) will be the correct syntax.

x = point.x - (3.5 * BOT_RADIUS) * (math.cos(theta))
y = point.y - (3.5 * BOT_RADIUS) * (math.sin(theta))
x = point.x - (1*BOT_RADIUS) * (math.cos(theta))
y = point.y - (1*BOT_RADIUS) * (math.sin(theta))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is bot able to reach the point returned by this function without colliding with ball?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He's using the getPointBehindBall, during intercept state, where defender is supposed to be ready to kick and clear the ball, I guess. Hence the small radius. But yeah we might have to increase it, if required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function can also be used to find a point by the attacker to kick towards the goal. Now if bot is in between the region of ball and goal post, attacker needs to cross the ball hence a point at sufficient distance is required otherwise path planner replans the path at every instant assuming ball as an obstacle

def getPointBehindTheBall(point, theta):
x = point.x - (1*BOT_RADIUS) * (math.cos(theta))
y = point.y - (1*BOT_RADIUS) * (math.sin(theta))
return Vector2D(int(x), int(y))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove duplicate code

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, a merge with fsm branch to get this branch updated will fix this.



import memcache
shared = memcache.Client(['127.0.0.1:11211'],debug=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unwanted import statements and memcache if not required

@saurabhkgp21
Copy link
Member

creating two files of defender for different positions isn't a good way to do this. You should create a class for Defender and pass arguments to place it at different position

if dist(awayPos,getPointBehindTheBall(ball,math.pi))/MAX_BOT_SPEED<opp_time:
opp_time=dist(awayPos,getPointBehindTheBall(ball,math.pi))/MAX_BOT_SPEED
our_time=dist(self.kub.state.homePos[2],getPointBehindTheBall(ball,0))/MAX_BOT_SPEED
if our_time > dist(self.kub.state.homePos[1],getPointBehindTheBall(ball,0))/MAX_BOT_SPEED:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldnt hardcode BotID like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants