51 GLOBAL INTERRUPT DECL 3 WHEN $STOPMESS==TRUE DO IR_STOPM ( )    54 ;ENDFOLD (BASISTECH INI)    57 ;FOLD STARTPOSITION PTP, VEL 50%, A1 5,A2 -90,A3 100,A4 5,A5 10,A6 -5,E1 0    59 PDAT_ACT = {VEL 50,ACC 100,APO_DIST 10}    61 FDAT_ACT = {TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE}    64 ;PTP {A1 -22.431,A2 -98.536,A3 76.935,A4 121.862,A5 -38.504,A6 -77.334,E1 44.368 }    68 ;FOLD SET SPEED TO 50% PTP AND 0.2 m/sec. LIN    77 PDAT_ACT = {VEL 50,ACC 100,APO_DIST 10}    78 FDAT_ACT = {TOOL_NO 0,BASE_NO 0,IPO_FRAME #BASE}    84 ; ---- PORGRAM START ----    90     """Converts a pose target to a string"""    92     return (
'X %.3f, Y %.3f, Z %.3f, A %.3f, B %.3f, C %.3f' % (x,y,z,r,p,w))
   100         for i 
in range(njoints-6):
   101             extaxes = extaxes + (
', E%i %.5f' % (i+1, joints[i+6]))
   105     """Contverts a joint target to a string"""   107     data = [
'A1',
'A2',
'A3',
'A4',
'A5',
'A6',
'E1',
'E2',
'E3',
'E4',
'E5',
'E6']
   108     for i 
in range(len(angles)):
   109         str = str + (
'%s %.5f,' % (data[i], angles[i]))
   116     """Robot post object"""   128     def __init__(self, robotpost=None, robotname=None, robot_axes = 6, **kwargs):
   136         self.
addline(
'DEF %s ( )' % progname)
   144     def ProgSave(self, folder, progname, ask_user = False, show_result = False):
   145         progname = progname + 
'.' + self.
PROG_EXT   147             filesave = 
getSaveFile(folder, progname, 
'Save program as...')
   148             if filesave 
is not None:
   149                 filesave = filesave.name
   153             filesave = folder + 
'/' + progname
   154         fid = open(filesave, 
"w")
   157         print(
'SAVED: %s\n' % filesave) 
   162             if type(show_result) 
is str:
   165                 p = subprocess.Popen([show_result, filesave])
   166             elif type(show_result) 
is list:
   168                 p = subprocess.Popen(show_result + [filesave])   
   172                 os.startfile(filesave)
   173             if len(self.
LOG) > 0:
   174                 mbox(
'Program generation LOG:\n\n' + self.
LOG)
   177         """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".   178         The connection parameters must be provided in the robot connection menu of RoboDK"""   181     def MoveJ(self, pose, joints, conf_RLF=None):
   182         """Add a joint movement"""   185     def MoveL(self, pose, joints, conf_RLF=None):
   186         """Add a linear movement"""   189     def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None):
   190         """Add a circular movement"""   191         self.
addlog(
'Circular move is not implemented')
   193     def setFrame(self, pose, frame_id=None, frame_name=None):
   194         """Change the robot reference frame"""   198             self.
addline(
'$BASE = EK (MACHINE_DEF[2].ROOT, MACHINE_DEF[2].MECH_TYPE, { %s })' % 
pose_2_str(pose))
   200     def setTool(self, pose, tool_id=None, tool_name=None):
   201         """Change the robot TCP"""   205         """Pause the robot program"""   209             self.
addline(
'WAIT SEC %.3f' % (time_ms*0.001))
   212         """Changes the robot speed (in mm/s)"""   213         self.
addline(
'$VEL.CP = %.5f' % (speed_mms/1000.0))
   216         """Changes the current robot acceleration"""   217         self.
addline(
'$ACC.CP = %.5f' % (accel_mmss/1000.0))
   220         """Changes the robot joint speed (in deg/s)"""   221         self.
addline(
'$VEL.ORI1 = %.5f' % speed_degs)
   222         self.
addline(
'$VEL.ORI2 = %.5f' % speed_degs)
   225         """Changes the robot joint acceleration (in deg/s2)"""   226         self.
addline(
'$ACC.ORI1 = %.5f' % accel_degss)
   227         self.
addline(
'$ACC.ORI2 = %.5f' % accel_degss)
   230         """Changes the zone data approach (makes the movement more smooth)"""   233             self.
addline(
'$APO.CPTP = %.3f' % zone_mm)
   234             self.
addline(
'$APO.CDIS = %.3f' % zone_mm)
   242         """Sets a variable (output) to a given value"""   243         if type(io_var) != str:  
   244             io_var = 
'$OUT[%s]' % str(io_var)        
   245         if type(io_value) != str: 
   252         self.
addline(
'%s=%s' % (io_var, io_value))
   254     def waitDI(self, io_var, io_value, timeout_ms=-1):
   255         """Waits for an input io_var to attain a given value io_value. Optionally, a timeout can be provided."""   256         if type(io_var) != str:  
   257             io_var = 
'$IN[%s]' % str(io_var)        
   258         if type(io_value) != str: 
   266             self.
addline(
'WAIT FOR (%s==%s)' % (io_var, io_value))
   269             self.
addline(
'$TIMER_STOP[1]=TRUE')
   270             self.
