-
Notifications
You must be signed in to change notification settings - Fork 127
Improve autoref proc management #3470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
|
@@ -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" | ||
|
|
||
|
|
@@ -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(" "), | ||
| 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 | ||
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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") | ||
There was a problem hiding this comment.
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