path_planner 0.1.0 version
This commit is contained in:
@@ -6,6 +6,7 @@ import numpy as np
|
||||
from utils.math_ops import MathOps
|
||||
from world.commons.field import FIFAField, HLAdultField, Soccer7vs7Field
|
||||
from world.commons.play_mode import PlayModeEnum, PlayModeGroupEnum
|
||||
from agent.path_planner import PathPlanner
|
||||
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -60,6 +61,7 @@ class Agent:
|
||||
|
||||
self.agent: Base_Agent = agent
|
||||
self.is_getting_up: bool = False
|
||||
self.path_planner = PathPlanner(agent.world)
|
||||
|
||||
def update_current_behavior(self) -> None:
|
||||
"""
|
||||
@@ -128,16 +130,22 @@ class Agent:
|
||||
desired_orientation = MathOps.vector_angle(ball_to_goal)
|
||||
|
||||
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
|
||||
self.agent.skills_manager.execute(
|
||||
"Walk",
|
||||
target_2d=carry_ball_pos,
|
||||
target_2d=next_target,
|
||||
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
|
||||
self.agent.skills_manager.execute(
|
||||
"Walk",
|
||||
target_2d=their_goal_pos,
|
||||
target_2d=next_target,
|
||||
is_target_absolute=True,
|
||||
orientation=desired_orientation
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user