KukaExporter.py

Go to the documentation of this file.
00001 # Kuka export lib (c) Juergen Riegel 2009 LGPL 2.1 or higher
00002 
00003 import time
00004 
00005 TeachPointFold = """
00006 ;FOLD LIN P4  Vel= 0.2 m/s CPDAT1 Tool[1] Base[0];%{PE}%R 5.4.27,%MKUKATPBASIS,%CMOVE,%VLIN,%P 1:LIN, 2:P4, 3:, 5:0.2, 7:CPDAT1
00007 $BWDSTART = FALSE
00008 LDAT_ACT=LCPDAT1
00009 FDAT_ACT=FP4
00010 BAS(#CP_PARAMS,0.2)
00011 LIN XP4 
00012 ;ENDFOLD
00013 """
00014 
00015 TeachPointDat = """
00016 DECL E6POS XP4={X -25.1844196,Y 1122.42603,Z 1158.07996,A -14.3267002,B 0.537901878,C 179.028305,S 6,T 59,E1 0.0,E2 0.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}
00017 DECL FDAT FP4={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " "}
00018 DECL LDAT LCPDAT1={VEL 2.0,ACC 100.0,APO_DIST 100.0,APO_FAC 50.0,ORI_TYP #VAR}
00019 """
00020 
00021 HeaderSrc = """&ACCESS RVP
00022 &REL 1
00023 &PARAM TEMPLATE = C:\KRC\Roboter\Template\ExpertVorgabe
00024 &PARAM EDITMASK = * 
00025 """
00026 
00027 
00028 def ExportCompactSub(Rob,Trak,FileName):
00029         print Rob,Trak,FileName
00030         Traj = Trak.Trajectory
00031         # open the output file
00032         SrcFile = open(FileName,'w')
00033         # header
00034         SrcFile.write(HeaderSrc)
00035         # subroutine definition
00036         SrcFile.write("DEF "+Trak.Name+"( )\n\n")
00037         SrcFile.write(";- Kuka src file, generated by FreeCAD (http://free-cad.sf.net)\n")
00038         SrcFile.write(";- "+ time.asctime()+"\n\n")
00039         # defining world and base
00040         SrcFile.write(";------------- definitions ------------\n")
00041         SrcFile.write("EXT BAS (BAS_COMMAND :IN,REAL :IN ) ;set base to World\n")
00042         SrcFile.write("BAS (#INITMOV,0 ) ;Initialicing the defaults for Vel and so on \n\n")
00043         
00044         SrcFile.write("\n;------------- main part ------------\n")
00045 
00046         for w in Traj.Waypoints:
00047                 (X,Y,Z) = (w.Pos.Base.x,w.Pos.Base.x,w.Pos.Base.x)
00048                 (A,B,C) = (w.Pos.Rotation.toEuler())
00049                 V = w.Velocity / 1000.0 # from mm/s to m/s
00050                 SrcFile.write("$VEL.CP = %f ; m/s ; m/s \n"%V)
00051                 SrcFile.write("LIN {X %.3f,Y %.3f,Z %.3f,A %.3f,B %.3f,C %.3f} ; %s\n"%(w.Pos.Base.x,w.Pos.Base.y,w.Pos.Base.z,A,B,C,w.Name))
00052         
00053         # end of subroutine
00054         SrcFile.write("\n;------------- end ------------\n")
00055         SrcFile.write("END \n\n")
00056 
00057         SrcFile.close()
00058         # open the output file
00059         #DatFile = open(FileName[:-4]+'.dat','w')
00060         # header
00061         #DatFile.write(HeaderSrc)
00062         # subroutine definition
00063         #DatFile.write("DEFDAT "+Trak.Name+" PUBLIC\n\n")
00064         #DatFile.write("ENDDAT\n")
00065         #DatFile.close()
00066         
00067 def ExportFullSub(Rob,Trak,FileName):
00068         print Trak,FileName
00069 

Generated on Wed Nov 23 19:00:20 2011 for FreeCAD by  doxygen 1.6.1