def __init__(self, main_window, nao: Nao, model=None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)
        self.dps_counter = 0
        self.dps_timer = qtc.QTimer()
        self.dps_timer.timeout.connect(self.update_dps)
        self.dps_timer.start(1000)

        self.timer = qtc.QTimer()
        self.timer.timeout.connect(self.update_data)
        self.spnFramerate.valueChanged.connect(self.set_timer)

        self.should_update = False
        self.data = None

        self.cbxMount.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbxMount.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)

        self.cbxMount.activated[str].connect(self.subscribe)
        self.cbxMount.setCurrentText(self.model["subscribe_key"])
        self.cbxMount.setFocus()

        self.btnSnap.clicked.connect(self.snap)

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #2
0
    def __init__(self, main_window, nao: Nao, model: typing.Dict = None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(os.path.dirname(__file__) +
                                         "/model.json", model)

        self.data = None
        self.data_orig = None

        # btnSetAll passes -1 to update all keys
        self.btnSetAll.clicked.connect(lambda: self.set(-1))
        self.btnSave.clicked.connect(self.save)
        self.btnExport.clicked.connect(lambda: self.export(self.get_data()))
        self.diffModeSelector.activated.connect(lambda index: self.export_diff(index))

        # Set values when pressing enter without klicking set-button
        self.tblConfig.cellChanged.connect(lambda row, col: self.set(row))

        self.cbxMount.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbxMount.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbxMount.activated[str].connect(self.select_mount)
        self.cbxMount.setCurrentText(self.model["subscribe_key"])

        self.update_signal.connect(self.update_data)

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #3
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "robotsFilter": (lambda: {
                "key": self.cbx_Key.currentText()
            }, lambda config: [self.cbx_Key.setCurrentText(config["key"])])
        }

        self.cbx_Key.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_Key.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)

        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)

        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.kickRatingChunks = []
        self.kickRatingChunks_identifier = uuid.uuid4()
        self.hitPoints = None
        self.hitPoints_identifier = uuid.uuid4()
        self.teamBallPosition = [0, 0]
        self.teamBallPosition_identifier = uuid.uuid4()
        self.rateKick = False
        self.rateKick_identifier = uuid.uuid4()
        self.kickRatingChunkWeights = []
        self.kickRatingChunkWeights_identifier = uuid.uuid4()
        self.firstShadowPoint = None
        self.firstShadowPoint_identifier = uuid.uuid4()
        self.secondShadowPoint = None
        self.secondShadowPoint_identifier = uuid.uuid4()
        self.firstShadowPointAfter = None
        self.firstShadowPointAfter_identifier = uuid.uuid4()
        self.secondShadowPointAfter = None
        self.secondShadowPointAfter_identifier = uuid.uuid4()

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #5
0
    def __init__(self, main_window, nao: Nao, model: typing.Dict = None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)
        self.data = None
        self.btnSetAll.clicked.connect(self.set)
        self.btnSave.clicked.connect(self.save)
        self.btnExport.clicked.connect(lambda: self.export(self.get_data()))
        self.topSliders = [
            self.topRollSlider, self.topPitchSlider, self.topYawSlider
        ]
        self.bottomSliders = [
            self.bottomRollSlider, self.bottomPitchSlider, self.bottomYawSlider
        ]
        self.topSBs = [self.topRollSB, self.topPitchSB, self.topYawSB]
        self.bottomSBs = [
            self.bottomRollSB, self.bottomPitchSB, self.bottomYawSB
        ]
        for i in range(3):
            self.topSliders[i].valueChanged.connect(self.setTopBySlider)
            self.bottomSliders[i].valueChanged.connect(self.setBottomBySlider)
            self.topSBs[i].valueChanged.connect(self.setTopBySpinBox)
            self.bottomSBs[i].valueChanged.connect(self.setBottomBySpinBox)
        self.update_signal.connect(self.update_data)

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #6
0
    def __init__(self, main_window, nao: Nao, model: typing.Dict = None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)

        self.play_timer = qtc.QTimer()
        self.capture_timer = qtc.QTimer()

        # Initialize model to assure consistent state
        reset_model(self.model)

        # Rendered View
        self.render_view = RenderView(self.model, self)
        format = qtg.QSurfaceFormat.defaultFormat()
        format.setSamples(4)
        self.render_view.setFormat(format)
        self.config_view = Config(self.model)
        self.tabWidget_left.addTab(self.render_view, "Display")
        self.tabWidget_left.addTab(self.config_view, "Config")

        # Load motion-file
        if self.model["opened_file"] != "": 
            self.open_motion2file(self.model["opened_file"])

        # Connect GUI elements to functions
        self.connect_gui()

        if self.nao.is_connected():
            self.connect(self.nao)
    def __init__(self, main_window, nao: Nao, model=None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)
        """
        self.data contains the data of curves.
        each curve data is a deque in this list:
            deque:
                - dict
                    - "y": value # this key should be called 'y'; pyqtgraph
                    - "timestamp": time received
            deque: ....
        """
        self.data = {}
        self.should_update = False
        self.plots = []

        self.cbxKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbxKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)

        self.data_received_signal.connect(self.data_received)
        self.spinFps.valueChanged.connect(self.set_fps)
        self.spinBufferSize.valueChanged.connect(self.set_buffer_size)
        self.legendCheckBox.stateChanged.connect(self.set_show_legend)

        self.listWidget.itemSelectionChanged.connect(self.select_curve)
        self.btnAccept.clicked.connect(self.accept)
        self.btnDiscard.clicked.connect(self.discard)
        self.btnAddCurve.clicked.connect(self.add_curve)
        self.btnDeleteCurve.clicked.connect(self.delete_curve)
        self.btnColor.clicked.connect(self.select_color)
        self.btnSnap.clicked.connect(self.snap)
        self.edit_color.returnPressed.connect(
            lambda: ui_utils.reset_textField_color(self.edit_color,
                                                   self.edit_color.text()))

        self.update_list()

        self.timer = qtc.QTimer()
        self.timer.timeout.connect(self.update)

        self.reset_fps_spin()
        self.reset_buffer_size_spin()
        self.reset_show_legend()

        self.tabWidget.currentChanged.connect(self.tab_changed)
        self.tabWidget.setCurrentIndex(self.model["selected_tab"])

        self._init_datalist()
        self._init_plot()

        self.data_received_signal.connect(self.data_received)

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #8
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.teamPlayers = None

        if self.nao.is_connected():
            self.connect(self.nao)
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.nao = nao
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "transformation":
            (lambda: {
                "key": self.cbx_TransformationKey.currentText(),
                "key_lambda": self.edit_TransformationKeyLambda.toPlainText()
            }, lambda config: [
                self.cbx_TransformationKey.setCurrentText(config["key"]),
                self.edit_TransformationKeyLambda.setPlainText(config[
                    "key_lambda"])
            ]),
            "motionPlan":
            (lambda:
             {
                 "key": self.cbx_MotionPlannerKey.currentText(),
                 "key_lambda": self.edit_MotionPlannerKeyLambda.toPlainText(),
                 "targetCircleDiameter": self.spin_targetCircleDiameter.value(
                 ),
                 "targetColor": self.edit_targetColor.text()
             }, lambda config: [
                 self.cbx_MotionPlannerKey.setCurrentText(config["key"]),
                 self.edit_MotionPlannerKeyLambda.setPlainText(config[
                     "key_lambda"]),
                 self.spin_targetCircleDiameter.setValue(config[
                     "targetCircleDiameter"]),
                 ui_utils.reset_textField_color(self.edit_targetColor, config[
                     "targetColor"])
             ])
        }
        self.cbx_TransformationKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_TransformationKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_MotionPlannerKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_MotionPlannerKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        ui_utils.init_Color_UI(self.btn_targetColor, self.edit_targetColor)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
    def __init__(self, main_window, nao: Nao, model=None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)

        self.signal_update_data.connect(self.update_data)

        self.edit_top_value.textChanged.connect(lambda: self.update_value(
            CameraType.TOP, self.edit_top_value.text()))
        self.chk_top_bit0.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit1.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit2.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit3.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit4.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit5.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit6.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))
        self.chk_top_bit7.stateChanged.connect(
            lambda: self.update_value(CameraType.TOP))

        self.edit_bottom_value.textChanged.connect(lambda: self.update_value(
            CameraType.BOTTOM, self.edit_bottom_value.text()))
        self.chk_bottom_bit0.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit1.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit2.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit3.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit4.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit5.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit6.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))
        self.chk_bottom_bit7.stateChanged.connect(
            lambda: self.update_value(CameraType.BOTTOM))

        self.edit_register_addr.returnPressed.connect(self.address_entered)

        # Buttons
        self.btn_set_top.clicked.connect(
            lambda: self.clicked_set(CameraType.TOP))
        self.btn_set_bottom.clicked.connect(
            lambda: self.clicked_set(CameraType.BOTTOM))

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #11
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(os.path.dirname(__file__) +
                                           "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.obstacles = None
        self.transformation = [[0, 0], 0]
        self.transformation_identifier = uuid.uuid4()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #12
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.probabilityMap = None
        self.explorerCount = 0
        self.voronoiSeeds = None
        self.ballSearchPose = None
        self.walkTarget = None
        self.pose = None
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #13
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.fieldScale = [
            (self.config["field"]["length"] +
             self.config["field"]["borderStripWidth"] * 2.0) /
            self.config["field"]["length"],
            (self.config["field"]["width"] +
             self.config["field"]["borderStripWidth"] * 2.0) /
            self.config["field"]["width"],
        ]
Beispiel #14
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.pathLines = None
        self.arcLines = None
        self.pathObstacles = None
        self.nodes = None
        self.start_nodes = None
        self.end_nodes = None
        self.blockedArcLines = None

        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #15
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.pose = None
        self.role = None
        self.role_identifier = uuid.uuid4()
        self.jointSensorData = None
        self.jointSensorData_identifier = uuid.uuid4()
        self.motionPlan = None
        self.motionPlan_identifier = uuid.uuid4()
        self.searchPosition = None
        self.searchPosition_identifier = uuid.uuid4()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #16
0
    def __init__(self, main_window, nao: Nao, model=None):
        super(Main, self).__init__(main_window, self.name, nao)
        ui_utils.loadUi(__file__, self)
        self.model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", model)
        self.layer_modules = self.import_layer()

        self.map_tab = MapTab(self, self.nao, self.model["projection_corners"])
        self.layer_tab = LayerTab(self, self.nao)
        self.config_tab = ConfigTab(self)

        self.tabWidget.addTab(self.map_tab, "Map")
        self.tabWidget.addTab(self.layer_tab, "Layer")
        self.tabWidget.addTab(self.config_tab, "Config")
        self.tabWidget.setCurrentIndex(self.model["selected_tab"])
        if self.is_map_tab_selected():
            self.map_tab.create_painter()

        self.tabWidget.currentChanged.connect(self.tab_changed)
Beispiel #17
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "mode": (lambda: self.cbx_Mode.currentText(),
                     lambda mode: self.cbx_Mode.setCurrentText(mode)),
            "filepath": (lambda: self.file_path_line_edit.text(),
                         lambda mode: self.file_path_line_edit.insert(mode)),
            "subscribe_key": (lambda: self.cbx_Key.currentText(),
                              lambda key: self.cbx_Key.setCurrentText(key)),
            "video_device": (lambda: self.cbx_Device.currentText(),
                             lambda key: self.cbx_Device.setCurrentText(key)),
        }

        self.cbx_Mode.addItem("File")
        self.cbx_Mode.addItem("Debug Key")
        self.cbx_Mode.addItem("Video Device")

        for file in glob.glob("/dev/video*"):
            self.cbx_Device.addItem(file)

        self.cbx_Key.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_Key.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)

        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)

        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #18
