客户希望能在机器人进入/离开对应干涉区时在信息栏给出提示,如上图所示。
客户可以加载以下lua代码并运行即可。
-- author:chenliao@elibot.cn -- 20220705 local recv, ret, recv2 local m = {} local m_pre = {} function Init() recv ,ret=get_robot_register (55) recv2 ,ret=get_robot_register (56) for i = 1, 8, 1 do if (recv & (2 ^ (i - 1)) > 0) then m[i] = 1 else m[i] = 0 end end for i = 1, 8, 1 do if (recv2 & (2 ^ (i - 1)) > 0) then m[i + 8] = 1 else m[i + 8] = 0 end end for i=1,16,1 do m_pre[i] = m[i] end end Init() while true do recv ,ret=get_robot_register (55) recv2 ,ret=get_robot_register (56) for i = 1, 8, 1 do if (recv & (2 ^ (i - 1)) > 0) then m[i] = 1 else m[i] = 0 end end for i = 1, 8, 1 do if (recv2 & (2 ^ (i - 1)) > 0) then m[i + 8] = 1 else m[i + 8] = 0 end end for i=1,16,1 do if(m[i]==1) and (m_pre[i]==0) then elite_print('Robot Enter InterZone'..i) elseif(m[i]==0) and (m_pre[i]==1) then elite_print('Robot Leave InterZone'..i) end end for i=1,16,1 do m_pre[i] = m[i] end sleep(0.5)
更多点击埃斯顿机器人