update 加入并行拍照,加入平滑
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import copy
|
||||
import logging
|
||||
import threading
|
||||
import time
|
||||
|
||||
import cv2
|
||||
@ -9,6 +10,7 @@ from PySide6.QtCore import Signal, QObject
|
||||
import Constant
|
||||
import Expection
|
||||
from CU.Catch import Catch, CatchStatus
|
||||
from CU.Detect import Detect, DetectStatus
|
||||
from Model.FeedModel import PositionModel
|
||||
from Model.Position import Real_Position, Detection_Position
|
||||
from enum import Enum, IntEnum
|
||||
@ -185,6 +187,9 @@ class Feeding(QObject):
|
||||
self.pos_index = -1
|
||||
self.pos_near_index = -1
|
||||
self.catch = Catch(self.robotClient)
|
||||
self.detect = Detect(self.detection)
|
||||
self.detect_thread_img = threading.Thread(target=self.detect.run)
|
||||
self.detect_thread_img.start()
|
||||
pass
|
||||
|
||||
def init_detection_image(self):
|
||||
@ -258,12 +263,11 @@ class Feeding(QObject):
|
||||
return
|
||||
|
||||
self.feedConfig.feedLine.get_position_list()
|
||||
|
||||
self.detect.detect_status = DetectStatus.DNone
|
||||
# = self.detection.get_position(Point_isVision=False, Box_isPoint=True, First_Depth=True, Iter_Max_Pixel=30,
|
||||
# # save_img_point=0, Height_reduce=30, width_reduce=30)
|
||||
|
||||
if self.feedConfig.feedLine.get_take_position().get_position() != None:
|
||||
self.feedConfig.feedLine.set_take_position(self.get_take_position())
|
||||
|
||||
# TODO 获取目标位置
|
||||
#
|
||||
self.feed_Mid_Status = FeedMidStatus.FMid_Start
|
||||
@ -291,7 +295,17 @@ class Feeding(QObject):
|
||||
|
||||
if self.robotClient.type_detection == DetectType.EyeOutHand:
|
||||
self.feed_Mid_Status = FeedMidStatus.FMid_Feed
|
||||
self.next_position()
|
||||
if self.detect.detect_status == DetectStatus.DNone:
|
||||
self.detect.detect_status = DetectStatus.DDetect
|
||||
elif self.detect.detect_status == DetectStatus.DOk:
|
||||
if self.detect.detect_position != None:
|
||||
log.log_message(logging.INFO, Constant.str_feed_takePhoto_success)
|
||||
self.feedConfig.feedLine.set_take_position(self.detect.detect_position)
|
||||
self.next_position()
|
||||
self.detect.detect_status = DetectStatus.DNone
|
||||
else:
|
||||
log.log_message(logging.ERROR, Constant.str_feed_takePhoto_fail)
|
||||
self.take_no_photo_sigal.emit()
|
||||
return
|
||||
detect_pos_list = []
|
||||
if not Constant.Debug:
|
||||
@ -386,10 +400,11 @@ class Feeding(QObject):
|
||||
else:
|
||||
log.log_message(logging.ERROR, Constant.str_feed_takePhoto_fail)
|
||||
# self.take_no_photo = True
|
||||
self.take_no_photo_sigal.emit()
|
||||
|
||||
# 继续获取图像
|
||||
# TODO
|
||||
self.feedConfig.feedLine.set_take_position(self.get_take_position())
|
||||
# self.feedConfig.feedLine.set_take_position(self.get_take_position())
|
||||
|
||||
|
||||
|
||||
|
||||
@ -437,7 +452,9 @@ class Feeding(QObject):
|
||||
self.catch.catch_status = CatchStatus.CNone
|
||||
time.sleep(self.robotClient.time_delay_put)
|
||||
# self.detection.get_position(Point_isVision=False, Box_isPoint=True, First_Depth=True, Iter_Max_Pixel=30, save_img_point=0, Height_reduce=30, width_reduce=30)
|
||||
self.feedConfig.feedLine.set_take_position(self.get_take_position())
|
||||
# self.feedConfig.feedLine.set_take_position(self.get_take_position())
|
||||
if self.detect.detect_status == DetectStatus.DNone:
|
||||
self.detect.detect_status = DetectStatus.DDetect
|
||||
self.feedConfig.num = self.feedConfig.num - 1
|
||||
log.log_message(logging.INFO, f'{Constant.str_feed_feed_num}{self.feedConfig.num}')
|
||||
self.next_position()
|
||||
@ -607,6 +624,7 @@ class Feeding(QObject):
|
||||
position_instruction.m3 = real_position.U
|
||||
position_instruction.m4 = real_position.V
|
||||
position_instruction.m5 = real_position.W
|
||||
position_instruction.smooth = 4
|
||||
|
||||
position_instruction.action = move_type.value
|
||||
if position_instruction.action == 17:
|
||||
@ -636,18 +654,18 @@ class Feeding(QObject):
|
||||
|
||||
self.robotClient.add_sendQuene(request_command)
|
||||
pass
|
||||
def get_take_position(self):
|
||||
if Constant.Debug:
|
||||
return self.robotClient.status_model.getRealPosition()
|
||||
_, img, xyz, uvw, points = self.detection.get_position(Point_isVision=False, Box_isPoint=True, First_Depth=True, Iter_Max_Pixel=30,save_img_point=0, Height_reduce=30, width_reduce=30)
|
||||
self.detection_image = img.copy()
|
||||
if xyz ==None or uvw==None or points==None:
|
||||
return None
|
||||
target_position,noraml_base = getPosition(*xyz,*uvw,None,points)
|
||||
|
||||
position = Real_Position().init_position(*target_position[:3],*noraml_base[:3])
|
||||
position.Z = position.Z+200
|
||||
return position
|
||||
# def get_take_position(self):
|
||||
# if Constant.Debug:
|
||||
# return self.robotClient.status_model.getRealPosition()
|
||||
# _, img, xyz, uvw, points = self.detection.get_position(Point_isVision=False, Box_isPoint=True, First_Depth=True, Iter_Max_Pixel=30,save_img_point=0, Height_reduce=30, width_reduce=30)
|
||||
# self.detection_image = img.copy()
|
||||
# if xyz ==None or uvw==None or points==None:
|
||||
# return None
|
||||
# target_position,noraml_base = getPosition(*xyz,*uvw,None,points)
|
||||
#
|
||||
# position = Real_Position().init_position(*target_position[:3],*noraml_base[:3])
|
||||
# position.Z = position.Z+200
|
||||
# return position
|
||||
def next_start(self,reverse=False):
|
||||
start_pos = self.feedConfig.feedLine.get_next_start_position(reverse)
|
||||
self.feedStatus = FeedStatus(start_pos.status) if self.feedStatus != FeedStatus.FNone else FeedStatus.FNone
|
||||
|
||||
Reference in New Issue
Block a user