50     """Converts a pose target to a string"""    52     return (
'%.6f,%.6f,%.6f,%.6f,%.6f,%.6f,0.0,0.0' % (x,y,z,r,p,w))
    55     """Prints a joint target"""    57     for i 
in range(len(angles)):
    58         str = str + (
'%.3f,' % (angles[i]*pulses_x_deg[i]))
    65     """Robot post object"""    67     MAX_LINES_X_PROG = 999  
    68     PULSES_X_DEG = [1,1,1,1,1,1]
    69     INCLUDE_SUB_PROGRAMS = 
False    99     def __init__(self, robotpost=None, robotname=None, robot_axes = 6, **kwargs):
   106         for k,v 
in kwargs.items():
   107             if k == 
'lines_x_prog':
   109             if k == 
'pulses_x_deg':
   113         progname_i = progname
   117                 progname_i = progname
   119                 progname_i = 
"%s%i" % (self.
PROG_NAME, nPages)
   130         self.
addline(
"# Program: %s" % progname_i)
   147     def progsave(self, folder, progname, ask_user = False, show_result = False): 
   148         progname = progname + 
'.' + self.
PROG_EXT   150             filesave = 
getSaveFile(folder, progname, 
'Save program as...')
   151             if filesave 
is not None:
   152                 filesave = filesave.name
   156             filesave = folder + 
'/' + progname
   157         fid = open(filesave, 
"w")
   161         print(
'SAVED: %s\n' % filesave) 
   166             if type(show_result) 
is str:
   169                 p = subprocess.Popen([show_result, filesave])
   170             elif type(show_result) 
is list:
   172                 p = subprocess.Popen(show_result + [filesave])   
   177                 os.startfile(filesave)
   178             if len(self.
LOG) > 0:
   179                 mbox(
'Program generation LOG:\n\n' + self.
LOG)
   181     def ProgSave(self, folder, progname, ask_user = False, show_result = False):
   189             progname_main = progname + 
"Main"   191             mainprog += 
"# %s \n" % progname_main
   192             for i 
in range(npages):
   199             self.
progsave(folder, progname_main, ask_user, show_result)
   209             for i 
in range(npages):
   215             self.
progsave(folder, progname, ask_user, show_result)
   218         """Send a program to the robot using the provided parameters. This method is executed right after ProgSave if we selected the option "Send Program to Robot".   219         The connection parameters must be provided in the robot connection menu of RoboDK"""   222     def MoveJ(self, pose, joints, conf_RLF=None):
   223         """Add a joint movement"""   240     def MoveL(self, pose, joints, conf_RLF=None):
   241         """Add a linear movement"""   257     def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None):
   258         """Add a circular movement"""   283     def setFrame(self, pose, frame_id=None, frame_name=None):
   284         """Change the robot reference frame"""   286         self.
addline(
'# using reference frame: %s' % frame_name)
   289     def setTool(self, pose, tool_id=None, tool_name=None):
   290         """Change the robot TCP"""   292         self.
addline(
'# using tool frame: %s' % tool_name)
   296         """Pause the robot program"""   300             self.
addline(
'DELAY T%.3f;' % (time_ms*0.001))
   303         """Changes the robot speed (in mm/s)"""   307         """Changes the current robot acceleration"""   311         """Changes the robot joint speed (in deg/s)"""   315         """Changes the robot joint acceleration (in deg/s2)"""   319         """Changes the zone data approach (makes the movement more smooth)"""   323         """Sets a variable (output) to a given value"""   324         if type(io_var) != str:  
   325             io_var = 
'OT%s' % str(io_var)        
   326         if type(io_value) != str: 
   333         self.
addline(
'DOUT %s, %s;' % (io_var, io_value))
   335     def waitDI(self, io_var, io_value, timeout_ms=-1):
   336         """Waits for an input io_var to attain a given value io_value. Optionally, a timeout can be provided."""   337         if type(io_var) != str:  
   338             io_var = 
'IN%s' % str(io_var)        
   339         if type(io_value) != str: 
   345         self.
addline(
'WAIT %s, %s, T%.1f;' % (io_var, io_value, max(timeout_ms,0)))
   347     def RunCode(self, code, is_function_call = False):
   348         """Adds code or a function call"""   350             code.replace(
' ',
'_')
   351             if not code.endswith(
')'):
   352                 code = 
