50     """Prints a pose target"""    52     return (
'X%.3f Y%.3f Z%.3f R%.3f P%.3f W%.3f' % (x,y,z,r,p,w))
    55     """Prints a joint target"""    57     data = [
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L']
    58     for i 
in range(len(angles)):
    59         str = str + (
'%s%.6f ' % (data[i], angles[i]))
    66     """Robot post object"""    78     def __init__(self, robotpost=None, robotname=None, robot_axes = 6, **kwargs):
    89         self.
addline(
'(** This is a program sample generated by RoboDK post processor for Logix5000**)')
    90         self.
addline(
'(*****  Enable Axis_0 and Axis_1 *****)')
    91         self.
addline(
'if (input_0 & State = 0) then ')
    92         self.
addline(
'\tMSO(Axis_0, Axis_0_MSO);')
    94         self.
addline(
'\tcounter [:=] .5;')
    97         self.
addline(
'(***** Check for servos on *****)');
    98         self.
addline(
'If (Axis_0.ServoActionStatus & Axis_1.ServoActionStatus & State = 1) then');
    99         self.
addline(
'\tgear_ratio := counter;');
   100         self.
addline(
'(**\tMAG(Axis_0, Axis_1, Axis0_1_MAG, 1, gear_ratio, 1, 1, Actual, Real, Disabled, 10, 1 );**)');
   104         self.
addline(
'(********** MOVE AXES START **********)')
   109         self.
addline(
'(***** Check if move is complete and axis is in position *****)')
   111         for i 
in range(self.
nAxes):
   112             MAM_PC_ALL = MAM_PC_ALL + (
'Axis_%i_MAM.PC & ' % i)
   118         self.
addline(
'If (%s & counter = 2 & Axis_1.PositionLockStatus & State = %i) then' % (MAM_PC_ALL, self.
COUNT_STATE))
   123         self.
addline(
'\tcounter := counter + .5;')
   124         self.
addline(
'\tState := 1; (* This directs the program to loop back and re-enter at State = 1 *)        ')
   126         self.
addline(
'If (Axis_0.ActualVelocity = 0 & Axis_1.ActualVelocity = 0 & State = %i) then' % self.
COUNT_STATE)
   127         self.
addline(
'\tMSF(Axis_0, Axis_0_MSF); MSF(Axis_1, Axis_1_MSF);')
   128         self.
addline(
'\tJSR(LadderFile, 0 );  (* Jump to Ladder program *) (* Return from Ladder enters here *)')
   130         self.
addline(
'If timer_1.DN & State = %i then (* Wait for timer done then reset ' % self.
COUNT_STATE)
   132         self.
addline(
'\tcounter := 0;')
   135         self.
addline(
'(** this program contains %i sequential movements **)' % self.
COUNT_MOVE)
   137     def ProgSave(self, folder, progname, ask_user = False, show_result = False):
   138         progname = progname + 
'.' + self.
PROG_EXT   140             filesave = 
getSaveFile(folder, progname, 
'Save program as...')
   141             if filesave 
is not None:
   142                 filesave = filesave.name
   146             filesave = folder + 
'/' + progname
   148         fid = open(filesave, 
"w")
   151         print(
'SAVED: %s\n' % filesave) 
   156             if type(show_result) 
is str:
   159                 p = subprocess.Popen([show_result, filesave])
   160             elif type(show_result) 
is list:
   162                 p = subprocess.Popen(show_result + [filesave])   
   166                 os.startfile(filesave)
   167             if len(self.
LOG) > 0:
   168                 mbox(
'Program generation LOG:\n\n' + self.
LOG)
   171         """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".   172         The connection parameters must be provided in the robot connection menu of RoboDK"""   175     def MoveJ(self, pose, joints, conf_RLF=None):
   176         """Add a joint movement"""   179         for i 
in range(len(joints)):
   180             MAM_PC_ALL = MAM_PC_ALL + (
'Axis_%i_MAM.PC & ' % i)
   185         for i 
in range(len(joints)):
   186             self.
addline(
'\tMAM(Axis_%i, Axis_%i_MAM, 1, %.3f, Move_Speed, Unitspersec, 50, %%ofMaximum, 50, %%ofMaximum, 1,100.0,100.0,%%ofTime, 0, 0 ,0,None,0,0);' % (i, i, joints[i]))
   191     def MoveL(self, pose, joints, conf_RLF=None):
   192         """Add a linear movement"""   195         for i 
in range(len(joints)):
   196             MAM_PC_ALL = MAM_PC_ALL + (
'Axis_%i_MAM.PC & ' % i)
   201         for i 
in range(len(joints)):
   202             self.
addline(
'\tMAM(Axis_%i, Axis_%i_MAM, 1, %.3f, Move_Speed, Unitspersec, 50, %%ofMaximum, 50, %%ofMaximum, 1,100.0,100.0,%%ofTime, 0, 0 ,0,None,0,0);' % (i, i, joints[i]))
   207     def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None):
   208         """Add a circular movement"""   209         self.
addlog(
'MoveC not defined')
   211     def setFrame(self, pose, frame_id=None, frame_name=None):
   212         """Change the robot reference frame"""   213         self.
addlog(
'setFrame not defined')
   215     def setTool(self, pose, tool_id=None, tool_name=None):
   216         """Change the robot TCP"""   217         self.
