Example #1
0
    def restart_gl(self):
        self.imu_gl = IMUV23DWidget()

        self.imu_gl.setFixedSize(200, 200)
        self.gl_layout.addWidget(self.imu_gl)
        self.imu_gl.show()

        self.save_orientation.clicked.connect(self.save_orientation_clicked)
        self.imu_gl.set_state(self.state)
Example #2
0
    def __init__(self, plugin):
        super().__init__()

        self.plugin = plugin

        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        self.setMinimumSize(200, 200)
        self.glWidget = IMUV23DWidget()
        self.layout().addWidget(self.glWidget)
        self.setWindowTitle('3D View - IMU Brick 2.0 - Brick Viewer ' + config.BRICKV_VERSION)
Example #3
0
    def __init__(self, *args):
        PluginBase.__init__(self, BrickIMUV2, *args)

        self.setupUi(self)

        self.imu = self.device

        self.cbe_all_data = CallbackEmulator(self.imu.get_all_data, None,
                                             self.cb_all_data,
                                             self.increase_error_count)

        self.imu_gl = IMUV23DWidget(self)
        self.imu_gl.setFixedSize(200, 200)

        self.imu_gl_wrapper = None
        self.state = None

        self.data_plot_widget = []

        self.sensor_data = [CurveValueWrapper() for i in range(23)]

        self.data_labels = [
            self.label_acceleration_x, self.label_acceleration_y,
            self.label_acceleration_z, self.label_magnetic_field_x,
            self.label_magnetic_field_y, self.label_magnetic_field_z,
            self.label_angular_velocity_x, self.label_angular_velocity_y,
            self.label_angular_velocity_z, self.label_euler_angle_heading,
            self.label_euler_angle_roll, self.label_euler_angle_pitch,
            self.label_quaternion_w, self.label_quaternion_x,
            self.label_quaternion_y, self.label_quaternion_z,
            self.label_linear_acceleration_x, self.label_linear_acceleration_y,
            self.label_linear_acceleration_z, self.label_gravity_vector_x,
            self.label_gravity_vector_y, self.label_gravity_vector_z,
            self.label_temperature
        ]

        self.data_rows = [
            [
                self.label_acceleration_11, self.label_acceleration_21,
                self.label_acceleration_22, self.label_acceleration_23,
                self.label_acceleration_41, self.label_acceleration_42,
                self.label_acceleration_43, self.label_acceleration_x,
                self.label_acceleration_y, self.label_acceleration_z
            ],
            [
                self.label_magnetic_field_11, self.label_magnetic_field_21,
                self.label_magnetic_field_22, self.label_magnetic_field_23,
                self.label_magnetic_field_41, self.label_magnetic_field_42,
                self.label_magnetic_field_43, self.label_magnetic_field_x,
                self.label_magnetic_field_y, self.label_magnetic_field_z
            ],
            [
                self.label_angular_velocity_11, self.label_angular_velocity_21,
                self.label_angular_velocity_22, self.label_angular_velocity_23,
                self.label_angular_velocity_41, self.label_angular_velocity_42,
                self.label_angular_velocity_43, self.label_angular_velocity_x,
                self.label_angular_velocity_y, self.label_angular_velocity_z
            ],
            [
                self.label_euler_angle_11, self.label_euler_angle_21,
                self.label_euler_angle_22, self.label_euler_angle_23,
                self.label_euler_angle_41, self.label_euler_angle_42,
                self.label_euler_angle_43, self.label_euler_angle_roll,
                self.label_euler_angle_pitch, self.label_euler_angle_heading
            ],
            [
                self.label_quaternion_11, self.label_quaternion_21,
                self.label_quaternion_22, self.label_quaternion_23,
                self.label_quaternion_24, self.label_quaternion_41,
                self.label_quaternion_42, self.label_quaternion_43,
                self.label_quaternion_44, self.label_quaternion_w,
                self.label_quaternion_x, self.label_quaternion_y,
                self.label_quaternion_z
            ],
            [
                self.label_linear_acceleration_11,
                self.label_linear_acceleration_21,
                self.label_linear_acceleration_22,
                self.label_linear_acceleration_23,
                self.label_linear_acceleration_41,
                self.label_linear_acceleration_42,
                self.label_linear_acceleration_43,
                self.label_linear_acceleration_x,
                self.label_linear_acceleration_y,
                self.label_linear_acceleration_z
            ],
            [
                self.label_gravity_vector_11, self.label_gravity_vector_21,
                self.label_gravity_vector_22, self.label_gravity_vector_23,
                self.label_gravity_vector_41, self.label_gravity_vector_42,
                self.label_gravity_vector_43, self.label_gravity_vector_x,
                self.label_gravity_vector_y, self.label_gravity_vector_z
            ],
            [
                self.label_temperature_11, self.label_temperature_21,
                self.label_temperature_41, self.label_temperature
            ]
        ]

        even_color = QColor(240, 240, 240)
        odd_color = QColor(255, 255, 255)

        self.data_color = [(Qt.red, even_color), (Qt.darkGreen, even_color),
                           (Qt.blue, even_color), (Qt.red, odd_color),
                           (Qt.darkGreen, odd_color), (Qt.blue, odd_color),
                           (Qt.red, even_color), (Qt.darkGreen, even_color),
                           (Qt.blue, even_color), (Qt.red, odd_color),
                           (Qt.darkGreen, odd_color), (Qt.blue, odd_color),
                           (Qt.magenta, even_color), (Qt.red, even_color),
                           (Qt.darkGreen, even_color), (Qt.blue, even_color),
                           (Qt.red, odd_color), (Qt.darkGreen, odd_color),
                           (Qt.blue, odd_color), (Qt.red, even_color),
                           (Qt.darkGreen, even_color), (Qt.blue, even_color),
                           (Qt.magenta, odd_color)]

        even_palette = QPalette()
        even_palette.setColor(QPalette.Window, even_color)
        odd_palette = QPalette()
        odd_palette.setColor(QPalette.Window, odd_color)

        for i, row in enumerate(self.data_rows):
            for label in row:
                if i % 2:
                    label.setPalette(odd_palette)
                else:
                    label.setPalette(even_palette)

                label.setAutoFillBackground(True)

        self.plot_timer = QTimer(self)
        self.plot_timer.start(100)

        for i in range(23):
            self.data_plot_widget.append(
                PlotWidget(
                    "",
                    [("", self.data_color[i][0], self.sensor_data[i], str)],
                    clear_button=self.clear_graphs,
                    x_scale_visible=False,
                    y_scale_visible=False,
                    curve_outer_border_visible=False,
                    curve_motion='smooth',
                    canvas_color=self.data_color[i][1],
                    external_timer=self.plot_timer,
                    curve_start='right',
                    key=None,
                    y_resolution=0.01))

        for w in self.data_plot_widget:
            w.setMinimumHeight(15)
            w.setMaximumHeight(25)

        for i in range(23):
            self.data_grid.addWidget(self.data_plot_widget[i], i, 4)

        self.data_grid.setColumnMinimumWidth(2, 75)

        self.gl_layout = QVBoxLayout()
        self.gl_layout.addWidget(self.imu_gl)
        self.layout_bottom.addLayout(self.gl_layout)
        self.save_orientation.clicked.connect(self.save_orientation_clicked)
        self.button_detach_3d_view.clicked.connect(self.detach_3d_view_clicked)

        self.checkbox_leds.stateChanged.connect(self.led_clicked)
        self.button_calibration.clicked.connect(self.calibration_clicked)
        self.calibration_color = [
            Qt.red, QColor(0xFF, 0xA0, 0x00), Qt.yellow, Qt.darkGreen
        ]

        self.calibration = None
        self.alive = True
        self.callback_counter = 0

        self.status_led_action = QAction('Status LED', self)
        self.status_led_action.setCheckable(True)
        self.status_led_action.toggled.connect(
            lambda checked: self.imu.enable_status_led()
            if checked else self.imu.disable_status_led())
        self.set_configs([(0, None, [self.status_led_action])])

        reset = QAction('Reset', self)
        reset.triggered.connect(self.imu.reset)
        self.set_actions([(0, None, [reset])])