Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class TigersAutoref(TimeProvider):
BUFFER_TIMEOUT = 10
NEXT_PACKET_DELAY = 1.0 / 30 # 30 Hz

AUTOREF_DIR = "/opt/tbotspython/autoReferee"
AUTOREF_JAVA_HOME = "/opt/tbotspython/bin/jdk"

def __init__(
self,
gc: Gamecontroller,
Expand Down Expand Up @@ -220,8 +223,10 @@ def _forward_to_gamecontroller(

def _start_autoref(self) -> None:
"""Starts the TigersAutoref binary."""
autoref_cmd = "software/autoref/run_autoref"
env = os.environ.copy()
env["JAVA_HOME"] = self.AUTOREF_JAVA_HOME

autoref_cmd = "bin/autoReferee -a"
if not self.show_gui:
autoref_cmd += " -hl"

Expand All @@ -231,10 +236,16 @@ def _start_autoref(self) -> None:
if self.suppress_logs:
with open(os.devnull, "w") as fp:
self.tigers_autoref_proc = Popen(
autoref_cmd.split(" "), stdout=fp, stderr=fp
autoref_cmd.split(" "),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split() also works here, since default separator is any whitespace

stdout=fp,
stderr=fp,
env=env,
cwd=self.AUTOREF_DIR,
)
else:
self.tigers_autoref_proc = Popen(autoref_cmd.split(" "))
self.tigers_autoref_proc = Popen(
autoref_cmd.split(" "), env=env, cwd=self.AUTOREF_DIR
)

def setup_ssl_wrapper_packets(self, autoref_proto_unix_io: ProtoUnixIO) -> None:
"""Registers as an observer of TrackerWrapperPackets from the Simulator, so that they can be forwarded to the
Expand All @@ -246,13 +257,12 @@ def setup_ssl_wrapper_packets(self, autoref_proto_unix_io: ProtoUnixIO) -> None:
autoref_proto_unix_io.register_observer(Referee, self.referee_buffer)

def __exit__(self, type, value, traceback) -> None:
self.end_autoref = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to your PR, but we ought to use Event here (and in all the other process managers) instead of a bool flag. Opened #3471 to track this issue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, I will take that ticket and implement the above comment along as well (so I don't get dismissed)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh awesome, thanks!

if self.tigers_autoref_proc:
self.tigers_autoref_proc.terminate()
self.tigers_autoref_proc.wait()

self.auto_ref_proc_thread.join()

self.end_autoref = True
self.auto_ref_wrapper_thread.join()

logging.info("[TigersAutoref] Process exited")