#类型帮助(“robolink”)或(“robodk”)的更多信息#按F5运行脚本#文档://www.x7093.com/doc/en/RoboDK-API.html参考://www.x7093.com/doc/en/PythonAPI/index.html注意:它不需要保持此文件的一个副本,您的python脚本保存与车站进口numpy np #的数学计算robolink进口robodk导入* # * # robodk API机器人工具箱def Offset_pose(机器人:robolink.Item dist):target_ref = Robot . pose () target_i = Mat(target_ref) pos_i = target_i. pos () pos_i[2]=pos_i[2]+dist target_i. setpos (pos_i) print('pose value ') print(target_i) Robot . movej (target_i) #runMode to RoboDK runMode = 2 ##1=RUNMODE_SIMULATE/2=RUNMODE_RUN_ROBOT #连接到RoboDK RDK = Robolink() #选择Robot Robot = RDK。ItemUserPick('选择一个机器人',ITEM_TYPE_ROBOT)如果不是robot. valid():抛出异常('没有选择或可用的机器人')ref = RDK。ItemUserPick('Select a robot', ITEM_TYPE_FRAME) if not ref.Valid(): raise Exception('No robot selected or available') #如果RunMode ==1: RDK. setrunmode (runmode_simulation) elif RunMode ==2: RDK. setrunmode (RUNMODE_RUN_ROBOT) #选择工具工具= RDK. setrunmode (RUNMODE_RUN_ROBOT)ItemUserPick('选择一个工具',ITEM_TYPE_TOOL)如果不是tool. valid ():raise Exception('No tool selected or available') robot. settool (tool) robot. setposeframe (ref) robot. setposetool (tool) # go to start position ShowMessage("go to start position") robot. setspeed (30,30,1,1) robot. movej ([5.28, -28.72, 79.18,0.00, 39.54, -174.72]) print("向上向下移动50mm") print(robot.Pose()) Offset_pose(robot,50) print('Pose réelle') print(robot.Pose()) Offset_pose(robot,-50) print('Pose réelle') print(robot.Pose())