0
    def __init__(self, layer_model: ty.Dict, nao: Nao):
        merged_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))

        self.ignore_perspective = True
        self.ignore_scale = True

        self.pixmap = qtg.QPixmap()
        self.image = qtg.QImage()

        if self.config["mode"] == "File":
            self.image.load(self.config["filepath"])

        if self.config["mode"] == "Debug Key":
            if self.nao.is_connected():
                self.connect(self.nao)
            self.data = None
            self.should_update = True

        if self.config["mode"] == "Video Device":
            self.vc = cv2.VideoCapture(self.config["video_device"])
Beispiel #19
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(os.path.dirname(__file__) +
                                               "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (
                lambda: self.spin_center_x.value(),
                lambda value: self.spin_center_x.setValue(value)),
            "center_y": (
                lambda: self.spin_center_y.value(),
                lambda value: self.spin_center_y.setValue(value)),
            "teamPlayers": (
                lambda:  {
                    "key":
                        self.cbx_TeamPlayersKey.currentText(),
                    "keyLambda":
                        self.edit_TeamPlayersKeyLambda.toPlainText(),
                    "showPlayer":
                        self.playerCheckbox.isChecked(),
                    "poseCircleDiameter":
                        self.spin_poseCircleDiameter.value(),
                    "showTarget":
                        self.targetCheckbox.isChecked(),
                    "targetCircleDiameter":
                        self.spin_targetCircleDiameter.value(),
                    "showFOV":
                        self.fovCheckbox.isChecked(),
                    "maxDistance":
                        self.spin_maxDistance.value(),
                    "cameraOpeningAngle":
                        self.spin_cameraOpeningAngle.value(),
                    "defaultColor":
                        self.edit_defaultColor.text(),
                    "keeperColor":
                        self.edit_keeperColor.text(),
                    "defenderLeftColor":
                        self.edit_defenderLeftColor.text(),
                    "defenderRightColor":
                        self.edit_defenderRightColor.text(),
                    "supporterColor":
                        self.edit_supporterColor.text(),
                    "strikerColor":
                        self.edit_strikerColor.text(),
                    "bishopColor":
                        self.edit_bishopColor.text(),
                    "replacement_keeperColor":
                        self.edit_replacementKeeperColor.text(),
                    "showSearchPosition":
                        self.searchPositionCheckbox.isChecked(),
                    "searchPositionDiameter":
                        self.spin_searchPositionDiameter.value()},
                lambda config: [
                    self.cbx_TeamPlayersKey.setCurrentText(
                        config["key"]),
                    self.edit_TeamPlayersKeyLambda.setPlainText(
                        config["keyLambda"]),
                    self.playerCheckbox.setChecked(
                        config["showPlayer"]),
                    self.spin_poseCircleDiameter.setValue(
                        config["poseCircleDiameter"]),
                    self.targetCheckbox.setChecked(
                        config["showTarget"]),
                    self.spin_targetCircleDiameter.setValue(
                        config["targetCircleDiameter"]),
                    self.fovCheckbox.setChecked(
                        config["showFOV"]),
                    self.spin_maxDistance.setValue(
                        config["maxDistance"]),
                    self.spin_cameraOpeningAngle.setValue(
                        config["cameraOpeningAngle"]),
                    ui_utils.reset_textField_color(
                        self.edit_defaultColor,
                        config["defaultColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_keeperColor,
                        config["keeperColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_defenderLeftColor,
                        config["defenderLeftColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_defenderRightColor,
                        config["defenderRightColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_supporterColor,
                        config["supporterColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_strikerColor,
                        config["strikerColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_bishopColor,
                        config["bishopColor"]),
                    ui_utils.reset_textField_color(
                        self.edit_replacementKeeperColor,
                        config["replacement_keeperColor"]),
                    self.searchPositionCheckbox.setChecked(
                        config["showSearchPosition"]),
                    self.spin_searchPositionDiameter.setValue(
                        config["searchPositionDiameter"])])
            }
        self.cbx_TeamPlayersKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_TeamPlayersKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        ui_utils.init_Color_UI(
            self.btn_defaultColor,
            self.edit_defaultColor)
        ui_utils.init_Color_UI(
            self.btn_keeperColor,
            self.edit_keeperColor)
        ui_utils.init_Color_UI(
            self.btn_defenderLeftColor,
            self.edit_defenderLeftColor)
        ui_utils.init_Color_UI(
            self.btn_defenderRightColor,
            self.edit_defenderRightColor)
        ui_utils.init_Color_UI(
            self.btn_supporterColor,
            self.edit_supporterColor)
        ui_utils.init_Color_UI(
            self.btn_strikerColor,
            self.edit_strikerColor)
        ui_utils.init_Color_UI(
            self.btn_bishopColor,
            self.edit_bishopColor)
        ui_utils.init_Color_UI(
            self.btn_replacementKeeperColor,
            self.edit_replacementKeeperColor)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #20
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "kickRatingChunksKey":
            (lambda: self.cbx_kickRatingChunksKey.currentText(),
             lambda value: self.cbx_kickRatingChunksKey.setCurrentText(value)),
            "kickRatingChunkWeightsKey":
            (lambda: self.cbx_kickRatingChunkWeightsKey.currentText(), lambda
             value: self.cbx_kickRatingChunkWeightsKey.setCurrentText(value)),
            "rateKickKey":
            (lambda: self.cbx_rateKick.currentText(),
             lambda value: self.cbx_rateKick.setCurrentText(value)),
            "hitPointsKey":
            (lambda: self.cbx_hitPointsKey.currentText(),
             lambda value: self.cbx_hitPointsKey.setCurrentText(value)),
            "teamBallPositionKey":
            (lambda: self.cbx_teamBallPositionKey.currentText(),
             lambda value: self.cbx_teamBallPositionKey.setCurrentText(value)),
            "firstShadowPointKey":
            (lambda: self.cbx_firstShadowPointKey.currentText(),
             lambda value: self.cbx_firstShadowPointKey.setCurrentText(value)),
            "secondShadowPointKey":
            (lambda: self.cbx_secondShadowPointKey.currentText(),
             lambda value: self.cbx_secondShadowPointKey.setCurrentText(value)
             ),
            "firstShadowPointAfterKey":
            (lambda: self.cbx_firstShadowPointAfterKey.currentText(), lambda
             value: self.cbx_firstShadowPointAfterKey.setCurrentText(value)),
            "secondShadowPointAfterKey":
            (lambda: self.cbx_secondShadowPointAfterKey.currentText(), lambda
             value: self.cbx_secondShadowPointAfterKey.setCurrentText(value)),
        }
        self.cbx_kickRatingChunksKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_kickRatingChunkWeightsKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_rateKick.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_hitPointsKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_teamBallPositionKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_firstShadowPointKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_secondShadowPointKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_firstShadowPointAfterKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_secondShadowPointAfterKey.completer().setFilterMode(
            qtc.Qt.MatchContains)

        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #21
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "pose":
            (lambda: {
                "key": self.cbx_PoseKey.currentText(),
                "keyLambda": self.edit_poseKeyLambda.toPlainText(),
                "drawPose": self.drawPoseCheckBox.isChecked(),
                "positionCircleDiameter": self.spin_positionCircleDiameter.
                value(),
                "orientationLineLength": self.spin_orientationLineLength.value(
                ),
                "fixedColor": self.edit_fixedColor.text(),
                "useFixedColor": self.useFixedColorCheckBox.isChecked(),
                "roleKey": self.cbx_RoleKey.currentText(),
                "roleKeyLambda": self.edit_roleKeyLambda.toPlainText(),
                "defaultColor": self.edit_defaultColor.text(),
                "keeperColor": self.edit_keeperColor.text(),
                "defenderColor": self.edit_defenderColor.text(),
                "supporterColor": self.edit_supporterColor.text(),
                "strikerColor": self.edit_strikerColor.text(),
                "bishopColor": self.edit_bishopColor.text(),
                "replacement_keeperColor": self.edit_replacementKeeperColor.
                text(),
                "loserColor": self.edit_loserColor.text(),
                "searcherColor": self.edit_searcherColor.text()
            }, lambda config: [
                self.cbx_PoseKey.setCurrentText(config["key"]),
                self.edit_poseKeyLambda.setPlainText(config["keyLambda"]),
                self.drawPoseCheckBox.setChecked(config["drawPose"]),
                self.spin_positionCircleDiameter.setValue(config[
                    "positionCircleDiameter"]),
                self.spin_orientationLineLength.setValue(config[
                    "orientationLineLength"]),
                ui_utils.reset_textField_color(self.edit_fixedColor, config[
                    "fixedColor"]),
                self.useFixedColorCheckBox.setChecked(config["useFixedColor"]),
                self.cbx_RoleKey.setCurrentText(config["roleKey"]),
                self.edit_roleKeyLambda.setPlainText(config["roleKeyLambda"]),
                ui_utils.reset_textField_color(self.edit_defaultColor, config[
                    "defaultColor"]),
                ui_utils.reset_textField_color(self.edit_keeperColor, config[
                    "keeperColor"]),
                ui_utils.reset_textField_color(self.edit_defenderColor, config[
                    "defenderColor"]),
                ui_utils.reset_textField_color(self.edit_supporterColor,
                                               config["supporterColor"]),
                ui_utils.reset_textField_color(self.edit_strikerColor, config[
                    "strikerColor"]),
                ui_utils.reset_textField_color(self.edit_bishopColor, config[
                    "bishopColor"]),
                ui_utils.reset_textField_color(
                    self.edit_replacementKeeperColor, config[
                        "replacement_keeperColor"]),
                ui_utils.reset_textField_color(self.edit_loserColor, config[
                    "loserColor"]),
                ui_utils.reset_textField_color(self.edit_searcherColor, config[
                    "searcherColor"])
            ]),
            "fov": (lambda: {
                "jointSensorDataKey":
                self.cbx_JointSensorDataKey.currentText(),
                "jointSensorDataKeyLambda":
                self.edit_jointSensorDataKeyLambda.toPlainText(),
                "drawFOV":
                self.drawFOVCheckBox.isChecked(),
                "maxDistance":
                self.spin_maxDistance.value(),
                "cameraOpeningAngle":
                self.spin_cameraOpeningAngle.value()
            }, lambda config: [
                self.cbx_JointSensorDataKey.setCurrentText(config[
                    "jointSensorDataKey"]),
                self.edit_jointSensorDataKeyLambda.setPlainText(config[
                    "jointSensorDataKeyLambda"]),
                self.drawFOVCheckBox.setChecked(config["drawFOV"]),
                self.spin_maxDistance.setValue(config["maxDistance"]),
                self.spin_cameraOpeningAngle.setValue(config[
                    "cameraOpeningAngle"])
            ]),
            "motionPlan":
            (lambda:
             {
                 "key": self.cbx_MotionPlannerKey.currentText(),
                 "keyLambda": self.edit_motionPlannerKeyLambda.toPlainText(),
                 "drawMotionPlan": self.drawMotionPlanCheckBox.isChecked(),
                 "targetCircleDiameter": self.spin_targetCircleDiameter.value(
                 ),
                 "drawTranslation": self.drawTranslationCheckBox.isChecked(),
                 "translationColor": self.edit_translationColor.text()
             }, lambda config: [
                 self.cbx_MotionPlannerKey.setCurrentText(config["key"]),
                 self.edit_motionPlannerKeyLambda.setPlainText(config[
                     "keyLambda"]),
                 self.drawMotionPlanCheckBox.setChecked(config["drawMotionPlan"
                                                               ]),
                 self.spin_targetCircleDiameter.setValue(config[
                     "targetCircleDiameter"]),
                 self.drawTranslationCheckBox.setChecked(config[
                     "drawTranslation"]),
                 ui_utils.reset_textField_color(self.edit_translationColor,
                                                config["translationColor"])
             ]),
            "ballSearch":
            (lambda:
             {
                 "key": self.cbx_BallSearchKey.currentText(),
                 "keyLambda": self.edit_ballSearchKeyLambda.toPlainText(),
                 "drawSearchTarget": self.drawBallSearchCheckBox.isChecked(),
                 "searchCircleDiameter": self.spin_searchCircleDiameter.value(
                 )
             }, lambda config: [
                 self.cbx_BallSearchKey.setCurrentText(config["key"]),
                 self.edit_ballSearchKeyLambda.setPlainText(config["keyLambda"]
                                                            ),
                 self.drawBallSearchCheckBox.setChecked(config[
                     "drawSearchTarget"]),
                 self.spin_searchCircleDiameter.setValue(config[
                     "searchCircleDiameter"])
             ])
        }
        self.cbx_PoseKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_PoseKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_RoleKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_RoleKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_JointSensorDataKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_JointSensorDataKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_MotionPlannerKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_MotionPlannerKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_BallSearchKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_BallSearchKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        ui_utils.init_Color_UI(self.btn_fixedColor, self.edit_fixedColor)
        ui_utils.init_Color_UI(self.btn_defaultColor, self.edit_defaultColor)
        ui_utils.init_Color_UI(self.btn_keeperColor, self.edit_keeperColor)
        ui_utils.init_Color_UI(self.btn_defenderColor, self.edit_defenderColor)
        ui_utils.init_Color_UI(self.btn_supporterColor,
                               self.edit_supporterColor)
        ui_utils.init_Color_UI(self.btn_strikerColor, self.edit_strikerColor)
        ui_utils.init_Color_UI(self.btn_bishopColor, self.edit_bishopColor)
        ui_utils.init_Color_UI(self.btn_replacementKeeperColor,
                               self.edit_replacementKeeperColor)
        ui_utils.init_Color_UI(self.btn_loserColor, self.edit_loserColor)
        ui_utils.init_Color_UI(self.btn_searcherColor, self.edit_searcherColor)
        ui_utils.init_Color_UI(self.btn_translationColor,
                               self.edit_translationColor)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.nao = nao
        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "transformation":
            (lambda: {
                "key": self.cbx_TransformationKey.currentText(),
                "key_lambda": self.edit_TransformationKeyLambda.toPlainText(),
            }, lambda config: [
                self.cbx_TransformationKey.setCurrentText(config["key"]),
                self.edit_TransformationKeyLambda.setPlainText(config[
                    "key_lambda"]),
            ]),
            "pose":
            (lambda:
             {
                 "key": self.cbx_PoseKey.currentText(),
                 "keyLambda": self.edit_poseKeyLambda.toPlainText(),
                 "positionCircleDiameter": self.spin_positionCircleDiameter.
                 value(),
                 "orientationLineLength": self.spin_orientationLineLength.
                 value(),
                 "color": self.edit_poseColor.text()
             }, lambda config: [
                 self.cbx_PoseKey.setCurrentText(config["key"]),
                 self.edit_poseKeyLambda.setPlainText(config["keyLambda"]),
                 self.spin_positionCircleDiameter.setValue(config[
                     "positionCircleDiameter"]),
                 self.spin_orientationLineLength.setValue(config[
                     "orientationLineLength"]),
                 ui_utils.reset_textField_color(self.edit_poseColor, config[
                     "color"])
             ]),
            "fov": (lambda: {
                "jointSensorDataKey":
                self.cbx_JointSensorDataKey.currentText(),
                "jointSensorDataKeyLambda":
                self.edit_jointSensorDataKeyLambda.toPlainText(),
                "maxDistance":
                self.spin_maxDistance.value(),
                "cameraOpeningAngle":
                self.spin_cameraOpeningAngle.value()
            }, lambda config: [
                self.cbx_JointSensorDataKey.setCurrentText(config[
                    "jointSensorDataKey"]),
                self.edit_jointSensorDataKeyLambda.setPlainText(config[
                    "jointSensorDataKeyLambda"]),
                self.spin_maxDistance.setValue(config["maxDistance"]),
                self.spin_cameraOpeningAngle.setValue(config[
                    "cameraOpeningAngle"])
            ])
        }
        self.cbx_PoseKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_PoseKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_TransformationKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_TransformationKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_JointSensorDataKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_JointSensorDataKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        ui_utils.init_Color_UI(self.btn_poseColor, self.edit_poseColor)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #23
0
    def __init__(self, layer_model, parent, update_callback, nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.layer_model = ui_utils.load_model(os.path.dirname(__file__) +
                                               "/model.json", layer_model)
        self.update_callback = update_callback
        self.nao = nao
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (
                lambda: self.spin_center_x.value(),
                lambda value: self.spin_center_x.setValue(value)),
            "center_y": (
                lambda: self.spin_center_y.value(),
                lambda value: self.spin_center_y.setValue(value)),
            "search": (
                lambda:  {
                    "key":
                        self.cbx_MapKey.currentText(),
                    "keyLambda":
                        self.edit_MapKeyLambda.toPlainText(),
                    "showProbability":
                        self.probabilityCheckbox.isChecked(),
                    "showNumericProbability":
                        self.probabilityNumericCheckbox.isChecked(),
                    "showAge":
                        self.ageCheckbox.isChecked(),
                    "showNumericAge":
                        self.ageNumericCheckbox.isChecked(),
                    "showVoronoiSeeds":
                        self.voronoiSeedsCheckbox.isChecked()
                },
                lambda config: [
                    self.cbx_MapKey.setCurrentText(
                        config["key"]),
                    self.edit_MapKeyLambda.setPlainText(
                        config["keyLambda"]),
                    self.probabilityCheckbox.setChecked(
                        config["showProbability"]),
                    self.probabilityNumericCheckbox.setChecked(
                        config["showNumericProbability"]),
                    self.ageCheckbox.setChecked(
                        config["showAge"]),
                    self.ageNumericCheckbox.setChecked(
                        config["showNumericAge"]),
                    self.voronoiSeedsCheckbox.setChecked(
                        config["showVoronoiSeeds"])
                ]
            )
        }

        self.cbx_MapKey.completer().setFilterMode(qtc.Qt.MatchContains)
        self.cbx_MapKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)

        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)

        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)
