58 FDAT_ACT = {TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE}    62 ;FOLD SET DEFAULT SPEED    69 PTP $AXIS_ACT ; skip BCO quickly    74     """Converts a pose target to a string"""    78     return (
'X %.3f,Y %.3f,Z %.3f,A %.3f,B %.3f,C %.3f' % (x,y,z,w,p,r))
    86         for i 
in range(njoints-6):
    87             extaxes = extaxes + (
',E%i %.5f' % (i+1, joints[i+6]))
    91     """Prints a joint target"""    93     data = [
'A1',
'A2',
'A3',
'A4',
'A5',
'A6',
'E1',
'E2',
'E3',
'E4',
'E5',
'E6']
    94     for i 
in range(len(angles)):
    95         str = str + (
'%s %.5f,' % (data[i], angles[i]))
   102     """Robot post object"""   131     def __init__(self, robotpost=None, robotname=None, robot_axes = 6, **kwargs):
   141         self.
addline(
'DEF %s ( )' % progname)
   148     def ProgSave(self, folder, progname, ask_user = False, show_result = False):
   149         progname = progname + 
'.' + self.
PROG_EXT   152             filesave = 
getSaveFile(folder, progname, 
'Save program as...')
   153             if filesave 
is not None:
   154                 filesave = filesave.name
   155                 filesave_csv = 
getFileDir(filesave) + 
'/' + progname_csv
   159             filesave = folder + 
'/' + progname
   160             filesave_csv = folder + 
'/' + progname_csv
   161         fid = open(filesave, 
"w")
   164         fidcsv = open(filesave_csv, 
"w")
   170         print(
'SAVED: %s\n' % filesave) 
   175             if type(show_result) 
is str:
   178                 p = subprocess.Popen([show_result, filesave, filesave_csv])
   179             elif type(show_result) 
is list:
   181                 p = subprocess.Popen(show_result + [filesave])   
   186                 os.startfile(filesave)
   187             if len(self.
LOG) > 0:
   188                 mbox(
'Program generation LOG:\n\n' + self.
LOG)
   191         """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".   192         The connection parameters must be provided in the robot connection menu of RoboDK"""   195     def MoveJ(self, pose, joints, conf_RLF=None):
   196         """Add a joint movement"""   199     def MoveL(self, pose, joints, conf_RLF=None):
   200         """Add a linear movement"""   213     def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None):
   214         """Add a circular movement"""   218             self.
addlog(
'Warning: Can not move circular inside a CSV file')
   221     def setFrame(self, pose, frame_id=None, frame_name=None):
   222         """Change the robot reference frame"""   223         if frame_id 
is not None and frame_id >= 0:
   228             self.
addlog(
'Warning: Can not set the reference frame inside CSV file')
   231         """Change the robot TCP"""   232         if tool_id 
is not None and tool_id >= 0:
   238             self.
addlog(
'Warning: Can not set the tool frame inside CSV file')
   241         """Pause the robot program"""   246                 self.
addline(
'WAIT SEC %.3f' % (time_ms*0.001))
   248             self.
addlog(
'Warning: Can not pause inside CSV file')
   251         """Changes the robot speed (in mm/s)"""   254             self.
addline(
'$VEL.CP = %.5f' % (speed_mms/1000.0))
   257         """Changes the current robot acceleration"""   260             self.
addline(
'$ACC.CP = %.5f' % (accel_mmss/1000.0))
   262             self.
addlog(
'Warning: Can not set acceleration inside CSV file')
   265         """Changes the robot joint speed (in deg/s)"""   268             self.
addline(
'$VEL.ORI1 = %.5f' % speed_degs)
   269             self.
addline(
'$VEL.ORI2 = %.5f' % speed_degs)
   271             self.
addlog(
'Warning: Can not set joint speed inside CSV file')
   274         """Changes the robot joint acceleration (in deg/s2)"""   277             self.
addline(
'$ACC.ORI1 = %.5f' % accel_degss)
   278             self.
addline(
'$ACC.ORI2 = %.5f' % accel_degss)
   280             self.
addlog(
'Warning: Can not set joint acceleration inside CSV file')
   284         """Changes the zone data approach (makes the movement more smooth)"""   287             self.
addline(
'$APO.CPTP = %.3f' % zone_mm)
   288             self.
addline(
'$APO.CDIS = %.3f' % zone_mm)
   296         """Sets a variable (output) to a given value"""   297         if type(io_var) != str:  
   298             io_var = 
'$OUT[%s]' % str(io_var)        
   299         if type(io_value) != str: 
   306         self.
addline(
'%s=%s' % (io_var, io_value))
   308     def waitDI(self, io_var, io_value, timeout_ms=-1):
   309         """Waits for an input io_var to attain a given value io_value. Optionally, a timeout can be provided."""   310         if type(io_var) != str:  
   311             io_var = 
'$IN[%s]' % str(io_var)        
   312         if type(io_value) != str: 
   320             self.
addline(
'WAIT FOR (%s==%s)' % (io_var, io_value))
   323             self.
