可以通过离线仿真软件或者LUA等计算方式,获得等时间间隔的轨迹点(例如每10ms,最小可至1ms)。这些轨迹点位可以是Joint或者笛卡尔空间的。
机器人基于以上离线轨迹,可以方便实现匀速运动(例如等时间等距离的轨迹)
机器人希望可以实现以下圆形轨迹。圆形轨迹通过lua计算并获得对应的微段轨迹.jbi文件
JBI文件如下:
C00000=-36.0656,-111.4706,105.1191,-83.6512,90.0004,53.8920 NOP SET D002 50 // 设置圆的半径 SET D003 5 // 设置圆每1°,机器人运行的时间,单位ms SET D004 360 // 设置插补的总个数 SETJOINT P000 -36.0656,-111.4706,105.1191,-83.6508,90.0004,53.8920 SETJOINT P001 -36.0656,-110.7748,99.8632,-79.0914,90.0004,53.8920 SET B000 0 MOVJ P001 VJ=100% CR=0.0MM ACC=50 DEC=50 MOVL P000 V=100.0MM/S CR=0.0MM ACC=50 DEC=50 SET B000 1 // 生成笛卡尔空间的微段插补轨迹的JBI文件 // 微段轨迹的jbi文件也可通过第三方离线软件生成,注意生成的文件格式 WAIT B000=2 MOUT M#(528) ON LOADML JOB:mFileCart // 加载微段轨迹JBI MOVML VJ=100% M#(528) JOB:mFileCart // 机器人移动到开始位置,并等待信号为1后,开始运行微段轨迹 UNLOADML JOB:mFileCart SET B000 0 // // 重新计算圆轨迹,插补成joint格式 TIMER T=1 S SET B000 3 // 生成Joint空间的微段插补轨迹的JBI文件 WAIT B000=4 MOUT M#(528) ON LOADML JOB:mFileJoint // 加载微段轨迹JBI MOVML VJ=100% M#(528) JOB:mFileJoint // 机器人移动到开始位置,并等待信号为1后,开始运行微段轨迹 UNLOADML JOB:mFileJoint SET B000 0 END
后台生成微段轨迹的lua代码如下:
function Movml_generator() local pStart = get_tcp_pose() pStart[1] = pStart[1] +R local c_joint = get_robot_joint() file = io.open("mFileCart.jbi", "w") io.output(file) io.write("//trajfile\n") io.write("version2.15\n") io.write("interval ["..string.format('%d',interval_time).."]ms\n") local s_joint = string.format('[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f]',c_joint[1],c_joint[2],c_joint[3],c_joint[4],c_joint[5],c_joint[6]) io.write('refJointPos '..s_joint..'\n') -- 设置第一个点的参考关节角度 io.write("length ["..string.format('%d',ttl_length).."]\n") io.write("postype [pose]\n") -- 点位类型是Pose笛卡尔 io.write("outputNumber [2]\n") io.write("refFrame [0.0,0.0,0.0,0.0,0.0,0.0]\n") -- 参考坐标系 Pout = {pStart[1], pStart[2], pStart[3], pStart[4], pStart[5], pStart[6]} -- 实际输出的位置 for i = 1, 360, 1 do Pout[1] = pStart[1] - R* math.cos(math.rad(i)) Pout[2] = pStart[2] + R* math.sin(math.rad(i)) local v = string.format('[%.2f,%.2f,%.2f,%.5f,%.5f,%.5f]', Pout[1], Pout[2], Pout[3], Pout[4], Pout[5], Pout[6]) io.write(v..'\n') end io.close(file) elite_print("轨迹已经保存到mFileCart.jbi") end function Movml_generator2() local pStart = get_tcp_pose() pStart[1] = pStart[1] +R local c_joint = get_robot_joint() file = io.open("mFileJoint.jbi", "w") io.output(file) io.write("//trajfile\n") io.write("version2.15\n") io.write("interval ["..string.format('%d',interval_time).."]ms\n") local s_joint = string.format('[%.2f,%.2f,%.2f,%.2f,%.2f,%.2f]',c_joint[1],c_joint[2],c_joint[3],c_joint[4],c_joint[5],c_joint[6]) io.write('refJointPos '..s_joint..'\n') -- 设置第一个点的参考关节角度 io.write("length ["..string.format('%d',ttl_length).."]\n") io.write("postype [joint]\n") -- 点位类型是Joint io.write("outputNumber [2]\n") io.write("refFrame [0.0,0.0,0.0,0.0,0.0,0.0]\n") --参考坐标系 Pout = {pStart[1], pStart[2], pStart[3], pStart[4], pStart[5], pStart[6]} -- 实际输出的位置 for i = 1, 360, 1 do Pout[1] = pStart[1] - R* math.cos(math.rad(i)) Pout[2] = pStart[2] + R* math.sin(math.rad(i)) local out1 = get_inv_kinematics(Pout) local p = string.format('[%.2f,%.2f,%.2f,%.5f,%.5f,%.5f]', out1[1], out1[2], out1[3], out1[4], out1[5], out1[6]) io.write(p..'\n') end io.close(file) elite_print("轨迹已经保存到mFileJoint.jbi") end sleep(0.3) interval_time = 1-- 设置插补间隔时间 R = 0 --圆的半径 CT = 1 -- 整圆的时间 ttl_length = 1-- 插补总点数 set_global_variable("B000", 0) while true do B000 = get_global_variable("B0") if B000 == 1 then R = get_global_variable("D002") --获取圆的半径 ttl_length = get_global_variable("D004") -- 获取-- 插补总点数 interval_time = get_global_variable("D003") -- 设置插补间隔时间 Movml_generator() -- 产生笛卡尔空间的位置数据 set_global_variable('B000',2) end if B000 == 3 then Movml_generator2() --产生joint类型的位置数据 set_global_variable('B000',4) end sleep(0.5) end
产生的mFileCart.jbi文件部分内容如下:
//trajfile version2.15 interval [5]ms refJointPos [-36.07,-111.47,105.12,-83.65,90.00,53.89] length [360] postype [pose] outputNumber [2,3] #后续可以控制DO2,DO3 refFrame [0.0,0.0,0.0,0.0,0.0,0.0] [266.31,-64.94,199.83,-3.14157,0.00004,-3.14085] [266.34,-64.07,199.83,-3.14157,0.00004,-3.14085] [266.37,-63.19,199.83,-3.14157,0.00004,-3.14085] output [2,1] #经过此点,将DO2置为1,方括号内不能有空格,信号控制不要出现在整个点位的最后两行 [266.43,-62.32,199.83,-3.14157,0.00004,-3.14085] [266.50,-61.45,199.83,-3.14157,0.00004,-3.14085]
产生的mFileJoint.jbi文件部分内容如下:
//trajfile version2.15 interval [5]ms refJointPos [-36.10,-111.46,105.11,-83.66,90.00,53.86] length [360] postype [joint] outputNumber [2] refFrame [0.0,0.0,0.0,0.0,0.0,0.0] [-35.96,-111.50,105.14,-83.63975,90.00038,54.00087] [-35.79,-111.55,105.17,-83.62288,90.00037,54.16349] [-35.63,-111.58,105.19,-83.60760,90.00036,54.32847] [-35.46,-111.62,105.21,-83.59391,90.00036,54.49572] [-35.29,-111.65,105.23,-83.58184,90.00035,54.66517] [-35.12,-111.68,105.25,-83.57139,90.00034,54.83674] [-34.95,-111.70,105.26,-83.56258,90.00033,55.01036] [-34.77,-111.72,105.27,-83.55543,90.00033,55.18594] [-34.59,-111.73,105.28,-83.54992,90.00032,55.36341]