Beispiel #24
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "coordinateSystem": (lambda: {
                "width":
                self.spin_coordinateSystem_width.value(),
                "height":
                self.spin_coordinateSystem_height.value(),
                "backgroundColor":
                self.edit_bgColor.text(),
                "backgroundAlpha":
                self.spin_coordinateSystem_bgAlpha.value(),
                "lineWidth":
                self.spin_coordinateSystem_lineWidth.value(),
                "stepSizeY":
                self.spin_coordinateSystem_stepSizeY.value(),
                "stepSizeX":
                self.spin_coordinateSystem_stepSizeX.value(),
                "lineColor":
                self.edit_lineColor.text(),
                "polar":
                self.polarCheckBox.isChecked(),
                "polarAngleStepSize":
                self.spin_coordinateSystem_angleStepSize.value(),
                "radialStepSize":
                self.spin_coordinateSystem_radialStepSize.value()
            }, lambda config: [
                self.spin_coordinateSystem_width.setValue(config["width"]),
                self.spin_coordinateSystem_height.setValue(config["height"]),
                ui_utils.reset_textField_color(self.edit_bgColor, config[
                    "backgroundColor"]),
                self.spin_coordinateSystem_bgAlpha.setValue(config[
                    "backgroundAlpha"]),
                self.spin_coordinateSystem_lineWidth.setValue(config[
                    "lineWidth"]),
                self.spin_coordinateSystem_stepSizeY.setValue(config[
                    "stepSizeY"]),
                self.spin_coordinateSystem_stepSizeX.setValue(config[
                    "stepSizeX"]),
                ui_utils.reset_textField_color(self.edit_lineColor, config[
                    "lineColor"]),
                self.polarCheckBox.setChecked(config["polar"]),
                self.spin_coordinateSystem_angleStepSize.setValue(config[
                    "polarAngleStepSize"]),
                self.spin_coordinateSystem_radialStepSize.setValue(config[
                    "radialStepSize"])
            ])
        }
        ui_utils.init_Color_UI(self.btn_bgColor, self.edit_bgColor)
        ui_utils.init_Color_UI(self.btn_lineColor, self.edit_lineColor)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
 def __init__(self, layer_model: ty.Dict, nao: Nao):
     merged_model = ui_utils.load_model(
         os.path.dirname(__file__) + "/model.json", layer_model)
     super(Main, self).__init__(merged_model, nao, str(uuid.uuid4()))
