update 更新命令发送错误,自由路径配置失误,图片显示实物

This commit is contained in:
Gogs
2024-12-14 17:09:45 +08:00
parent 1efd0385e1
commit e2b60094b3
5 changed files with 115 additions and 82 deletions

View File

@ -36,13 +36,13 @@ class Catch:
if self.catch_status == CatchStatus.CShake:
if not self.shake_continue.Q(True, 2000):
shakeQ = self.shakePulse.Q(True, 100, 100)
self.robotClient.sendIOControl(self.robotClient.con_ios[2], shakeQ)
self.robotClient.sendIOControl(self.robotClient.con_ios[2], 1 if shakeQ else 0)
print("正在震动" if shakeQ else "震动结束")
else:
self.shake_continue.SetReset()
self.catch_status = CatchStatus.COk
if Constant.Debug or self.robotClient.check_outputQ(self.robotClient.con_ios[2]):
self.robotClient.sendIOControl(self.robotClient.con_ios[2], False)
self.robotClient.sendIOControl(self.robotClient.con_ios[2], 0)
print("震动结束")
if self.catch_status == CatchStatus.COk:

View File

@ -180,7 +180,7 @@ class Feeding(QObject):
self.reset_status = ResetStatus.RNone
self.reversed_positions = []
self.current_position = None
self.index=1
self.pos_index = -1
self.pos_near_index = -1
self.catch = Catch(self.robotClient)
@ -206,6 +206,12 @@ class Feeding(QObject):
# 0,
# 0);
img_path = f'Image/{self.index}.png'
img = cv2.imread(img_path)
self.index += 1
self.index = self.index % 4
self.detection_image = img
if self.feedConfig == None:
self.feedStatus = FeedStatus.FNone
@ -655,7 +661,7 @@ class Feeding(QObject):
self.feedStatus = None
log.log_message(logging.ERROR, Constant.str_feed_angle_error)
else:
self.sendTargPosition(real_position=start_pos.get_position(),speed=self.robotClient.debug_speed,move_type=MoveType.WORLD)
self.sendTargPosition(real_position=start_pos.get_position(),speed=self.robotClient.debug_speed,move_type=MoveType.AXIS)
else:
self.sendTargPosition(real_position=start_pos.get_position(),speed=self.robotClient.debug_speed)
pass

View File

@ -3,17 +3,17 @@ id = 1
name = 反应釜1
[Position2]
x = 421.397
y = 2095.76
z = 1403.803
u = 2.787
v = 17.14
w = -95.084
x = 2.734364
y = -0.014967
z = -0.353024
u = -19.845549
v = -21.947229
w = 2.585297
id = 2
order = 0
lineid = 1
status = 3
linetype = 2
linetype = 4
[FeedLine2]
id = 2
@ -33,119 +33,132 @@ status = 3
linetype = 0
[Position5]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.6604
y = -7.213258
z = 728.627869
u = -156.791855
v = 64.281898
w = -157.13649
id = 5
order = 2
order = 3
lineid = 1
status = 4
linetype = 0
[Position4]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.677979
y = -24.01004
z = 730.956055
u = -141.801926
v = 60.324791
w = -143.841553
id = 4
order = 3
order = 4
lineid = 1
status = 2
status = 3
linetype = 0
[Position1]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.6604
y = -7.213258
z = 728.627869
u = -156.791855
v = 64.281898
w = -157.13649
id = 1
order = 4
order = 5
lineid = 1
status = 5
linetype = 0
[Position6]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.677979
y = -24.01004
z = 730.956055
u = -141.801926
v = 60.324791
w = -143.841553
id = 6
order = 1
order = 2
lineid = 1
status = 2
linetype = 0
[Position7]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.677979
y = -24.01004
z = 730.956055
u = -141.801926
v = 60.324791
w = -143.841553
id = 7
order = 5
order = 6
lineid = 1
status = 6
linetype = 0
[Position8]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.6604
y = -7.213258
z = 728.627869
u = -156.791855
v = 64.281898
w = -157.13649
id = 8
order = 6
order = 7
lineid = 1
status = 7
linetype = 0
[Position9]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.677979
y = -24.01004
z = 730.956055
u = -141.801926
v = 60.324791
w = -143.841553
id = 9
order = 7
order = 8
lineid = 1
status = 8
linetype = 0
[Position10]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.6604
y = -7.213258
z = 728.627869
u = -156.791855
v = 64.281898
w = -157.13649
id = 10
order = 8
order = 9
lineid = 1
status = 9
linetype = 0
[Position11]
x = 7.0
y = 50.0
z = 1.0
u = 12.0
v = 0.0
w = 1.0
x = 693.677979
y = -24.01004
z = 730.956055
u = -141.801926
v = 60.324791
w = -143.841553
id = 11
order = 9
order = 10
lineid = 1
status = 3
linetype = 0
[Position12]
x = 2.719969
y = 0.0
z = -0.338814
u = -34.504669
v = -21.932972
w = 2.570882
id = 12
order = 1
lineid = 1
status = 3
linetype = 4

