Update sim/simulator_factory.py
Browse files- sim/simulator_factory.py +0 -40
sim/simulator_factory.py
CHANGED
|
@@ -56,43 +56,3 @@ class SimulatorFactory:
|
|
| 56 |
)
|
| 57 |
return BaseSimulator(config=config, env_name=env_name, **env_kwargs)
|
| 58 |
|
| 59 |
-
@staticmethod
|
| 60 |
-
def start_simulator(
|
| 61 |
-
simulator,
|
| 62 |
-
as_thread: bool = True,
|
| 63 |
-
enable_image_publish: bool = False,
|
| 64 |
-
mp_start_method: str = "spawn",
|
| 65 |
-
camera_port: int = 5555,
|
| 66 |
-
):
|
| 67 |
-
"""
|
| 68 |
-
Start the simulator either as a thread or as a separate process.
|
| 69 |
-
|
| 70 |
-
Args:
|
| 71 |
-
simulator: The simulator instance to start
|
| 72 |
-
config: Configuration dictionary
|
| 73 |
-
as_thread: If True, start as thread; if False, start as subprocess
|
| 74 |
-
enable_offscreen: If True and not as_thread, start image publishing
|
| 75 |
-
"""
|
| 76 |
-
|
| 77 |
-
if as_thread:
|
| 78 |
-
simulator.start_as_thread()
|
| 79 |
-
else:
|
| 80 |
-
# Wrap in try-except to make sure simulator is properly closed upon exit.
|
| 81 |
-
try:
|
| 82 |
-
if enable_image_publish:
|
| 83 |
-
simulator.start_image_publish_subprocess(
|
| 84 |
-
start_method=mp_start_method,
|
| 85 |
-
camera_port=camera_port,
|
| 86 |
-
)
|
| 87 |
-
time.sleep(1)
|
| 88 |
-
simulator.start()
|
| 89 |
-
except KeyboardInterrupt:
|
| 90 |
-
print("+++++Simulator interrupted by user.")
|
| 91 |
-
except Exception as e:
|
| 92 |
-
print(f"++++error in simulator: {e} ++++")
|
| 93 |
-
finally:
|
| 94 |
-
print("++++closing simulator ++++")
|
| 95 |
-
simulator.close()
|
| 96 |
-
|
| 97 |
-
# Allow simulator to initialize
|
| 98 |
-
time.sleep(1)
|
|
|
|
| 56 |
)
|
| 57 |
return BaseSimulator(config=config, env_name=env_name, **env_kwargs)
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|