addline(
'$TIMER_FLAG[1]=FALSE')
   271             self.
addline(
'$TIMER[1]=%.3f' % (float(timeout_ms)*0.001))
   272             self.
addline(
'$TIMER_STOP[1]=FALSE')
   273             self.
addline(
'WAIT FOR (%s==%s OR $TIMER_FLAG[1])' % (io_var, io_value))
   274             self.
addline(
'$TIMER_STOP[1]=TRUE')
   275             self.
addline(
'IF $TIMER_FLAG[1]== TRUE THEN')
   276             self.
addline(
'    HALT ; Timed out!')
   277             self.
addline(
'    GOTO START_TIMER')
   280     def RunCode(self, code, is_function_call = False):
   281         """Adds code or a function call"""   283             code.replace(
' ',
'_')
   284             if not code.endswith(
')'):
   291         """Add a joint movement"""   295             self.
addline(
'Wait for StrClear($LOOP_MSG[])')
   296             self.
addline(
'$LOOP_CONT = TRUE')
   297             self.
addline(
'$LOOP_MSG[] = "%s"' % message)
   301         """Add a program line"""   302         self.
PROG = self.
PROG + newline + 
'\n'   305         """Add a log message"""   306         self.
LOG = self.
LOG + newline + 
'\n'   311     [x,y,z,r,p,w] = xyzrpw
   321     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]])
   324     """Test the post with a basic program"""   326     robot = 
RobotPost(
'Kuka_custom', 
'Generic Kuka')
   328     robot.ProgStart(
"Program")
   329     robot.RunMessage(
"Program generated by RoboDK", 
True)
   330     robot.setFrame(
Pose([807.766544, -963.699898, 41.478944, 0, 0, 0]))
   331     robot.setTool(
Pose([62.5, -108.253175, 100, -60, 90, 0]))
   332     robot.MoveJ(
Pose([200, 200, 500, 180, 0, 180]), [-46.18419, -6.77518, -20.54925, 71.38674, 49.58727, -302.54752] )
   333     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   334     robot.MoveL(
Pose([200, 200, 262.132034, 180, 0, -150]), [-43.73892, -3.91728, -35.77935, 58.57566, 54.11615, -253.81122] )
   335     robot.RunMessage(
"Setting air valve 1 on")
   336     robot.RunCode(
"TCP_On", 
True)
   338     robot.MoveL(
Pose([200, 250, 348.734575, 180, 0, -150]), [-41.62707, -8.89064, -30.01809, 60.62329, 49.66749, -258.98418] )
   339     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   340     robot.MoveL(
Pose([250, 250, 191.421356, 180, 0, -150]), [-39.75778, -1.04537, -40.37883, 52.09118, 54.15317, -246.94403] )
   341     robot.RunMessage(
"Setting air valve off")
   342     robot.RunCode(
"TCP_Off", 
True)
   345     robot.waitDI(
'$IN[1]',
'TRUE', 10)
   346     robot.MoveL(
Pose([250, 300, 278.023897, 180, 0, -150]), [-37.52588, -6.32628, -34.59693, 53.52525, 49.24426, -251.44677] )
   347     robot.MoveL(
Pose([250, 200, 278.023897, 180, 0, -150]), [-41.85389, -1.95619, -34.89154, 57.43912, 52.34162, -253.73403] )
   348     robot.MoveL(
Pose([250, 150, 191.421356, 180, 0, -150]), [-43.82111, 3.29703, -40.29493, 56.02402, 56.61169, -249.23532] )
   349     robot.ProgFinish(
"Program")
   352     if len(robot.LOG) > 0:
   353         mbox(
'Program generation LOG:\n\n' + robot.LOG)
   355     input(
"Press Enter to close...")
   357 if __name__ == 
"__main__":
   358     """Function to call when the module is executed by itself: test""" def MoveC(self, pose1, joints1, pose2, joints2, conf_RLF_1=None, conf_RLF_2=None)
def setSpeed(self, speed_mms)
def ProgFinish(self, progname)
def addline(self, newline)
def RunCode(self, code, is_function_call=False)
def pose_2_str_ext(pose, joints)
def RunMessage(self, message, iscomment=False)
def UploadFTP(program, robot_ip, remote_path, ftp_user, ftp_pass)
def addlog(self, newline)
def MoveJ(self, pose, joints, conf_RLF=None)
def setDO(self, io_var, io_value)
def ProgStart(self, progname)
def mbox(msg, b1='OK', b2='Cancel', frame=True, t=False, entry=None)
def ProgSave(self, folder, progname, ask_user=False, show_result=False)
def setZoneData(self, zone_mm)
def setAccelerationJoints(self, accel_degss)
def setTool(self, pose, tool_id=None, tool_name=None)
def ProgSendRobot(self, robot_ip, remote_path, ftp_user, ftp_pass)
def setFrame(self, pose, frame_id=None, frame_name=None)
def setSpeedJoints(self, speed_degs)
def getSaveFile(strdir='C:\\', strfile='file.txt', strtitle='Save file as ...')
def waitDI(self, io_var, io_value, timeout_ms=-1)
def setAcceleration(self, accel_mmss)
def MoveL(self, pose, joints, conf_RLF=None)
def __init__(self, robotpost=None, robotname=None, robot_axes=6, kwargs)