#输入help("robolink")或help("robodk")查看更多信息#按F5运行脚本#文档://www.w5838.com/doc/en/RoboDK-API.html #参考://www.w5838.com/doc/en/PythonAPI/index.html #备注:不需要保留此文件的副本,您的python脚本将与站一起保存从robolink导入* # RoboDK API从RoboDK导入* #机器人工具箱导入时间从py_openshowvar导入openshowvar从函数导入* # RoboDK初始化RDK = robolink () # sys.path。insert(0, "C:\Program Files\RoboDK\Python") robot = RDK。项目('KUKA KR 6 R700 sixx') RDK.setSimulationSpeed(1) #初始化慢参考= robot. parent() #检索机器人参考框架robot. setposeframe(参考)#使用机器人基本框架作为活动参考home = [0, - 90,90,0,0,0] robot. movej (home)路径=解析器(' C:/Users/Luky/Desktop/DTU/Industrial Robotics/ final_assignmt /Notes/rocket.gcode')机器人。setSpeed(speed_linear=100, speed_joint =20, accel_linear=3000, accel_joint =20) ROBOT . setround (3) # CONNECT TO ROBOT # client = openshowvar('172.31.1.147', 7000) # ip地址+端口7000 # client。写('$OUT[17]', 'FALSE') #客户端。写(# 'XHOME', '{A1 0.0, A2 -90, A3 90, A4 0, A5 -0, A6 0.0, E1 0.0, E2 0.0, E3 0.0, E4 0.0, E5 0.0, E6 0.0}') #客户端写入(# 'MYAXIS', '{A1 0.0, A2 -90, A3 90, A4 0, A5 -0, A6 0.0, E1 0.0, E2 0.0, E3 0.0, E4 0.0, E5 0.0, E6 0.0}') # time.sleep(3) # 1)移动到点P1, P2, P3,定义一个帧# 2)移动到其中一个P并获得它的角度并插入到home_关节# 3)不启动挤出机,直到循环item_frame = RDK.Item('task_frame') home_关节=[-5.52万,-107.55万,115.910000,1.620000,37.390000,-0.2400006] #将关节定位到P1 robot. setframe (item_frame) robot. movej (home_关节)# move(robot.关节(),客户端)# invH(item_frame. pose()) =同构矩阵# robot. solvefk (home_关节)=关节定位orient_frame2tool = invH(item_frame. pose ())*robot. solvefk (home_关节)#移除同构的最后一列orient_frame2tool[0:3,3] = Mat([0,0, 0,0]) # result =最后一列为0的机器人的齐次矩阵方向# #在工作区中移动,看看它是否没有击中表:# robot。移动(transl([0,0,0])*orient_frame2tool) # #移动(robot.关节(),客户端)#机器人。移动(transl([0,70,0])*orient_frame2tool) # #移动(robot.关节(),客户端)#机器人。移动(transl([70,70,0])*orient_frame2tool) # #移动(robot.关节(),客户端)#机器人。移动(transl([70,0,0])*orient_frame2tool) # #移动(robot.关节(),客户端)#机器人。移动(transl([0,0,0])*orient_frame2tool) # #移动(robot.关节(),客户端)# #去除多余的灯丝#机器人。MoveL(transl([0, 0, 1])*orient_frame2tool) # # move(robot.Joints(), client) # # extruder(client, "START") # time.sleep(2) # PRINTING RDK.setSimulationSpeed(1) # printing is fast printing_status = False for item in path: # if item[3] == False and printing_status == True: # # extruder(client, "STOP") # printing_status = False # elif item[3] == True and printing_status == False: # print # # extruder(client, "START") # printing_status = True target_point = [item[0], item[1], 0.55*item[2]+0.15] target0 = transl(target_point)*orient_frame2tool robot.MoveL(target0, blocking=False) # move(robot.Joints(), client) # extruder(client, "STOP") robot.MoveJ(home) # target0 is referenced to the task_frame, not baseframe of the robot afaik # if we use SolveIK (inv kinematics), the angles of the # P1: -5.52 -107.55 115.91 1.62 37.39 -0.24 # P2: 13.34 -108.15 116.43 -18.85 40.36 29.33 # P2 dal: 23.72 -105.25 114.28 -28 43.73 43.69 # P3: -6.59 -86.19 96.72 3 35.27 -2.17