Skip to content

Commit 316db8a

Browse files
authored
Merge pull request #8 from elephantrobotics/riscv-opt
修复其他机型无法正常运行程序问题
2 parents 7ebc80d + a3ca8ae commit 316db8a

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

main.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from libraries.log import logfile
2323
from libraries.pyqtFile.AiKit_auto import Ui_AiKit_UI as AiKit_window
24-
from libraries.yolov8File.yolov8_detect import YOLODetection
2524
import pymycobot
2625
from packaging import version
2726

@@ -170,24 +169,15 @@ def _init_variable(self):
170169
# yolov8 model and label file path (only for 280 RISCV)
171170
self.yolov8_model_path = libraries_path + '/yolov8File/yolov8n.q.onnx'
172171
self.yolov8_label_path = libraries_path + '/yolov8File/yolov8_label.txt'
173-
self.yolov8_detect = YOLODetection(self.yolov8_model_path, self.yolov8_label_path)
172+
self.yolov8_detect = None
174173

175174
self.is_picking = False # 初始化是否正在抓取标志-yolov8
176175
self.cooldown_counter = 0 # 新增冷却计数器(单位:帧)- yolov8
177176
self.detect_history = deque(maxlen=5) # 存放最近5帧识别结果 - yolov8
178177

179-
self.mycobot_riscv = open("/sys/devices/soc0/machine").read().strip() == "spacemit k1-x RV4B board"
180-
if self.mycobot_riscv:
181-
from gpiozero.pins.lgpio import LGPIOFactory
182-
from gpiozero import Device, LED
183-
Device.pin_factory = LGPIOFactory(chip=0) # 显式指定/dev/gpiochip0
184-
# 初始化 GPIO 控制的设备
185-
self.pump = LED(71) # 气泵
186-
self.valve = LED(72) # 阀门
187-
self.pump.on() # 关闭泵
188-
time.sleep(0.05)
189-
self.valve.on() # 打开阀门
190-
time.sleep(1)
178+
self.pump = None
179+
self.valve =None
180+
191181

192182
self._init_ = 20
193183
self.init_num = 0
@@ -490,6 +480,19 @@ def buad_choose(self):
490480
self.camera_edit.setText('20')
491481

492482
self.set_comboBox_options_mutually_exclusive(self.comboBox_function, 'yolov8', 'yolov5')
483+
# self.mycobot_riscv = open("/sys/devices/soc0/machine").read().strip() == "spacemit k1-x RV4B board"
484+
from libraries.yolov8File.yolov8_detect import YOLODetection
485+
self.yolov8_detect = YOLODetection(self.yolov8_model_path, self.yolov8_label_path)
486+
from gpiozero.pins.lgpio import LGPIOFactory
487+
from gpiozero import Device, LED
488+
Device.pin_factory = LGPIOFactory(chip=0) # 显式指定/dev/gpiochip0
489+
# 初始化 GPIO 控制的设备
490+
self.pump = LED(71) # 气泵
491+
self.valve = LED(72) # 阀门
492+
self.pump.on() # 关闭泵
493+
time.sleep(0.05)
494+
self.valve.on() # 打开阀门
495+
time.sleep(1)
493496

494497
else:
495498
self.camera_edit.setText('0')

0 commit comments

Comments
 (0)