Skip to content

Commit

Permalink
Merge pull request #133 from GIRA/relocation-bug
Browse files Browse the repository at this point in the history
Workaround for the relocation bug
  • Loading branch information
Adman committed Apr 30, 2022
2 parents 2278b6d + 8153a04 commit 0eec6ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controllers/rcj_soccer_referee_supervisor/referee/referee.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ def kickoff(self, team: Optional[str] = None):
)

def tick(self) -> bool:
self.sv.check_reset_physics_counters()

# On the very first tick, note that the match has started
if self.time == self.match_time:
self.eventer.event(
Expand Down
13 changes: 13 additions & 0 deletions controllers/rcj_soccer_referee_supervisor/referee/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(self):
self.robot_rotation_fields = {}
self.robot_translation = {}
self.robot_rotation = {}
self.robot_reset_physics = {}
for robot in ROBOT_NAMES:
robot_node = self.getFromDef(robot)
self.robot_nodes[robot] = robot_node
Expand All @@ -42,6 +43,17 @@ def __init__(self):
self.robot_rotation_fields[robot] = field
self.robot_rotation[robot] = field.getSFRotation()

self.robot_reset_physics[robot] = 0

def check_reset_physics_counters(self):
# HACK(Richo): Workaround for the following issue
# https://github.com/RoboCupJuniorTC/rcj-soccer-sim/issues/130
for robot in ROBOT_NAMES:
reset_physics_counter = self.robot_reset_physics[robot]
if reset_physics_counter > 0:
self.robot_nodes[robot].resetPhysics()
self.robot_reset_physics[robot] = reset_physics_counter - 1

def update_positions(self):
"""Update the positions of robots and the ball"""
self.ball_translation = self.ball_translation_field.getSFVec3f()
Expand Down Expand Up @@ -83,6 +95,7 @@ def set_robot_position(self, robot_name: str, position: List[float]):
"""
tr_field = self.robot_translation_fields[robot_name]
tr_field.setSFVec3f(position)
self.robot_reset_physics[robot_name] = 1
self.robot_nodes[robot_name].resetPhysics()
self.robot_translation[robot_name] = position

Expand Down

0 comments on commit 0eec6ed

Please sign in to comment.