addlog(
'setTool not defined')
   220         """Pause the robot program"""   221         self.
addlog(
'Pause not defined')
   224         """Changes the current robot speed (in mm/s)"""   225         self.
addlog(
'setSpeed not defined')
   228         """Changes the current robot acceleration (in mm/s2)"""   229         self.
addlog(
'setAcceleration not defined')
   232         """Changes the robot joint speed (in deg/s)"""   233         self.
addlog(
'setSpeedJoints not defined')
   236         """Changes the robot joint acceleration (in deg/s2)"""   237         self.
addlog(
'setAccelerationJoints not defined')
   240         """Changes the zone data approach (makes the movement more smooth)"""   241         self.
addlog(
'Zone data not implemented (%.1f mm)' % zone_mm)
   244         """Sets a variable (output) to a given value"""   245         if type(io_var) != str:  
   246             io_var = 
'OUT[%s]' % str(io_var)        
   247         if type(io_value) != str: 
   254         self.
addline(
'%s=%s' % (io_var, io_value))
   256     def waitDI(self, io_var, io_value, timeout_ms=-1):
   257         """Waits for an input io_var to attain a given value io_value. Optionally, a timeout can be provided."""   258         if type(io_var) != str:  
   259             io_var = 
'IN[%s]' % str(io_var)        
   260         if type(io_value) != str: 
   268             self.
addline(
'WAIT FOR %s==%s' % (io_var, io_value))
   270             self.
addline(
'WAIT FOR %s==%s TIMEOUT=%.1f' % (io_var, io_value, timeout_ms))   
   272     def RunCode(self, code, is_function_call = False):
   273         """Adds code or a function call"""   274         self.
addlog(
'RunCode not defined')
   277         """Show a message on the controller screen"""   278         self.
addlog(
'RunMessage not defined')
   282         """Add a program line"""   283         self.
PROG = self.
PROG + newline + 
'\n'   286         """Add a log message"""   287         self.
LOG = self.
LOG + newline + 
'\n'   292     [x,y,z,r,p,w] = xyzrpw
   302     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]])
   305     """Test the post with a basic program"""   309     robot.ProgStart(
"Program")
   310     robot.RunMessage(
"Program generated by RoboDK", 
True)
   311     robot.setFrame(
Pose([807.766544, -963.699898, 41.478944, 0, 0, 0]))
   312     robot.setTool(
Pose([62.5, -108.253175, 100, -60, 90, 0]))
   313     robot.MoveJ(
Pose([200, 200, 500, 180, 0, 180]), [-46.18419, -6.77518, -20.54925, 71.38674, 49.58727, -302.54752] )
   314     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   315     robot.MoveL(
Pose([200, 200, 262.132034, 180, 0, -150]), [-43.73892, -3.91728, -35.77935, 58.57566, 54.11615, -253.81122] )
   316     robot.RunMessage(
"Setting air valve 1 on")
   317     robot.RunCode(
"TCP_On", 
True)
   319     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   320     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   321     robot.MoveL(
Pose([250, 250, 191.421356, 180, 0, -150]), [-39.75778, -1.04537, -40.37883, 52.09118, 54.15317, -246.94403] )
   322     robot.RunMessage(
"Setting air valve off")
   323     robot.RunCode(
"TCP_Off", 
True)
   325     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   326     robot.MoveL(
Pose([250, 200, 278.023897, 180, 0, -150]), [-41.85389, -1.95619, -34.89154, 57.43912, 52.34162, -253.73403] )
   327     robot.MoveL(
Pose([250, 150, 191.421356, 180, 0, -150]), [-43.82111, 3.29703, -40.29493, 56.02402, 56.61169, -249.23532] )
   328     robot.ProgFinish(
"Program")
   331     if len(robot.LOG) > 0:
   332         mbox(
'Program generation LOG:\n\n' + robot.LOG)
   334     input(
"Press Enter to close...")
   336 if __name__ == 
"__main__":
   337     """Function to call when the module is executed by itself: test""" 
def ProgStart(self, progname)
def ProgSendRobot(self, robot_ip, remote_path, ftp_user, ftp_pass)
def setSpeedJoints(self, speed_degs)
def addlog(self, newline)
def MoveJ(self, pose, joints, conf_RLF=None)
def setTool(self, pose, tool_id=None, tool_name=None)
def setDO(self, io_var, io_value)
def setFrame(self, pose, frame_id=None, frame_name=None)
def setAcceleration(self, accel_mmss)
def UploadFTP(program, robot_ip, remote_path, ftp_user, ftp_pass)
def setZoneData(self, zone_mm)
def waitDI(self, io_var, io_value, timeout_ms=-1)
def ProgSave(self, folder, progname, ask_user=False, show_result=False)
def mbox(msg, b1='OK', b2='Cancel', frame=True, t=False, entry=None)
def ProgFinish(self, progname)
def __init__(self, robotpost=None, robotname=None, robot_axes=6, kwargs)
def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None)
def MoveL(self, pose, joints, conf_RLF=None)
def setSpeed(self, speed_mms)
def RunCode(self, code, is_function_call=False)
def getSaveFile(strdir='C:\\', strfile='file.txt', strtitle='Save file as ...')
def RunMessage(self, message, iscomment=False)
def addline(self, newline)
def setAccelerationJoints(self, accel_degss)