Skip to content

Commit

Permalink
Workaround for the relocation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RichoM committed Apr 28, 2022
1 parent 2278b6d commit 35c9de6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 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,14 @@ def kickoff(self, team: Optional[str] = None):
)

def tick(self) -> bool:
# 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.sv.robot_reset_physics[robot]
if reset_physics_counter > 0:
self.sv.robot_nodes[robot].resetPhysics()
self.sv.robot_reset_physics[robot] = reset_physics_counter - 1

# On the very first tick, note that the match has started
if self.time == self.match_time:
self.eventer.event(
Expand Down
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,8 @@ def __init__(self):
self.robot_rotation_fields[robot] = field
self.robot_rotation[robot] = field.getSFRotation()

self.robot_reset_physics[robot] = 0

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 +86,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 35c9de6

Please sign in to comment.