View File

@ -1,13 +1,23 @@
import logging
import cv2
from PIL.ImageQt import QImage, QPixmap
from Util.util_log import log
def cv2_to_qpixmap(cv_img):
"""将OpenCV图像转换为QPixmap"""
height, width, channel = cv_img.shape
bytes_per_line = 3 * width
q_img = QImage(cv_img.data, width, height, bytes_per_line, QImage.Format_RGB888)
return QPixmap.fromImage(q_img)
# img = cv_img.copy()
# cv_img = cv2.cvtColor(cv_img, cv2.COLOR_BGR2RGB)
try:
height, width, channel = cv_img.shape
bytes_per_line = 3 * width
q_img = QImage(cv_img.data, width, height, bytes_per_line, QImage.Format_RGB888)
return QPixmap.fromImage(q_img)
except Exception as e:
log.log_message(logging.ERROR,e)
return None
# def cv2_to_qpixmap(cv_img):
# """将OpenCV图像转换为QPixmap"""

10
main.py
View File

@ -8,6 +8,7 @@ from multiprocessing import Process
import traceback
import PySide6
import cv2
from PyQt5.uic.properties import QtWidgets
from PySide6 import QtCore
from PySide6.QtCore import QThread, Signal, Slot, QObject, QEvent, QTimer
@ -589,6 +590,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.main_threading = None
self.detection_person = None # DetectionPerson()
self.cton_take_no_photo = CRisOrFall()
self.index = 1
self.configReader.read(Constant.set_ini)
ip = self.configReader.get('Robot_Feed', 'IPAddress')
@ -1035,9 +1037,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.robotClient.time_delay_shake = time_delay_shake
self.configReader = configparser.ConfigParser()
self.configReader.read(Constant.set_ini)
self.configReader.set('Robot_Feed', 'solenoid_valve1_addr', str(take_addr))
self.configReader.set('Robot_Feed', 'solenoid_valve2_addr', str(press_addr))
self.configReader.set('Robot_Feed', 'solenoid_valve3_addr', str(shake_addr))
self.configReader.set('Robot_Feed', 'io_take_addr', str(take_addr))
self.configReader.set('Robot_Feed', 'io_zip_addr', str(press_addr))
self.configReader.set('Robot_Feed', 'io_shake_addr', str(shake_addr))
self.configReader.set('Robot_Feed', 'takeDelay', str(time_delay_take))
self.configReader.set('Robot_Feed', 'putDelay', str(time_delay_put))
self.configReader.set('Robot_Feed', 'shakeDelay', str(time_delay_shake))
@ -1409,6 +1411,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
pass
def updateUI_label_detection(self):
backgroud_img = Util.util_pic.cv2_to_qpixmap(self.feeding.detection_image)
if backgroud_img == None:
return
backgroud_img = backgroud_img.scaled(self.label_showDetection.size().width(),self.label_showDetection.size().height(), Qt.AspectRatioMode.IgnoreAspectRatio,Qt.TransformationMode.SmoothTransformation)
self.label_showDetection.setPixmap(backgroud_img)