-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_control_center.py
More file actions
55 lines (41 loc) · 1.39 KB
/
Copy pathrun_control_center.py
File metadata and controls
55 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""
Drone Inspection Control Center.
A persistent, interactive dashboard. Unlike the old run_dashboard.py (which
auto-flew a fixed mission on launch), this just serves the control center and
waits for you to drive it from the browser:
• Layout Editor — build/edit the warehouse (spawn/move/delete live, or
rebuild the .world for a cold restart)
• Mission — edit waypoints, run the autonomous inspection
• Live flight — connect, take off, click-to-go, land / RTL
Usage:
python run_control_center.py
Then (in the ROS2 terminal, with the sim running):
ros2 run camera_bridge bridge_all
"""
import os
import sys
import threading
import time
import webbrowser
import uvicorn
sys.path.insert(0, os.path.dirname(__file__))
from dashboard import server as dashboard_server
from dashboard.hub import ControlHub
PORT = 8765
def main():
hub = ControlHub()
dashboard_server.hub = hub
dashboard_server.broadcaster = hub.bc # back-compat
def _open():
time.sleep(1.8)
url = f"http://localhost:{PORT}"
print(f"\n Control Center -> {url}\n")
try:
webbrowser.open(url)
except Exception:
pass
threading.Thread(target=_open, daemon=True).start()
uvicorn.run(dashboard_server.app, host="0.0.0.0", port=PORT, log_level="error")
if __name__ == "__main__":
main()