'CALL ' + code + 
';'   355             if not code.endswith(
';'):
   360         """Add a joint movement"""   364             self.
addline(
'# Show message: ' + message)
   368         """Add a program line"""   377         self.
PROG = self.
PROG + newline + 
'\n'   381         """Add a program line"""   385         self.
DATA = self.
DATA + newline + 
'\n'   388         """Add a log message"""   392         self.
LOG = self.
LOG + newline + 
'\n'   397     [x,y,z,r,p,w] = xyzrpw
   407     return Mat([[cb*ca, ca*sc*sb - cc*sa, sc*sa + cc*ca*sb, x],[cb*sa, cc*ca + sc*sb*sa, cc*sb*sa - ca*sc, y],[-sb, cb*sc, cc*cb, z],[0,0,0,1]])
   410     """Test the post with a basic program"""   412     robot = 
RobotPost(
'Kuka_custom', 
'Generic Kuka')
   414     robot.ProgStart(
"Program")
   415     robot.RunMessage(
"Program generated by RoboDK", 
True)
   416     robot.setFrame(
Pose([807.766544, -963.699898, 41.478944, 0, 0, 0]))
   417     robot.setTool(
Pose([62.5, -108.253175, 100, -60, 90, 0]))
   418     robot.MoveJ(
None, [-46.18419, -6.77518, -20.54925, 71.38674, 49.58727, -302.54752] )
   419     robot.MoveJ(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   420     robot.MoveL(
Pose([200, 200, 262.132034, 180, 0, -150]), [-43.73892, -3.91728, -35.77935, 58.57566, 54.11615, -253.81122] )
   421     robot.RunMessage(
"Setting air valve 1 on")
   422     robot.RunCode(
"TCP_On", 
True)
   424     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   425     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   426     robot.MoveL(
Pose([250, 250, 191.421356, 180, 0, -150]), [-39.75778, -1.04537, -40.37883, 52.09118, 54.15317, -246.94403] )
   427     robot.RunMessage(
"Setting air valve off")
   428     robot.RunCode(
"TCP_Off", 
True)
   430     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   431     robot.MoveL(
Pose([250, 200, 278.023897, 180, 0, -150]), [-41.85389, -1.95619, -34.89154, 57.43912, 52.34162, -253.73403] )
   432     robot.MoveL(
Pose([250, 150, 191.421356, 180, 0, -150]), [-43.82111, 3.29703, -40.29493, 56.02402, 56.61169, -249.23532] )
   433     robot.ProgFinish(
"Program")
   437     if len(robot.LOG) > 0:
   438         mbox(
'Program generation LOG:\n\n' + robot.LOG)
   440     input(
"Press Enter to close...")
   442 if __name__ == 
"__main__":
   443     """Function to call when the module is executed by itself: test""" 
def addline(self, newline)
def ProgStart(self, progname, new_page=False)
def setAcceleration(self, accel_mmss)
def MoveJ(self, pose, joints, conf_RLF=None)
def setTool(self, pose, tool_id=None, tool_name=None)
def setFrame(self, pose, frame_id=None, frame_name=None)
def UploadFTP(program, robot_ip, remote_path, ftp_user, ftp_pass)
def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None)
def RunCode(self, code, is_function_call=False)
def addlog(self, newline)
def mbox(msg, b1='OK', b2='Cancel', frame=True, t=False, entry=None)
def __init__(self, robotpost=None, robotname=None, robot_axes=6, kwargs)
def ProgSendRobot(self, robot_ip, remote_path, ftp_user, ftp_pass)
def setSpeedJoints(self, speed_degs)
def ProgFinish(self, progname, new_page=False)
def setAccelerationJoints(self, accel_degss)
def ProgSave(self, folder, progname, ask_user=False, show_result=False)
def progsave(self, folder, progname, ask_user=False, show_result=False)
def setZoneData(self, zone_mm)
def adddata(self, newline)
def setSpeed(self, speed_mms)
def getSaveFile(strdir='C:\\', strfile='file.txt', strtitle='Save file as ...')
def MoveL(self, pose, joints, conf_RLF=None)
bool INCLUDE_SUB_PROGRAMS
def RunMessage(self, message, iscomment=False)
def angles_2_str(angles, pulses_x_deg)
def waitDI(self, io_var, io_value, timeout_ms=-1)
def setDO(self, io_var, io_value)