保存所有工具数据和用户坐标系数据到JBI文件

机器人的工具和用户坐标系数据实时保存到机器人控制器。

为避免误修改,可以使用以下lua代码,将所有tool和user数据保存到jbi。

用户在使用时,可以在初始化时加载该jbi并初始化tool和user数据

-- Author: chenliao@elibot.cn
-- May.5, 2023
function ArrFormat(data)
    for i = 1, #data, 1 do
        data[i] = tonumber(string.format('%.5f',data[i]))
    end
    return data
end

sleep(0.3)
file = io.open("SaveTCPUser.jbi", "w")
io.output(file)
TOOL ={}
USER = {}
for i=1,8,1  do
    TOOL[i] = ArrFormat(get_tool_frame(i-1))
    USER[i] = ArrFormat(get_user_frame(i-1))
end
io.write('NOP\n')
-- 以写入的方式打开文件
for i=1,8,1  do
    io.write('SETPOSE V000 '..table.concat(TOOL[i],',')..'\n')
    io.write('SETTOOLFRAME TOOL#('..NumToStr(i-1,0)..') V000\n')
end

for i=1,8,1  do
    io.write('SETPOSE V000 '..table.concat(USER[i],',')..'\n')
    io.write('SETUSERFRAME USER#('..NumToStr(i-1,0)..') V000\n')
end
io.write('TPWRITE finishTCPUserLoading\n')
io.write('END')

-- 关闭打开的文件
io.close(file)
elite_print('工具数据和用户坐标user已经保存到SaveTCPUser.jbi')

生成的jbi文件如下

NOP
SETPOSE V000 -8.51783,27.04674,107.66355,2.4543,0.15572,0.01
SETTOOLFRAME TOOL#(0) V000
SETPOSE V000 0.0,0.0,100.0,0.0,0.0,0.0
SETTOOLFRAME TOOL#(1) V000
SETPOSE V000 20.0,20.0,140.0,0.0,0.0,0.0
SETTOOLFRAME TOOL#(2) V000
SETPOSE V000 4.564,-10.972,104.88,-3.09457,-0.0011,-3.03909
SETTOOLFRAME TOOL#(3) V000
SETPOSE V000 -8.587,-20.964,124.772,0.01895,0.04555,-1.5816
SETTOOLFRAME TOOL#(4) V000
SETPOSE V000 -13.368,2.534,126.975,-0.12392,0.19256,-0.98944
SETTOOLFRAME TOOL#(5) V000
SETPOSE V000 -5.577,-17.511,121.213,-0.38671,0.45766,2.99549
SETTOOLFRAME TOOL#(6) V000
SETPOSE V000 0.0,0.0,0.0,0.0,0.0,0.0
SETTOOLFRAME TOOL#(7) V000
SETPOSE V000 374.30435,290.82212,4.38723,-3.14125,0.00021,2.59653
SETUSERFRAME USER#(0) V000
SETPOSE V000 -70.0,-140.0,130.0,0.0,0.0,0.0
SETUSERFRAME USER#(1) V000
SETPOSE V000 417.65824,-100.78387,2.12139,3.07298,-0.23625,2.10289
SETUSERFRAME USER#(2) V000
SETPOSE V000 499.44648,90.57778,83.2948,-0.57091,-0.72419,0.25855
SETUSERFRAME USER#(3) V000
SETPOSE V000 0.0,0.0,0.0,0.0,0.0,0.0
SETUSERFRAME USER#(4) V000
SETPOSE V000 0.0,0.0,0.0,0.0,0.0,0.0
SETUSERFRAME USER#(5) V000
SETPOSE V000 413.9767,-107.60183,43.44389,-3.14156,0.00012,2.11688
SETUSERFRAME USER#(6) V000
SETPOSE V000 415.13106,-115.85387,46.17371,-3.14155,-0.0,1.98335
SETUSERFRAME USER#(7) V000
TPWRITE finishTCPUserLoading
END
点击显示全文
赞同0
发表评论
分享

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