-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_GUI.py
65 lines (53 loc) · 2.39 KB
/
main_GUI.py
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
56
57
58
59
60
61
62
63
64
65
# main with GUI
import logging
import tools.Logger as Logger
import variable
from cameraStream.SimulationWAPIStreamClient import SimulationWAPIStreamClient
from cameraStream.ToGuiStream import ToGuiStream
from communicationThreads.GUI.Server import JetsonServer
from communicationThreads.GUI.Setup import PrepareCallbacks
from communicationThreads.Simulation.okon_sim_client import OkonSimClient
from config.ConfigLoader import ConfigLoader
from controlThread.controlThread_simulation import SimulationControlThread
from Detectors.simulation_noGPU import Simulation_noGPU_detector
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
# init sim_client
simulation_client = OkonSimClient(ip="127.0.0.1", port=44210, sync_interval=0.05, debug=False)
if not simulation_client.connect():
print("Not connected!")
# init cameraStream
cameraStream = SimulationWAPIStreamClient(simulation_client)
cameraStream.setFov(60, 60)
# init control thread
controlThread = SimulationControlThread(simulation_client)
# init autonomy helpers
# we can switch them according to environment
# TODO: currently detector is only usable once. FIX!!!
detector = Simulation_noGPU_detector(cameraStream, controlThread, simulation_client)
# TODO: add new autonomy
# init autonomy
autonomyThread = None
# autonomyThread = AutonomyThread(detector, controller)
# autonomyThread.StartAutonomy()
# load config and start camera
controlThread.setPIDs(ConfigLoader.LoadPIDs("config/PID_simulation.json"))
cameraStream.start()
# lines only for gui
mode = "simulation"
# mode = "jetson_stm"
guiStream = ToGuiStream(cameraStream)
server = JetsonServer(variable.GUI_ADDRESS, mode)
controlThread.ArmNotificator += server.sender.SendArmCallback
controlThread.DisarmNotificator += server.sender.SendDisarmCallback
guiStream.Start()
# after receiving a msg server invokes a callback
# for sending telemetry server uses 'dataCollector' marked below as 'd'
c, d = PrepareCallbacks(detector, autonomyThread, controlThread)
server.SetCallbacks(c, d)
# event handling - make sure that arguments are matching
detector.RegisterDetectionCallback(server.sender.SendDetection)
# start when ready
server.StartServer()
# setup logger. F.e. Logger.setStream(print, None) or:
Logger.setStream(server.sender.SendLog, None)