addline(
'$TIMER_STOP[1]=TRUE')
   324             self.
addline(
'$TIMER_FLAG[1]=FALSE')
   325             self.
addline(
'$TIMER[1]=%.3f' % (float(timeout_ms)*0.001))
   326             self.
addline(
'$TIMER_STOP[1]=FALSE')
   327             self.
addline(
'WAIT FOR (%s==%s OR $TIMER_FLAG[1])' % (io_var, io_value))
   328             self.
addline(
'$TIMER_STOP[1]=TRUE')
   329             self.
addline(
'IF $TIMER_FLAG[1]== TRUE THEN')
   330             self.
addline(
'    HALT ; Timed out!')
   331             self.
addline(
'    GOTO START_TIMER')
   334     def RunCode(self, code, is_function_call = False):
   335         """Adds code or a function call"""   338                 code = code.replace(
' ',
'_')
   339                 if not code.endswith(
')'):
   349         """Add a joint movement"""   363         newline = 
'%i;%.4f;%.4f;%.4f;%.4f;%.4f;%.4f;%i;%.3f;1;0;0;0;%i;%.4f' % (self.
nLineCSV, x,y,z,r,p,w, self.
nLineCSV, speed_time_desired, self.
TOOL_ID, self.
E01)
   378         """Add a program line"""   379         self.
PROG = self.
PROG + newline + 
'\n'   382         """Add a log message"""   383         self.
LOG = self.
LOG + newline + 
'\n'   388     [x,y,z,r,p,w] = xyzrpw
   398     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]])
   401     """Test the post with a basic program"""   403     robot = 
RobotPost(
'Kuka_custom', 
'Generic Kuka')
   405     robot.ProgStart(
"Program")
   406     robot.RunMessage(
"Program generated by RoboDK", 
True)
   407     robot.setFrame(
Pose([807.766544, -963.699898, 41.478944, 0, 0, 0]))
   408     robot.setTool(
Pose([62.5, -108.253175, 100, -60, 90, 0]))
   409     robot.MoveJ(
Pose([200, 200, 500, 180, 0, 180]), [-46.18419, -6.77518, -20.54925, 71.38674, 49.58727, -302.54752] )
   410     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   411     robot.MoveL(
Pose([200, 200, 262.132034, 180, 0, -150]), [-43.73892, -3.91728, -35.77935, 58.57566, 54.11615, -253.81122] )
   412     robot.RunMessage(
"Setting air valve 1 on")
   413     robot.RunCode(
"TCP_On", 
True)
   415     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   416     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   417     robot.MoveL(
Pose([250, 250, 191.421356, 180, 0, -150]), [-39.75778, -1.04537, -40.37883, 52.09118, 54.15317, -246.94403] )
   418     robot.RunMessage(
"Setting air valve off")
   419     robot.RunCode(
"TCP_Off", 
True)
   421     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   422     robot.MoveL(
Pose([250, 200, 278.023897, 180, 0, -150]), [-41.85389, -1.95619, -34.89154, 57.43912, 52.34162, -253.73403] )
   423     robot.MoveL(
Pose([250, 150, 191.421356, 180, 0, -150]), [-43.82111, 3.29703, -40.29493, 56.02402, 56.61169, -249.23532] )
   424     robot.ProgFinish(
"Program")
   427     print(robot.PROG_CSV)
   428     if len(robot.LOG) > 0:
   429         mbox(
'Program generation LOG:\n\n' + robot.LOG)
   431     input(
"Press Enter to close...")
   433 if __name__ == 
"__main__":
   434     """Function to call when the module is executed by itself: test""" def setTool(self, pose, tool_id, tool_name)
def setSpeed(self, speed_mms)
def ProgSave(self, folder, progname, ask_user=False, show_result=False)
def __init__(self, robotpost=None, robotname=None, robot_axes=6, kwargs)
def waitDI(self, io_var, io_value, timeout_ms=-1)
def ProgSendRobot(self, robot_ip, remote_path, ftp_user, ftp_pass)
def UploadFTP(program, robot_ip, remote_path, ftp_user, ftp_pass)
def addline(self, newline)
def addlog(self, newline)
def addline_csv(self, pose_csv)
def setFrame(self, pose, frame_id=None, frame_name=None)
def MoveJ(self, pose, joints, conf_RLF=None)
def ProgStart(self, progname)
def RunMessage(self, message, iscomment=False)
def mbox(msg, b1='OK', b2='Cancel', frame=True, t=False, entry=None)
def RunCode(self, code, is_function_call=False)
def setDO(self, io_var, io_value)
def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None)
def ProgFinish(self, progname)
def pose_2_str_ext(pose, joints)
def MoveL(self, pose, joints, conf_RLF=None)
def getSaveFile(strdir='C:\\', strfile='file.txt', strtitle='Save file as ...')
def setZoneData(self, zone_mm)
def setAcceleration(self, accel_mmss)
def setAccelerationJoints(self, accel_degss)
def setSpeedJoints(self, speed_degs)