#类型帮助(“robolink”)或(“robodk”)的更多信息#按F5运行脚本#注:你不需要保持此文件的一个副本,您的python脚本保存与车站robolink进口* # API与robodk robodk进口* #基本的矩阵操作#使用robodk API作为RL RDK = robolink() #定义默认方法距离方法= 100 #收集机器人,工具和参考帧从车站机器人= RDK。项目('UR10e', ITEM_TYPE_ROBOT)工具= RDK。项目('Grijper', ITEM_TYPE_TOOL) frame_tray = RDK。项目('PalletFrame', ITEM_TYPE_FRAME) null_position_holder = RDK。项目('NullPositionHolder', ITEM_TYPE_FRAME) #收集目标target_pallet_safe = RDK。项目('PalletApproach', ITEM_TYPE_TARGET) target_null_safe = RDK。项目('NullPositionApproach', ITEM_TYPE_TARGET) #获取变量参数SIZE_SLOTKLOS = RDK.getParam('SizeSlotKlos') size_栈= RDK.getParam(' sizepalllet ') SIZE_SLOTKLOS_XYZ = [float(x.)replace(' ',')) for SIZE_SLOTKLOS.split(',')] SIZE_PALLET_XYZ = [float(x. slotklos .split)]取代 (' ','')) x在SIZE_PALLET.split (" ")] SIZE_SLOTKLOS_Z = SIZE_SLOTKLOS_XYZ[2] #盒子的高度接近头寸时,必须考虑def box_calc (size_xyz pallet_xyz):““计算点的列表来存储部分托盘”“[size_x、size_y size_z] = size_xyz [pallet_x、pallet_y pallet_z] = pallet_xyz xyz_list = [] h范围内(int (pallet_z)): j的范围(int (pallet_y)):我的范围(int (pallet_x)):xyz_list = xyz_list + [[(i+0.5)*size_x, (j+0.5)*size_y, (h+0.5)*size_z]]] return xyz_list def TCP_On(toolitem): """将最近的对象附加到toolitem Htool pose上,它还将对生成的机器人程序输出适当的函数调用(对TCP_On的调用)""" toolitem. attachnearest () toolitem.RDK(). "toolitem.RDK().RunProgram('TCP_On()');def TCP_Off(toolitem, itemleave=0): ""分离与toolitem Htool pose连接最近的对象,它还将在生成的机器人程序上输出适当的函数调用(调用TCP_Off)""" toolitem.DetachAll(itemleave) toolitem.RDK(). "toolitem.RDK().RunProgram('TCP_Off()'); # calculate an array of positions to get/store the parts parts_positions = box_calc(SIZE_SLOTKLOS_XYZ, SIZE_PALLET_XYZ) # Calculate a new TCP that takes into account the size of the part (targets are set to the center of the box) tool_xyzrpw = tool.PoseTool()*transl(0,0,SIZE_SLOTKLOS_Z/2) tool_tcp = robot.AddTool(tool_xyzrpw, 'TCP A') robot.setPoseTool(tool_tcp) nparts = len(parts_positions) i = nparts-1 while i >= 0: # ----------- take a part from the pallet ------ # get the xyz position of part i robot.setPoseFrame(frame_pallet) part_position_i = parts_positions[i] target_i = transl(part_position_i)*rotx(pi)*rotz(0.5*pi) target_i_app = target_i * transl(0,0,-(APPROACH+SIZE_SLOTKLOS_Z)) # approach to the pallet robot.MoveJ(target_pallet_safe) # get the box i robot.MoveJ(target_i_app) robot.MoveL(target_i) TCP_On(tool) # attach the closest part robot.MoveL(target_i_app) robot.MoveJ(target_pallet_safe) # ----------- place the box i on the convegor ------ # approach to the conveyor robot.setPoseFrame(null_position_holder) target_conv_pose = null_position_holder.Pose() target_conv_app = target_conv_pose robot.MoveJ(target_null_safe) #robot.MoveJ(target_conv_pose) TCP_Off(tool, null_position_holder) # detach an place the object in the moving reference frame of the conveyor i = i - 1