【ECEN009】Data Communication Between JBI and LUA

JBI and LUA in Elibot

JBI:

Elite collaborative robots use a specific script language called JBI (short for Job Instruction), developed

independently by Elite. Unlike Lua, JBI is the only language with robot motion control instructions,

including variables, logic, loops, calculation, IO monitoring, etc. JBI script can quickly share data

with soft PLC and Lua programs through M registers, global variables, etc. JBI scripts are stored in a

text file with a ”.jbi” extension, called a JOB.

LUA in Elibot:

The Lua script language is lightweight and small, written in standard C and open source, and is designed to be embedded in applications to provide flexibility in extending and customizing them

Elite use the Lua scripting language for calculation and communication. User can write normal LUA program, Elibot also provide some specific LUA instruction for Elibot(eg. get_robot_mode() )


How to do communication between LUA and JBI

There are 5 type global variable which user can use in the LUA and JBI(data value shared both in LUA and JBI

Use Global Variable in JBI

NOP
// Set Global variable B0 value as 1
SET B000 1
// Set Global variable I0 value as 1
SET I000 1
// Set Global variable D0 value as 1
SET D000 1
// Set Global variable P0(j1) value as 1
SET P000(0) 1
// Set Global variable V0(x) value as 1
SET V000(0) 1

// Set P000(8 data, j1 -j6(deg), data7 and data8 reserved)
SETJOINT P000 170.2074,-85.7738,102.0724,-104.2114,89.9468,-14.3515,0.0000,0.0000

// Set V000(x(mm),y,z,rx(rad),ry(rad),rz(rad))
SETPOSE V000 -517.8859,-34.5460,208.5253,3.1061,0.0081,1.6502

// Wait B0 = 0
WAIT B000=0
// WaitI0 = 0
WAIT I000=0
// WaitD0 = 0
WAIT D000=0
END

Use Global variable in LUA

-- get data from global variable
local b0 = get_global_variable("B0")
local i0 = get_global_variable("I0")
local d0 = get_global_variable("D0")

-- for P and V varible, user can get data like below 
local j7 = {}
j7[1],j7[2],j7[3],j7[4],j7[5],j7[6] = get_global_variable("P0")

local pose0 = {}
pose0[1],pose0[2],pose0[3],pose0[4],pose0[5],pose0[6] = get_global_variable("V0")

local j1,j2,j3,j4,j5,j6 = get_global_variable("P0")
local p0 = {j1, j2, j3, j4, j5, j6}

local v0 = {get_global_variable("V0")}


-- Set Global variable value
-- Set B0 as 1
set_global_variable("B0", 1)
-- set D0 as 1
set_global_variable("D0", 1)
-- Set I0 as 1
set_global_variable("I0", 1)

-- Set P0 value as 1,2,3,4,5,6
-- Because P variable has 8 element, so user have to set data in element7 and element8
set_global_variable("P0", 1, 2, 3, 4, 5, 6,0,0)
-- Set V0 value as 1,2,3,4,5,6
set_global_variable("V0", 1, 2, 3, 4, 5, 6)

Communication Between JBI and LUA

JBI program

NOP
// Set data
SET D000 0
SET D001 -90
SET D002 0
SET D003 -90
SET D004 90
SET D005 0

// Set B001 as 1, start LUA (LUA now is waitting B001=1)
SET B001 1

// Wait LUA to set B001=0
WAIT B001=0
TIMER T=0.002 S
MOVJ P001 VJ=30% CR=0.0MM ACC=50 DEC=50
END

LUA program

sleep(1)
elite_print("runing")

-- wait JBI to set B1 as 1
repeat
    elite_print("Waiting B1 == 1!")
until (get_global_variable("B1") == 1)

-- get global variable 
local j1 = get_global_variable("D0")
local j2 = get_global_variable("D1")
local j3 = get_global_variable("D2")
local j4 = get_global_variable("D3")
local j5 = get_global_variable("D4")
local j6 = get_global_variable("D5")

set_global_variable("P1", j1, j2, j3, j4, j5, j6, 0, 0)

set_global_variable("B1", 0)

elite_print("done")

Both JBI and LUA start,

LUA will wait JBI to set B1=1,

then LUA get some global variable and set global variable P1,

after LUA set global variabe B1=0(JBI is waiting B1=0),

JBI will run next instruction

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

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