LUA生成JBI轨迹程序文件


例如LUA 接收到机器人的一段轨迹点位,那么可以通过lua讲点位转成JBI程序轨迹。

前台JBI只需要等待lua转化完,并调用新的轨迹即可。

JBI程序,

NOP
SET B001 0
TIMER T=1 S
SET B001 1
// 请求lua开始转化并生成 轨迹jbi程序
// 等待lua转化完成
WAIT B001=0
CALL JOB:Alson1
// 调用新生成的Alson.jbi程序
END

generateJBI.lua 后台程序

sleep(0.3)

Pose_arr = {{400,12.543,25.9139,2.30554,-0.00000,-3.14159},
{400,25.9819,36.2783,2.48465,-0.00000,-3.14159},
{400,40.0492,43.015,2.69498,-0.00000,-3.14159},
{400,55.475,46.1574,2.94063,-0.00000,-3.14159},
{400,72.1395,45.5849,-3.10724,-0.00000,3.14159},
{400,92.1442,41.2421,-2.92782,-0.00000,3.14159},
{400,131.193,28.7256,-2.83139,-0.00000,3.14159},
{400,158.247,21.5695,-2.88300,-0.00000,3.14159},
{400,179.531,18.4946,-2.99811,-0.00000,3.14159},
{400,200,18.3181,-3.13297,-0.00000,3.14159},
{400,220.469,18.4946,3.13297,-0.00000,-3.14159},
{400,241.753,21.5695,2.99811,-0.00000,-3.14159},
{400,268.807,28.7256,2.88300,-0.00000,-3.14159},
{400,307.856,41.2421,2.83139,-0.00000,-3.14159},
{400,327.86,45.5849,2.92782,-0.00000,-3.14159},
{400,344.525,46.1574,3.10724,-0.00000,-3.14159},
{400,359.951,43.015,-2.94063,-0.00000,3.14159},
{400,374.018,36.2783,-2.69498,-0.00000,3.14159},
{400,387.457,25.9139,-2.48465,-0.00000,3.14159},
{400,400,12.0313,-2.30554,-0.00000,3.14159}}
-- 路径轨迹一共20个笛卡尔点

StartPos = {-54.169,-68.726,81.686,-61.057,115.744,25.829}
--起点,joint

user1 ={-70,-140,130,0.0,0.0,0.0} --用户坐标系
tool1 ={0,0,100,0.0,0.0,0.0} --工具


-- 用于MoveL中的运动参数
ACC = 20
DEC = 20
CR = 8.0
V = 50

function GenerateJBI(file1)
    local jbifile_out = {}
    table.insert(jbifile_out,'SETPOSE V000 '..table.concat(tool1, ","))
    table.insert(jbifile_out,'SETTOOLFRAME TOOL#(1) V000')
    -- 插入设置工具tool

    table.insert(jbifile_out,'SETPOSE V000 '..table.concat(user1, ","))
    table.insert(jbifile_out,'SETUSERFRAME USER #(1) V000')
    -- 插入设置user用户坐标系

    table.insert(jbifile_out,'MOVEJ VJ=100% CR=0.0MM ACC=20 DEC=20 ConstP=['..table.concat(StartPos, ",")..']')
    -- 插入movej

    for i = 1, #Pose_arr, 1 do
        table.insert(jbifile_out,'MOVEL V='..V..'MM/S CR='..CR..'MM ACC='..ACC..' DEC='..DEC..' TOOL#(1) USER#(1) ConstV=['..table.concat(Pose_arr[i], ",")..']')
    end
    -- 插入moveL

    filename = file1..'.jbi'
    file = io.open(filename, "w")
    io.output(file)

    table.insert(jbifile_out, 1, "NOP")
    table.insert(jbifile_out, "END")
    for i = 1, #jbifile_out, 1 do
        io.write(jbifile_out[i] .. "\n")
    end
    io.close(file)
    sleep(0.3)
    elite_print("生成程序" .. filename..'成功')
end

set_global_variable('B001',0)
while true do
    B001 = get_global_variable('B001')
    if B001 ==1 then
        
        GenerateJBI('Alson1')
        set_global_variable('B001',0)
        sleep(0.5)
    end
end

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

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