【CSEN007】Reservation function in CS model

The reservation function is basic in cobot system. It means that external controller could switch to a different task in next cycle without interrupting the executing task right now.

The default setting of CS model is event, which means it's step signal instead of edge signal. While for reservation function, usually the system use edge signal to trigger it and record it in some variables as flags. And when executing this task, it will clear flag signal.

Just as shown below, robot system decides tasks to execute based on the value of stn1 and stn2:

  • If di1 is a rising edge signal, set stn1 to true, and move to waypoint1 in main program
  • if di2 is a rising edge signal, set stn2 to true, and move to waypoint2 in main program

Event.script is as below:

def trap1():
global stn1
stn1 = True
# set global variable stn1 as True

def trap2():
global stn2
stn2 = True
# set global variable stn2 as True

pre_sig = get_standard_digital_in(1)
pre_sig2 = get_standard_digital_in(2)

while True:
sig = get_standard_digital_in(1)
# Get current di1
sig2 = get_standard_digital_in(2)
# Get current di2

if pre_sig==False and sig==True:
# if di1 is upper edge signal, enter trap1
trap1()
if pre_sig2==False and sig2==True:
trap2()
# if di2 is upper edge signal, enter trap2

pre_sig= sig
# keep current di1 as the old value of di1 of next cycle
pre_sig2 = sig2
# keep current di2 as the old value of di2 of next cycle
sleep(0.1)

点击显示全文
赞同0
发表评论
分享

手机扫码分享
0
389
收藏
举报
收起
登录
  • 密码登录
  • 验证码登录
还没有账号,立即注册
还没有账号,立即注册
注册
已有账号,立即登录
选择发帖板块
上传文件
举报
请选择举报理由
举报
举报说明