00001
00002
00003
00004
00005 from Robot import *
00006 from Part import *
00007 from FreeCAD import *
00008
00009
00010
00011 rob = Robot6Axis()
00012 print rob
00013
00014
00015 Start = rob.Tcp
00016 print Start
00017 print rob.Axis1
00018
00019
00020 rob.Axis1 = 5.0
00021
00022 print rob.Tcp
00023
00024
00025 rob.Tcp = Start
00026 print rob.Axis1
00027
00028
00029 rob.Axis2 = 5.0
00030 print rob.Tcp
00031 rob.Tcp = Start
00032 print rob.Axis2
00033
00034
00035 w = Waypoint(Placement(),name="Pt",type="LIN")
00036 print w.Name,w.Type,w.Pos,w.Cont,w.Velocity,w.Base,w.Tool
00037
00038
00039 l = [w]
00040 for i in range(5):
00041 l.append(Waypoint(Placement(Vector(0,0,i*100),Vector(1,0,0),0),"LIN","Pt"))
00042
00043
00044 t = Trajectory(l)
00045 print t
00046 for i in range(7):
00047 t.insertWaypoints(Waypoint(Placement(Vector(0,0,i*100+500),Vector(1,0,0),0),"LIN","Pt"))
00048
00049
00050 print t.Waypoints
00051
00052 del rob,Start,t,l,w
00053
00054
00055
00056
00057
00058 if(App.activeDocument() == None):App.newDocument()
00059
00060 App.activeDocument().addObject("Robot::RobotObject","Robot")
00061
00062 App.activeDocument().Robot.RobotVrmlFile = App.getResourceDir()+"Mod/Robot/Lib/Kuka/kr500_1.wrl"
00063 App.activeDocument().Robot.RobotKinematicFile = App.getResourceDir()+"Mod/Robot/Lib/Kuka/kr500_1.csv"
00064
00065 App.activeDocument().Robot.Axis2 = -90
00066 App.activeDocument().Robot.Axis3 = 90
00067
00068
00069 pos = FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp
00070
00071 pos.move(App.Vector(-10,0,0))
00072 FreeCAD.getDocument("Unnamed").getObject("Robot").Tcp = pos
00073
00074
00075 App.activeDocument().addObject("Robot::TrajectoryObject","Trajectory")
00076
00077 t = App.activeDocument().Trajectory.Trajectory
00078
00079 StartTcp = App.activeDocument().Robot.Tcp
00080 t.insertWaypoints(StartTcp)
00081 App.activeDocument().Trajectory.Trajectory = t
00082 print App.activeDocument().Trajectory.Trajectory
00083
00084
00085 for i in range(7):
00086 t.insertWaypoints(Waypoint(Placement(Vector(0,1000,i*100+500),Vector(1,0,0),i),"LIN","Pt"))
00087
00088 t.insertWaypoints(StartTcp)
00089 App.activeDocument().Trajectory.Trajectory = t
00090 print App.activeDocument().Trajectory.Trajectory
00091
00092
00093
00094
00095
00096
00097
00098 from KukaExporter import ExportCompactSub
00099
00100 ExportCompactSub(App.activeDocument().Robot,App.activeDocument().Trajectory,'D:/Temp/TestOut.src')
00101
00102
00103 for w in App.activeDocument().Trajectory.Trajectory.Waypoints:
00104 (A,B,C) = (w.Pos.Rotation.toEuler())
00105 print ("LIN {X %.3f,Y %.3f,Z %.3f,A %.3f,B %.3f,C %.3f} ; %s"%(w.Pos.Base.x,w.Pos.Base.y,w.Pos.Base.z,A,B,C,w.Name))
00106