Beispiel #26
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback

        self.field_types = {
            "default": {
                "center_x": 0.0,
                "center_y": 0.0,
                "field": {
                    "length": 9,
                    "width": 6,
                    "lineWidth": 0.05,
                    "penaltyMarkerSize": 0.1,
                    "penaltyMarkerDistance": 1.3,
                    "goalBoxAreaLength": 0.6,
                    "goalBoxAreaWidth": 2.2,
                    "penaltyAreaLength": 1.65,
                    "penaltyAreaWidth": 4.0,
                    "centerCircleDiameter": 1.5,
                    "borderStripWidth": 0.7,
                    "hide_background": False
                },
                "goal": {
                    "postDiameter": 0.1,
                    "height": 0.8,
                    "innerWidth": 1.5,
                    "depth": 0.5
                }
            },
            "smd": {
                "center_x": 0.0,
                "center_y": 0.0,
                "field": {
                    "length": 7.5,
                    "width": 5,
                    "lineWidth": 0.05,
                    "penaltyMarkerSize": 0.1,
                    "penaltyMarkerDistance": 1.3,
                    "goalBoxAreaLength": 0.6,
                    "goalBoxAreaWidth": 2.2,
                    "penaltyAreaLength": 1.65,
                    "penaltyAreaWidth": 3.6,
                    "centerCircleDiameter": 1.25,
                    "borderStripWidth": 0.4,
                    "hide_background": False
                },
                "goal": {
                    "postDiameter": 0.1,
                    "height": 0.8,
                    "innerWidth": 1.5,
                    "depth": 0.5
                }
            }
        }

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "field": (lambda: {
                "width":
                self.spin_field_width.value(),
                "length":
                self.spin_field_length.value(),
                "lineWidth":
                self.spin_field_lineWidth.value(),
                "penaltyMarkerSize":
                self.spin_field_penaltyMarkerSize.value(),
                "penaltyMarkerDistance":
                self.spin_field_penaltyMarkerDistance.value(),
                "goalBoxAreaLength":
                self.spin_field_goalBoxAreaLength.value(),
                "goalBoxAreaWidth":
                self.spin_field_goalBoxAreaWidth.value(),
                "penaltyAreaLength":
                self.spin_field_penaltyAreaLength.value(),
                "penaltyAreaWidth":
                self.spin_field_penaltyAreaWidth.value(),
                "centerCircleDiameter":
                self.spin_field_centerCircleDiameter.value(),
                "borderStripWidth":
                self.spin_field_borderStripWidth.value(),
                "hide_background":
                self.hide_background_check_box.checkState()
            }, lambda config: [
                self.spin_field_width.setValue(config["width"]),
                self.spin_field_length.setValue(config["length"]),
                self.spin_field_lineWidth.setValue(config["lineWidth"]),
                self.spin_field_penaltyMarkerSize.setValue(config[
                    "penaltyMarkerSize"]),
                self.spin_field_penaltyMarkerDistance.setValue(config[
                    "penaltyMarkerDistance"]),
                self.spin_field_goalBoxAreaLength.setValue(config[
                    "goalBoxAreaLength"]),
                self.spin_field_goalBoxAreaWidth.setValue(config[
                    "goalBoxAreaWidth"]),
                self.spin_field_penaltyAreaLength.setValue(config[
                    "penaltyAreaLength"]),
                self.spin_field_penaltyAreaWidth.setValue(config[
                    "penaltyAreaWidth"]),
                self.spin_field_centerCircleDiameter.setValue(config[
                    "centerCircleDiameter"]),
                self.spin_field_borderStripWidth.setValue(config[
                    "borderStripWidth"]),
                self.hide_background_check_box.setChecked(config[
                    "hide_background"])
            ]),
            "goal": (lambda: {
                "postDiameter": self.spin_goal_postDiameter.value(),
                "height": self.spin_goal_height.value(),
                "innerWidth": self.spin_goal_innerWidth.value(),
                "depth": self.spin_goal_depth.value()
            }, lambda config: [
                self.spin_goal_postDiameter.setValue(config["postDiameter"]),
                self.spin_goal_height.setValue(config["height"]),
                self.spin_goal_innerWidth.setValue(config["innerWidth"]),
                self.spin_goal_depth.setValue(config["depth"])
            ])
        }

        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)

        self.fill_field_type_menu()
        self.reset_widgets()
