Skip to content

Commit

Permalink
rollback midfielder
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkleal committed Oct 19, 2022
1 parent 672068d commit a84b9fb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion config_real_life.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"match" : {
"team_side": "left",
"team_color": "blue",
"team_color": "yellow",
"coach_name": "IRON_2022",
"category": "3v3",
"robot_ids": [
Expand Down
2 changes: 1 addition & 1 deletion controller/PID_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, robot, default_fps=60):
self.alpha_old = 0 # stores previous iteration alpha

# Max speeds for the robot
self.v_max = 150 # 40 # linear speed
self.v_max = 130 # 40 # linear speed
self.w_max = 550 # math.radians(7200) # angular speed rad/

self.v_min = 80
Expand Down
40 changes: 21 additions & 19 deletions strategy/iron2022/Midfielder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ def __init__(self, match, plot_field=False):
self.lwr_margin = 0.2
self.hgr_margin = 1.1

self.pushing_ball = False

self.def_x = 0.27
self.ga_hgr = 1
self.ga_lwr = .3
Expand Down Expand Up @@ -79,30 +81,30 @@ def decide(self):
ball = self.match.ball
ball_x, ball_y = ball.x, ball.y

if ball_x < .575 and ball_x > self.robot.x:
behaviour = self.push_ball
elif self.robot.x > .25 or self.robot.x < .15:
behaviour = self.recovery
else:
behaviour = self.defender
# if ball_x < .575 and ball_x > self.robot.x:
# behaviour = self.push_ball
# elif self.robot.x > .25 or self.robot.x < .15:
# behaviour = self.recovery
# else:
# behaviour = self.defender

if ball_x == -1 or ball_y == -1:
ball_x, ball_y = self.last_b_x, self.last_b_y

# if ball_x < .375:
# self.pushing_ball = True
if ball_x < .375:
self.pushing_ball = True

# if self.pushing_ball:
# if ball_x >= .575 or ball_x < .15:
# self.pushing_ball = False
# behaviour = self.defender
# else:
# behaviour = self.push_ball
# else:
# if self.robot.x > .25 or self.robot.x < .15:
# behaviour = self.recovery
# else:
# behaviour = self.defender
if self.pushing_ball:
if ball_x >= .575 or ball_x < .15:
self.pushing_ball = False
behaviour = self.defender
else:
behaviour = self.push_ball
else:
if self.robot.x > .25 or self.robot.x < .15:
behaviour = self.recovery
else:
behaviour = self.defender

if ball.x > 0 and ball.y > 0:
self.last_b_x, self.last_b_y = ball.x, ball.y
Expand Down
1 change: 1 addition & 0 deletions strategy/tests/Idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ def reset(self, robot=None):


def decide(self):
print(self.robot.x, self.robot.y)
return 0, 0

0 comments on commit a84b9fb

Please sign in to comment.