|
|
|
|
|
|
docker_training: bool = False, |
|
|
|
no_graphics: bool = False, |
|
|
|
timeout_wait: int = 30, |
|
|
|
args: list = [], |
|
|
|
): |
|
|
|
""" |
|
|
|
Starts a new unity environment and establishes a connection with the environment. |
|
|
|
|
|
|
:bool no_graphics: Whether to run the Unity simulator in no-graphics mode |
|
|
|
:int timeout_wait: Time (in seconds) to wait for connection from environment. |
|
|
|
:bool train_mode: Whether to run in training mode, speeding up the simulation, by default. |
|
|
|
:list args: Addition Unity command line arguments |
|
|
|
""" |
|
|
|
|
|
|
|
atexit.register(self._close) |
|
|
|
|
|
|
"the worker-id must be 0 in order to connect with the Editor." |
|
|
|
) |
|
|
|
if file_name is not None: |
|
|
|
self.executable_launcher(file_name, docker_training, no_graphics) |
|
|
|
self.executable_launcher(file_name, docker_training, no_graphics, args) |
|
|
|
else: |
|
|
|
logger.info( |
|
|
|
"Start training by pressing the Play button in the Unity Editor." |
|
|
|
|
|
|
def reset_parameters(self): |
|
|
|
return self._resetParameters |
|
|
|
|
|
|
|
def executable_launcher(self, file_name, docker_training, no_graphics): |
|
|
|
def executable_launcher(self, file_name, docker_training, no_graphics, args): |
|
|
|
cwd = os.getcwd() |
|
|
|
file_name = ( |
|
|
|
file_name.strip() |
|
|
|
|
|
|
"-batchmode", |
|
|
|
"--port", |
|
|
|
str(self.port), |
|
|
|
] |
|
|
|
] + args |
|
|
|
[launch_string, "--port", str(self.port)] |
|
|
|
[launch_string, "--port", str(self.port)] + args |
|
|
|
) |
|
|
|
else: |
|
|
|
""" |
|
|
|