Beispiel #27
0
    def __init__(self, layer_model, parent, update_callback, nao: Nao):
        super(Config, self).__init__(parent)
        ui_utils.loadUi(__file__, self)

        self.layer_model = ui_utils.load_model(
            os.path.dirname(__file__) + "/model.json", layer_model)
        self.update_callback = update_callback
        self.nao = nao
        self.identifier = uuid.uuid4()

        self.config_to_ui = {
            "center_x": (lambda: self.spin_center_x.value(),
                         lambda value: self.spin_center_x.setValue(value)),
            "center_y": (lambda: self.spin_center_y.value(),
                         lambda value: self.spin_center_y.setValue(value)),
            "transformation":
            (lambda: {
                "key": self.cbx_TransformationKey.currentText(),
                "key_lambda": self.edit_TransformationKeyLambda.toPlainText()
            }, lambda config: [
                self.cbx_TransformationKey.setCurrentText(config["key"]),
                self.edit_TransformationKeyLambda.setPlainText(config[
                    "key_lambda"])
            ]),
            "obstacles": (lambda: {
                "key":
                self.cbx_ObstacleDataKey.currentText(),
                "key_lambda":
                self.edit_ObstacleDataKeyLambda.toPlainText(),
                "goalPostColor":
                self.edit_goalPostColor.text(),
                "unknownColor":
                self.edit_unknownColor.text(),
                "anonymousRobotColor":
                self.edit_anonymousRobotColor.text(),
                "hostileRobotColor":
                self.edit_hostileRobotColor.text(),
                "teamRobotColor":
                self.edit_teamRobotColor.text(),
                "fallenAnonymousRobotColor":
                self.edit_fallenAnonymousRobotColor.text(),
                "fallenHostileRobotColor":
                self.edit_fallenHostileRobotColor.text(),
                "fallenTeamRobotColor":
                self.edit_fallenTeamRobotColor.text(),
                "ballColor":
                self.edit_ballColor.text(),
                "freeKickAreaColor":
                self.edit_freeKickAreaColor.text(),
                "penWidth":
                self.spin_penWidth.value()
            }, lambda config: [
                self.cbx_ObstacleDataKey.setCurrentText(config["key"]),
                self.edit_ObstacleDataKeyLambda.setPlainText(config[
                    "key_lambda"]),
                ui_utils.reset_textField_color(self.edit_goalPostColor, config[
                    "goalPostColor"]),
                ui_utils.reset_textField_color(self.edit_unknownColor, config[
                    "unknownColor"]),
                ui_utils.reset_textField_color(self.edit_anonymousRobotColor,
                                               config["anonymousRobotColor"]),
                ui_utils.reset_textField_color(self.edit_hostileRobotColor,
                                               config["hostileRobotColor"]),
                ui_utils.reset_textField_color(self.edit_teamRobotColor,
                                               config["teamRobotColor"]),
                ui_utils.reset_textField_color(
                    self.edit_fallenAnonymousRobotColor, config[
                        "fallenAnonymousRobotColor"]),
                ui_utils.reset_textField_color(
                    self.edit_fallenHostileRobotColor, config[
                        "fallenHostileRobotColor"]),
                ui_utils.reset_textField_color(self.edit_fallenTeamRobotColor,
                                               config["fallenTeamRobotColor"]),
                ui_utils.reset_textField_color(self.edit_ballColor, config[
                    "ballColor"]),
                ui_utils.reset_textField_color(self.edit_freeKickAreaColor,
                                               config["freeKickAreaColor"]),
                self.spin_penWidth.setValue(config["penWidth"])
            ])
        }
        self.cbx_TransformationKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_TransformationKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        self.cbx_ObstacleDataKey.completer().setFilterMode(
            qtc.Qt.MatchContains)
        self.cbx_ObstacleDataKey.completer().setCompletionMode(
            qtw.QCompleter.PopupCompletion)
        ui_utils.init_Color_UI(self.btn_goalPostColor, self.edit_goalPostColor)
        ui_utils.init_Color_UI(self.btn_unknownColor, self.edit_unknownColor)
        ui_utils.init_Color_UI(self.btn_anonymousRobotColor,
                               self.edit_anonymousRobotColor)
        ui_utils.init_Color_UI(self.btn_hostileRobotColor,
                               self.edit_hostileRobotColor)
        ui_utils.init_Color_UI(self.btn_teamRobotColor,
                               self.edit_teamRobotColor)
        ui_utils.init_Color_UI(self.btn_fallenAnonymousRobotColor,
                               self.edit_fallenAnonymousRobotColor)
        ui_utils.init_Color_UI(self.btn_fallenHostileRobotColor,
                               self.edit_fallenHostileRobotColor)
        ui_utils.init_Color_UI(self.btn_fallenTeamRobotColor,
                               self.edit_fallenTeamRobotColor)
        ui_utils.init_Color_UI(self.btn_ballColor, self.edit_ballColor)
        ui_utils.init_Color_UI(self.btn_freeKickAreaColor,
                               self.edit_freeKickAreaColor)
        self.btnAccept.pressed.connect(self.accept)
        self.btnDiscard.pressed.connect(self.discard)
        self.reset_widgets()
        if self.nao.is_connected():
            self.connect(self.nao)