repair some bugs and path planning 0.2.0 version
This commit is contained in:
@@ -99,9 +99,10 @@ class Agent:
|
||||
"""
|
||||
Basic example of a behavior: moves the robot toward the goal while handling the ball.
|
||||
"""
|
||||
their_goal_pos = self.agent.world.field.get_their_goal_position()[:2]
|
||||
their_goal_pos = np.array(self.agent.world.field.get_their_goal_position()[:2])
|
||||
ball_pos = self.agent.world.ball_pos[:2]
|
||||
my_pos = self.agent.world.global_position[:2]
|
||||
next_target = None
|
||||
|
||||
ball_to_goal = their_goal_pos - ball_pos
|
||||
bg_norm = np.linalg.norm(ball_to_goal)
|
||||
@@ -132,20 +133,24 @@ class Agent:
|
||||
if not aligned or not behind_ball:
|
||||
self.path_planner.set_target(carry_ball_pos)
|
||||
current_time = self.agent.world.server_time
|
||||
next_target = self.path_planner.update(my_pos, current_time=current_time) if next_target is not None else carry_ball_pos
|
||||
next_target = self.path_planner.update(my_pos, current_time=current_time)
|
||||
if next_target is None:
|
||||
next_target = carry_ball_pos
|
||||
self.agent.skills_manager.execute(
|
||||
"Walk",
|
||||
target_2d=next_target,
|
||||
target_2d=carry_ball_pos,
|
||||
is_target_absolute=True,
|
||||
orientation=None if np.linalg.norm(my_pos - carry_ball_pos) > 2 else desired_orientation
|
||||
)
|
||||
else:
|
||||
self.path_planner.set_target(their_goal_pos)
|
||||
current_time = self.agent.world.server_time
|
||||
next_target = self.path_planner.update(my_pos, current_time=current_time) if next_target is not None else their_goal_pos
|
||||
next_target = self.path_planner.update(my_pos, current_time=current_time)
|
||||
if next_target is None:
|
||||
next_target = their_goal_pos
|
||||
self.agent.skills_manager.execute(
|
||||
"Walk",
|
||||
target_2d=next_target,
|
||||
target_2d=their_goal_pos,
|
||||
is_target_absolute=True,
|
||||
orientation=desired_orientation
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user