mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-23 17:23:44 +08:00
Make SimulatorBridge picklable (MacOS support) (#34023)
* remove unused * make Params (un)serializable * move initialization after spawn _thread.lock objects can't be pickled
This commit is contained in:
@@ -47,12 +47,11 @@ class SimulatorBridge(ABC):
|
||||
self.dual_camera = dual_camera
|
||||
self.high_quality = high_quality
|
||||
|
||||
self._exit_event = threading.Event()
|
||||
self._exit_event: threading.Event | None = None
|
||||
self._threads = []
|
||||
self._keep_alive = True
|
||||
self.started = Value('i', False)
|
||||
signal.signal(signal.SIGTERM, self._on_shutdown)
|
||||
self._exit = threading.Event()
|
||||
self.simulator_state = SimulatorState()
|
||||
|
||||
self.world: World | None = None
|
||||
@@ -76,7 +75,9 @@ class SimulatorBridge(ABC):
|
||||
|
||||
def close(self, reason):
|
||||
self.started.value = False
|
||||
self._exit_event.set()
|
||||
|
||||
if self._exit_event is not None:
|
||||
self._exit_event.set()
|
||||
|
||||
if self.world is not None:
|
||||
self.world.close(reason)
|
||||
@@ -103,6 +104,8 @@ Ignition: {self.simulator_state.ignition} Engaged: {self.simulator_state.is_enga
|
||||
self.simulated_car = SimulatedCar()
|
||||
self.simulated_sensors = SimulatedSensors(self.dual_camera)
|
||||
|
||||
self._exit_event = threading.Event()
|
||||
|
||||
self.simulated_car_thread = threading.Thread(target=rk_loop, args=(functools.partial(self.simulated_car.update, self.simulator_state),
|
||||
100, self._exit_event))
|
||||
self.simulated_car_thread.start()
|
||||
|
||||
Reference in New Issue
Block a user