Files
FCP_gym/example.py
2025-11-19 08:08:22 -05:00

49 lines
1.7 KiB
Python

from agent.Base_Agent import Base_Agent as Agent
# Args: Server IP, Agent Port, Monitor Port, Uniform No., Robot Type, Team Name
player = Agent("localhost", 3100, 3200, 7, 4, "TeamName")
w = player.world
def kick(self, kick_direction=None, kick_distance=None, abort=False, enable_pass_command=False):
'''
Walk to ball and kick
Parameters
----------
kick_direction : float
kick direction, in degrees, relative to the field
kick_distance : float
kick distance in meters
abort : bool
True to abort.
The method returns True upon successful abortion, which is immediate while the robot is aligning itself.
However, if the abortion is requested during the kick, it is delayed until the kick is completed.
avoid_pass_command : bool
When False, the pass command will be used when at least one opponent is near the ball
Returns
-------
finished : bool
Returns True if the behavior finished or was successfully aborted.
'''
if self.min_opponent_ball_dist < 1.45 and enable_pass_command:
self.scom.commit_pass_command()
self.kick_direction = self.kick_direction if kick_direction is None else kick_direction
self.kick_distance = self.kick_distance if kick_distance is None else kick_distance
if self.fat_proxy_cmd is None: # normal behavior
return self.behavior.execute("Basic_Kick", self.kick_direction,
abort) # Basic_Kick has no kick distance control
else: # fat proxy behavior
return self.fat_proxy_kick()
while True:
player.behavior.execute("Nerul_Kick", True, 0)
player.scom.commit_and_send(w.robot.get_command())
player.scom.receive()