Update run_sim.py
Browse files- run_sim.py +14 -9
run_sim.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
import sys
|
| 3 |
from pathlib import Path
|
| 4 |
-
|
| 5 |
# Add sim module to path
|
| 6 |
sys.path.insert(0, str(Path(__file__).parent))
|
| 7 |
|
|
@@ -41,19 +41,24 @@ def main(n_envs=1, use_async_envs: bool = False,
|
|
| 41 |
camera_configs=camera_configs,
|
| 42 |
)
|
| 43 |
|
| 44 |
-
# Start simulator
|
| 45 |
print("\nSimulator running. Press Ctrl+C to exit.")
|
| 46 |
if enable_offscreen and publish_images:
|
| 47 |
print(f"Camera images publishing on tcp://localhost:{camera_port}")
|
| 48 |
try:
|
| 49 |
-
|
| 50 |
-
sim
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
except KeyboardInterrupt:
|
| 56 |
-
print("
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
sim.close()
|
| 58 |
|
| 59 |
if __name__ == "__main__":
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
import sys
|
| 3 |
from pathlib import Path
|
| 4 |
+
import time
|
| 5 |
# Add sim module to path
|
| 6 |
sys.path.insert(0, str(Path(__file__).parent))
|
| 7 |
|
|
|
|
| 41 |
camera_configs=camera_configs,
|
| 42 |
)
|
| 43 |
|
| 44 |
+
# Start simulator
|
| 45 |
print("\nSimulator running. Press Ctrl+C to exit.")
|
| 46 |
if enable_offscreen and publish_images:
|
| 47 |
print(f"Camera images publishing on tcp://localhost:{camera_port}")
|
| 48 |
try:
|
| 49 |
+
if publish_images:
|
| 50 |
+
sim.start_image_publish_subprocess(
|
| 51 |
+
start_method="spawn",
|
| 52 |
+
camera_port=camera_port,
|
| 53 |
+
)
|
| 54 |
+
time.sleep(1)
|
| 55 |
+
sim.start()
|
| 56 |
except KeyboardInterrupt:
|
| 57 |
+
print("+++++Simulator interrupted by user.")
|
| 58 |
+
except Exception as e:
|
| 59 |
+
print(f"++++error in simulator: {e} ++++")
|
| 60 |
+
finally:
|
| 61 |
+
print("++++closing simulator ++++")
|
| 62 |
sim.close()
|
| 63 |
|
| 64 |
if __name__ == "__main__":
|