🚑 update 加入网络继电器控制 震动时同时运动
This commit is contained in:
50
CU/Catch.py
50
CU/Catch.py
@ -4,7 +4,7 @@ from enum import Enum
|
|||||||
import Constant
|
import Constant
|
||||||
from COM.COM_Robot import RobotClient
|
from COM.COM_Robot import RobotClient
|
||||||
from Util.util_time import CClockPulse, CTon
|
from Util.util_time import CClockPulse, CTon
|
||||||
|
from EMV import *
|
||||||
|
|
||||||
class CatchStatus(Enum):
|
class CatchStatus(Enum):
|
||||||
CNone = 0
|
CNone = 0
|
||||||
@ -32,7 +32,10 @@ class Catch:
|
|||||||
|
|
||||||
if self.catch_status == CatchStatus.CTake:
|
if self.catch_status == CatchStatus.CTake:
|
||||||
if not self.is_send_take_command:
|
if not self.is_send_take_command:
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[0],1)
|
# 本身IO
|
||||||
|
##self.robotClient.sendIOControl(self.robotClient.con_ios[0],1)
|
||||||
|
# 网络继电器
|
||||||
|
open(1, 0, 0)
|
||||||
self.is_send_take_command = True
|
self.is_send_take_command = True
|
||||||
else:
|
else:
|
||||||
if self.take_continue.Q(True,self.robotClient.time_delay_take*1000):
|
if self.take_continue.Q(True,self.robotClient.time_delay_take*1000):
|
||||||
@ -41,12 +44,19 @@ class Catch:
|
|||||||
|
|
||||||
if self.catch_status == CatchStatus.CDrop:
|
if self.catch_status == CatchStatus.CDrop:
|
||||||
if not self.is_send_command:
|
if not self.is_send_command:
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[0], 0)
|
# 本身IO
|
||||||
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[0], 0)
|
||||||
|
# 网络继电器
|
||||||
|
close(1, 0, 0)
|
||||||
for _ in range(self.drop_count):
|
for _ in range(self.drop_count):
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[1], 1, delay=self.robotClient.time_delay_put)
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[1], 1, delay=self.robotClient.time_delay_put)
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[1], 0)
|
open(0, 1, 0)
|
||||||
|
time.sleep(self.robotClient.time_delay_put) # 会造成这个时间点 其他命令插入不进去 需要另开线程
|
||||||
|
close(0, 1, 0)
|
||||||
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[1], 0)
|
||||||
|
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[1], 1)
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[1], 1)
|
||||||
|
open(0, 1, 0)
|
||||||
self.is_send_command = True
|
self.is_send_command = True
|
||||||
if self.drop_continue.Q(True,self.robotClient.time_delay_put*1000*self.drop_count):
|
if self.drop_continue.Q(True,self.robotClient.time_delay_put*1000*self.drop_count):
|
||||||
# if Constant.Debug or self.robotClient.check_outputQ(self.robotClient.con_ios[1]) and not self.robotClient.check_outputQ(self.robotClient.con_ios[0]):
|
# if Constant.Debug or self.robotClient.check_outputQ(self.robotClient.con_ios[1]) and not self.robotClient.check_outputQ(self.robotClient.con_ios[0]):
|
||||||
@ -54,19 +64,25 @@ class Catch:
|
|||||||
self.catch_status = CatchStatus.COk
|
self.catch_status = CatchStatus.COk
|
||||||
self.drop_continue.SetReset()
|
self.drop_continue.SetReset()
|
||||||
|
|
||||||
if self.catch_status == CatchStatus.CShake:
|
if self.catch_status == CatchStatus.CShake: # 1500
|
||||||
if not self.shake_continue.Q(True, 600): # 1500
|
|
||||||
self.shake_Q = not self.shake_Q # 10
|
self.shake_Q = not self.shake_Q # 10
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[2], 1 if self.shake_Q else 0)
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[2], 1 if self.shake_Q else 0)
|
||||||
else:
|
if self.shake_Q:
|
||||||
self.shake_continue.SetReset()
|
open(0, 0, 1)
|
||||||
self.catch_status = CatchStatus.COk
|
else:
|
||||||
#if Constant.Debug or self.robotClient.check_outputQ(self.robotClient.con_ios[2]):
|
close(0, 0, 1)
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[2], 0)
|
# else:
|
||||||
print("震动结束")
|
# 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], 0)
|
||||||
|
# close(0, 0, 1)
|
||||||
|
# print("震动结束")
|
||||||
|
|
||||||
if self.catch_status == CatchStatus.COk:
|
if self.catch_status == CatchStatus.COk :
|
||||||
self.robotClient.sendIOControl(self.robotClient.con_ios[1], 0,emptyList='1')
|
# self.robotClient.sendIOControl(self.robotClient.con_ios[1], 0,emptyList='1')
|
||||||
|
close(0, 1, 0)
|
||||||
|
close(0, 0, 1)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,6 +39,7 @@ def open(grasp, throw, shake):
|
|||||||
if grasp:
|
if grasp:
|
||||||
print("打开电磁阀 1")#抓取
|
print("打开电磁阀 1")#抓取
|
||||||
send_command(valve_commands[1]['open'])
|
send_command(valve_commands[1]['open'])
|
||||||
|
#缺少反馈函数 不知道命令是否下发正确 是否需要等待延时
|
||||||
if throw:
|
if throw:
|
||||||
print("打开电磁阀 2")#扔袋
|
print("打开电磁阀 2")#扔袋
|
||||||
send_command(valve_commands[2]['open'])
|
send_command(valve_commands[2]['open'])
|
||||||
@ -59,4 +60,4 @@ def close(grasp, throw, shake ):
|
|||||||
print("关闭电磁阀 3")
|
print("关闭电磁阀 3")
|
||||||
send_command(valve_commands[3]['close'])
|
send_command(valve_commands[3]['close'])
|
||||||
|
|
||||||
close(True,True,True)#参数传True和False
|
# close(True,True,True)#参数传True和False
|
||||||
@ -491,6 +491,10 @@ class Feeding(QObject):
|
|||||||
return
|
return
|
||||||
if self.catch.catch_status == CatchStatus.CShake:
|
if self.catch.catch_status == CatchStatus.CShake:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.feedConfig.feedLine.start_to_take[self.feedConfig.feedLine.feeding2end_pos_index+1].status != FeedStatus.FShake:
|
||||||
|
self.catch.catch_status = CatchStatus.COk
|
||||||
|
|
||||||
if self.catch.catch_status == CatchStatus.COk:
|
if self.catch.catch_status == CatchStatus.COk:
|
||||||
self.catch.catch_status = CatchStatus.CNone
|
self.catch.catch_status = CatchStatus.CNone
|
||||||
self.next_position()
|
self.next_position()
|
||||||
|
|||||||
Reference in New Issue
Block a user