Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable IMU #726

Open
wants to merge 5 commits into
base: UI-test-tools-Production-gen2
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ def __init__(self):
self.imu = self.pipeline.create(dai.node.IMU)
self.xoutIMU = self.pipeline.create(dai.node.XLinkOut)
self.xoutIMU.setStreamName("IMU")
if 'lite' in test_type:
self.imu.enableFirmwareUpdate(True)
self.imu.enableFirmwareUpdate(True)
self.imu.enableIMUSensor(dai.IMUSensor.ACCELEROMETER_RAW, 500)
self.imu.setBatchReportThreshold(1)
self.imu.setMaxBatchReports(10)
self.imu.out.link(self.xoutIMU.input)



self.videoEnc = self.pipeline.create(dai.node.VideoEncoder)
self.camRgb.video.link(self.videoEnc.input)
self.xoutJpeg = self.pipeline.create(dai.node.XLinkOut)
Expand Down Expand Up @@ -957,14 +954,16 @@ def setupUi(self):
self.update_imu = True
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.set_result)
self.timer.start(1000//FPS)
self.timer.start(100)

# self.connect_timer = QtCore.QTimer()
# self.connect_timer.connect(test_connexion)
# self.timer.stop()

self.threadpool = QThreadPool()
self.scanning = False
self.last_progress_val = 0.0
self.cycle = 0

def retranslateUi(self, UI_tests):
_translate = QtCore.QCoreApplication.translate
Expand Down Expand Up @@ -1076,11 +1075,11 @@ def connexion_slot(self, signal):
self.print_logs('No camera detected, check the connexion and try again...', 'ERROR')
return
self.print_logs('Camera connected, starting tests...', 'GREEN')
# self.connect_but.setText("FLASHING")
# self.connect_but.adjustSize()
# self.connect_but.setChecked(False)
# self.connect_but.setCheckable(False)
# self.connect_but.setEnabled(False)
self.connect_but.setText("FLASHING")
self.connect_but.adjustSize()
self.connect_but.setChecked(False)
self.connect_but.setCheckable(False)
self.connect_but.setEnabled(False)
# Update BL if PoE
# if test_type == 'OAK-D-PRO-POE':
eeprom_written = False
Expand All @@ -1093,7 +1092,12 @@ def connexion_slot(self, signal):
usbBootHeader = [77, 65, 50, 120, 176, 0, 0, 0, 128, 10, 0, 0,
0, 0, 0, 0, 0, 58, 32, 95, 6, 0, 0, 0, 0]
self.print_logs('NOR flash: writing USB boot header...')
device.flashWrite(usbBootHeader)
try:
device.flashWrite(usbBootHeader)
except RuntimeError as ex:
self.print_logs(f'SPI Flash failed! - {ex}', log_level='ERROR')
self.update_imu = False
return
self.print_logs('Programmed, data: '+ str(device.flashRead(len(usbBootHeader))))

if not eeprom_written:
Expand All @@ -1107,18 +1111,19 @@ def connexion_slot(self, signal):

except RuntimeError as ex:
self.print_logs(f"Something went wrong, check connexion! - {ex}", log_level='ERROR')
self.update_imu = False
return
# self.update_imu = True
# if imu_upgrade:
# self.depth_camera.device.setLogLevel(dai.LogLevel.INFO)
# self.depth_camera.device.addLogCallback(self.logMonitorImuFwUpdateCallback)
# else:
self.connect_but.setChecked(False)
self.connect_but.setCheckable(True)
self.connect_but.setEnabled(True)
self.connect_but.setText('DISCONNECT AND SAVE')
self.connect_but.adjustSize()
self.update_imu = True
if imu_upgrade:
self.depth_camera.device.setLogLevel(dai.LogLevel.INFO)
self.depth_camera.device.addLogCallback(self.logMonitorImuFwUpdateCallback)
else:
self.connect_but.setChecked(False)
self.connect_but.setCheckable(True)
self.connect_but.setEnabled(True)
self.connect_but.setText('DISCONNECT AND SAVE')
self.connect_but.adjustSize()
self.update_imu = True
location = WIDTH, 0
self.rgb = Camera(lambda: self.depth_camera.get_image('RGB'), colorMode, 'RGB Preview', location)
self.rgb.show()
Expand Down Expand Up @@ -1153,6 +1158,13 @@ def connexion_slot(self, signal):

def set_result(self):
global update_res
if not self.connect_but.isCheckable() and self.prog_bar.value() == self.last_progress_val:
self.cycle += 1
else:
self.cycle = 0
self.last_progress_val = self.prog_bar.value()
if self.cycle >= 100:
self.update_imu = False
if not self.update_imu:
self.connect_but.setChecked(False)
self.connect_but.setCheckable(True)
Expand Down Expand Up @@ -1319,6 +1331,11 @@ def logMonitorImuFwUpdateCallback(self, msg):
self.update_imu = False

if 'IMU firmware update failed' in msg.payload:
if "Your board likely doesn't have IMU!" in msg.payload:
self.print_logs_trigger.emit('IMU Upgrade not supported')
self.prog_label.setText('SKIP IMU')
self.update_imu = False
return
self.prog_label.setText('IMU FAIL')
self.update_prog_bar(0.0)
self.print_logs_trigger.emit(f'FAILED updating IMU!')
Expand Down