Skip to content

debug

DebugWindow #

Source code in cogip/tools/planner/avoidance/debug.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
class DebugWindow:
    ui_thread: threading.Thread | None = None

    def __init__(self):
        self.app = None
        if DebugWindow.ui_thread is None:
            DebugWindow.ui_thread = threading.Thread(target=self.start_qapp)
            DebugWindow.ui_thread.start()
            time.sleep(0.05)  # Wait for a short time to ensure QApplication instance created.

        self.point_start: models.Pose | None = None
        self.point_goal: models.Pose | None = None

        self.fixed_obstacles: list[visibility_road_map.ObstaclePolygon] = []
        self.dyn_obstacles: list[visibility_road_map.ObstaclePolygon] = []

        self.visibility_nodes: list[tuple[float, float]] = []
        self.graph: list[tuple[float, float]] = []
        self.road_map: list[tuple[float, float, float, float]] = []
        self.path: list[tuple[float, float]] = []

        self.win = MainWindow(self)
        self.win.show()

    def start_qapp(self):
        """a thread for QApplication event loop"""
        self.app = QtWidgets.QApplication(sys.argv)
        self.app.exec_()

    def update(self):
        self.win.repaint()

    def reset(self):
        self.point_start = None
        self.point_goal = None
        self.dyn_obstacles.clear()
        self.visibility_nodes.clear()
        self.graph.clear()
        self.road_map.clear()
        self.path.clear()

start_qapp() #

a thread for QApplication event loop

Source code in cogip/tools/planner/avoidance/debug.py
131
132
133
134
def start_qapp(self):
    """a thread for QApplication event loop"""
    self.app = QtWidgets.QApplication(sys.argv)
    self.app.exec_()