|
|
|
@ -4,22 +4,10 @@ import time |
|
|
|
import Part |
|
|
|
import Part |
|
|
|
import copy |
|
|
|
import copy |
|
|
|
import os |
|
|
|
import os |
|
|
|
|
|
|
|
import os.path |
|
|
|
|
|
|
|
from jinja2 import Environment, FileSystemLoader |
|
|
|
|
|
|
|
import io |
|
|
|
|
|
|
|
|
|
|
|
TeachPointFold = """ |
|
|
|
|
|
|
|
;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 |
|
|
|
|
|
|
|
$BWDSTART = FALSE |
|
|
|
|
|
|
|
LDAT_ACT=LCPDAT1 |
|
|
|
|
|
|
|
FDAT_ACT=FP4 |
|
|
|
|
|
|
|
BAS(#CP_PARAMS,0.2) |
|
|
|
|
|
|
|
LIN XP4 |
|
|
|
|
|
|
|
;ENDFOLD |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TeachPointDat = """ |
|
|
|
|
|
|
|
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} |
|
|
|
|
|
|
|
DECL FDAT FP4={TOOL_NO 1,BASE_NO 0,IPO_FRAME #BASE,POINT2[] " "} |
|
|
|
|
|
|
|
DECL LDAT LCPDAT1={VEL 2.0,ACC 100.0,APO_DIST 100.0,APO_FAC 50.0,ORI_TYP #VAR} |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
header_src = """&ACCESS RVP |
|
|
|
header_src = """&ACCESS RVP |
|
|
|
&REL 1 |
|
|
|
&REL 1 |
|
|
|
@ -27,22 +15,20 @@ header_src = """&ACCESS RVP |
|
|
|
&PARAM EDITMASK = * |
|
|
|
&PARAM EDITMASK = * |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
ptp_fold = """;FOLD PTP xp1 Vel=100 % PDAT1 Tool[6]:laser6 Base[2]:Laser;%{PE}%R 8.2.24,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:xp1, 3:, 5:100, 7:PDAT1 |
|
|
|
|
|
|
|
$BWDSTART=FALSE |
|
|
|
|
|
|
|
PDAT_ACT=PPDAT1 |
|
|
|
|
|
|
|
FDAT_ACT=Fxp1 |
|
|
|
|
|
|
|
BAS(#PTP_PARAMS,100) |
|
|
|
|
|
|
|
PTP Xxp1 |
|
|
|
|
|
|
|
;ENDFOLD""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
z_up_pose = """{X 0.0, Y 0.0, Z 50.0, A 0.0, B 0.0, C 0.0, E1 0.0, E2 0.0}""" |
|
|
|
z_up_pose = """{X 0.0, Y 0.0, Z 50.0, A 0.0, B 0.0, C 0.0, E1 0.0, E2 0.0}""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Kuka_Layer: |
|
|
|
|
|
|
|
def __init__(self): |
|
|
|
|
|
|
|
self.contours = [] |
|
|
|
|
|
|
|
self.hatchlines = [] |
|
|
|
|
|
|
|
|
|
|
|
class Kuka_Prog: |
|
|
|
class Kuka_Prog: |
|
|
|
def __init__(self): |
|
|
|
def __init__(self): |
|
|
|
self.contour_path_list = [] |
|
|
|
# each layer is a tuple of Contours[] and Hatchlines[] |
|
|
|
self.hatchlines_list = [] |
|
|
|
self.layers = [] |
|
|
|
|
|
|
|
self.current_layer = -1 |
|
|
|
|
|
|
|
# self.contour_path_list = [] |
|
|
|
|
|
|
|
# self.hatchlines_list = [] |
|
|
|
self.baseorigin = (0, 0, 0) |
|
|
|
self.baseorigin = (0, 0, 0) |
|
|
|
self.tool = 6 |
|
|
|
self.tool = 6 |
|
|
|
self.base = 6 |
|
|
|
self.base = 6 |
|
|
|
@ -85,16 +71,23 @@ class Kuka_Prog: |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.use_laser_out = self.laser_pilot_out |
|
|
|
self.use_laser_out = self.laser_pilot_out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_layer(self): |
|
|
|
|
|
|
|
self.layers.append(Kuka_Layer()) |
|
|
|
|
|
|
|
self.current_layer += 1 |
|
|
|
|
|
|
|
return self.current_layer |
|
|
|
|
|
|
|
|
|
|
|
def append_contour(self, poses, segmenttype='LIN'): |
|
|
|
def append_contour(self, poses, segmenttype='LIN'): |
|
|
|
self.contour_path_list.append((poses, segmenttype)) |
|
|
|
layer = self.layers[self.current_layer] |
|
|
|
|
|
|
|
layer.contours.append((poses, segmenttype)) |
|
|
|
|
|
|
|
|
|
|
|
def append_hatchline(self, line, segmenttype='LIN'): |
|
|
|
def append_hatchline(self, line, segmenttype='LIN'): |
|
|
|
if not len(self.hatchlines_list): |
|
|
|
layer = self.layers[self.current_layer] |
|
|
|
self.hatchlines_list.append((line, segmenttype)) |
|
|
|
if not len(layer.hatchlines): |
|
|
|
|
|
|
|
layer.hatchlines.append((line, segmenttype)) |
|
|
|
# poses are sorted |
|
|
|
# poses are sorted |
|
|
|
# but maybe we need to reverse |
|
|
|
# but maybe we need to reverse |
|
|
|
# get the point distance from first and last pose |
|
|
|
# get the point distance from first and last pose |
|
|
|
last, _ = self.hatchlines_list[-1] |
|
|
|
last, _ = layer.hatchlines[-1] |
|
|
|
nfirst = line[0] |
|
|
|
nfirst = line[0] |
|
|
|
nlast = line[-1] |
|
|
|
nlast = line[-1] |
|
|
|
last = FreeCAD.Base.Vector(last[1].X, last[1].Y, last[1].Z) |
|
|
|
last = FreeCAD.Base.Vector(last[1].X, last[1].Y, last[1].Z) |
|
|
|
@ -104,25 +97,7 @@ class Kuka_Prog: |
|
|
|
dnf = last.distanceToPoint(nfirst) |
|
|
|
dnf = last.distanceToPoint(nfirst) |
|
|
|
if dnl < dnf: |
|
|
|
if dnl < dnf: |
|
|
|
line.reverse() |
|
|
|
line.reverse() |
|
|
|
self.hatchlines_list.append((line, segmenttype)) |
|
|
|
layer.hatchlines.append((line, segmenttype)) |
|
|
|
|
|
|
|
|
|
|
|
def append_poses(self, poses): |
|
|
|
|
|
|
|
if not len(self.pose_list): |
|
|
|
|
|
|
|
self.pose_list.extend(poses) |
|
|
|
|
|
|
|
# poses are sorted |
|
|
|
|
|
|
|
# but maybe we need to reverse |
|
|
|
|
|
|
|
# get the point distance from first and last pose |
|
|
|
|
|
|
|
last = self.pose_list[-1] |
|
|
|
|
|
|
|
nfirst = poses[0] |
|
|
|
|
|
|
|
nlast = poses[-1] |
|
|
|
|
|
|
|
last = FreeCAD.Base.Vector(last.X, last.Y, last.Z) |
|
|
|
|
|
|
|
nlast = FreeCAD.Base.Vector(nlast.X, nlast.Y, nlast.Z) |
|
|
|
|
|
|
|
nfirst = FreeCAD.Base.Vector(nfirst.X, nfirst.Y, nfirst.Z) |
|
|
|
|
|
|
|
dnl = last.distanceToPoint(nlast) |
|
|
|
|
|
|
|
dnf = last.distanceToPoint(nfirst) |
|
|
|
|
|
|
|
if dnl < dnf: |
|
|
|
|
|
|
|
poses.reverse() |
|
|
|
|
|
|
|
self.pose_list.extend(poses) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def draw_wire(self, obj): |
|
|
|
def draw_wire(self, obj): |
|
|
|
path = Part.makePolygon([FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in self.pose_list ]) |
|
|
|
path = Part.makePolygon([FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in self.pose_list ]) |
|
|
|
@ -134,6 +109,98 @@ class Kuka_Prog: |
|
|
|
def get_vectors(self): |
|
|
|
def get_vectors(self): |
|
|
|
return [FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in poses for poses in self.contour_path_list ] |
|
|
|
return [FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in poses for poses in self.contour_path_list ] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_with_template(self, article, path, templatename): |
|
|
|
|
|
|
|
if self.simulation: |
|
|
|
|
|
|
|
filename_src = "kvt_{}_sim.src".format(article) |
|
|
|
|
|
|
|
filename_dat = "kvt_{}_sim.dat".format(article) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
filename_src = "kvt_{}.src".format(article) |
|
|
|
|
|
|
|
filename_dat = "kvt_{}.dat".format(article) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user_dir = FreeCAD.getUserAppDataDir() |
|
|
|
|
|
|
|
template_dir = os.path.join(user_dir, "Mod", "fc_lasercladding_wb", "freecad", "LaserCladdingWorkbench", "templates") |
|
|
|
|
|
|
|
environment = Environment(loader=FileSystemLoader(template_dir)) |
|
|
|
|
|
|
|
template_src = environment.get_template(templatename+".src") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with io.StringIO("") as f: |
|
|
|
|
|
|
|
for layer_idx, layer in enumerate(self.layers): |
|
|
|
|
|
|
|
f.write(";- =============================\n") |
|
|
|
|
|
|
|
f.write(";- Layer {}\n".format(layer_idx)) |
|
|
|
|
|
|
|
f.write(";- Contourpaths\n") |
|
|
|
|
|
|
|
for contour_idx, (poses, seg_type) in enumerate(layer.contours): |
|
|
|
|
|
|
|
f.write(";- Contourpath {}\n".format(contour_idx)) |
|
|
|
|
|
|
|
# start laser code |
|
|
|
|
|
|
|
f.write(";- Move to pose up from contour start\n") |
|
|
|
|
|
|
|
f.write("$VEL.CP = TRAVELSPEED ; m/s (vmax)\n") |
|
|
|
|
|
|
|
f.write("LIN_REL {Z 90.0} C_VEL; relative 90mm up\n") |
|
|
|
|
|
|
|
f.write("LIN refpose:{}:{} C_VEL; move to start point but save z distance\n".format(poses[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
|
|
|
|
if seg_type == 'LIN': |
|
|
|
|
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(poses[0].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=TRUE ; Turn on Laser at point\n" % self.use_laser_out) |
|
|
|
|
|
|
|
f.write("$VEL.CP = WELDSPEED ; m/s ; m/s (vproc)\n") |
|
|
|
|
|
|
|
for pose in poses[1:]: |
|
|
|
|
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if seg_type == 'SPLINE': |
|
|
|
|
|
|
|
f.write("SPLINE\n") |
|
|
|
|
|
|
|
for pose in poses: |
|
|
|
|
|
|
|
f.write(" SPL refpose:{} ; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
f.write("ENDSPLINE\n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f.write(";- Turn off Laser\n") |
|
|
|
|
|
|
|
f.write("$OUT[%d] = FALSE\n" % self.use_laser_out) |
|
|
|
|
|
|
|
# end of subroutine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f.write(";- =============================\n") |
|
|
|
|
|
|
|
f.write(";- Hatchlines\n") |
|
|
|
|
|
|
|
f.write("$VEL.CP = TRAVELSPEED ; m/s ; m/s \n") |
|
|
|
|
|
|
|
f.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
|
|
|
|
(line, seg_type) = layer.hatchlines[0] |
|
|
|
|
|
|
|
f.write("LIN refpose:{}:{} C_VEL; move to first hatch point but with z_up\n".format(line[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
|
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
|
|
|
|
# start laser code |
|
|
|
|
|
|
|
f.write(";- Hatchline\n") |
|
|
|
|
|
|
|
if seg_type == 'LIN': |
|
|
|
|
|
|
|
f.write("$VEL.CP = TRAVELSPEED ;m/s \n") |
|
|
|
|
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(line[0].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=TRUE; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
|
|
|
|
f.write("$VEL.CP = WELDSPEED ; m/s \n") |
|
|
|
|
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(line[1].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
|
|
|
|
f.write(";- ========= END LAYER =========\n") |
|
|
|
|
|
|
|
f.write(";- =============================\n") |
|
|
|
|
|
|
|
# end of subroutine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content = template_src.render( |
|
|
|
|
|
|
|
artikel=article, |
|
|
|
|
|
|
|
tool=self.tool, |
|
|
|
|
|
|
|
base=self.base, |
|
|
|
|
|
|
|
powder_out=self.powder_out, |
|
|
|
|
|
|
|
inert_gas_out=self.inert_gas_out, |
|
|
|
|
|
|
|
laser_out=self.use_laser_out, |
|
|
|
|
|
|
|
laserpower=self.laser_power, |
|
|
|
|
|
|
|
vproc=self.vproc, |
|
|
|
|
|
|
|
vmax=self.vmax, |
|
|
|
|
|
|
|
paths=f.getvalue() |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# dat template |
|
|
|
|
|
|
|
template_dat = environment.get_template(templatename+".dat") |
|
|
|
|
|
|
|
datcontent = template_dat.render( |
|
|
|
|
|
|
|
artikel=article |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Save the rendere template to output file |
|
|
|
|
|
|
|
with open(filename_src, mode="w", encoding="utf-8") as message: |
|
|
|
|
|
|
|
message.write(content) |
|
|
|
|
|
|
|
print(f"... wrote {filename_src}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(filename_dat, mode="w", encoding="utf-8") as message: |
|
|
|
|
|
|
|
message.write(datcontent) |
|
|
|
|
|
|
|
print(f"... wrote {filename_dat}") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_prog(self, article, path): |
|
|
|
def save_prog(self, article, path): |
|
|
|
if self.simulation: |
|
|
|
if self.simulation: |
|
|
|
filename = "kvt_{}_sim.src".format(article) |
|
|
|
filename = "kvt_{}_sim.src".format(article) |
|
|
|
@ -148,6 +215,9 @@ class Kuka_Prog: |
|
|
|
srcfile.write(";- " + time.asctime() + "\n\n") |
|
|
|
srcfile.write(";- " + time.asctime() + "\n\n") |
|
|
|
# defining world and base |
|
|
|
# defining world and base |
|
|
|
srcfile.write("E6POS startp\n") |
|
|
|
srcfile.write("E6POS startp\n") |
|
|
|
|
|
|
|
srcfile.write("REAL WELDSPEED\n") |
|
|
|
|
|
|
|
srcfile.write("REAL TRAVELSPEED\n") |
|
|
|
|
|
|
|
srcfile.write("REAL LASERPOWER\n") |
|
|
|
srcfile.write("E6POS point1\n") |
|
|
|
srcfile.write("E6POS point1\n") |
|
|
|
# srcfile.write("DECL E6AXIS xp1={A1 -1.9, A2 -105.76, A3 79.97, A4 178.83, A5 -20.3, A6 -4.37, E1 -90, E2 0}\n") |
|
|
|
# srcfile.write("DECL E6AXIS xp1={A1 -1.9, A2 -105.76, A3 79.97, A4 178.83, A5 -20.3, A6 -4.37, E1 -90, E2 0}\n") |
|
|
|
srcfile.write(";------------- definitions ------------\n") |
|
|
|
srcfile.write(";------------- definitions ------------\n") |
|
|
|
@ -157,18 +227,27 @@ class Kuka_Prog: |
|
|
|
srcfile.write("BAS (#BASE,%d) ;Initialicing the defaults for Vel and so on \n\n" % self.base) |
|
|
|
srcfile.write("BAS (#BASE,%d) ;Initialicing the defaults for Vel and so on \n\n" % self.base) |
|
|
|
srcfile.write("PTP {A1 -33.31, A2 -104.71, A3 114.60, A4 282.66, A5 -39.21, A6 -104.87, E1 -90, E2 1.0}\n") |
|
|
|
srcfile.write("PTP {A1 -33.31, A2 -104.71, A3 114.60, A4 282.66, A5 -39.21, A6 -104.87, E1 -90, E2 1.0}\n") |
|
|
|
srcfile.write("\n;------------- main part ------------\n") |
|
|
|
srcfile.write("\n;------------- main part ------------\n") |
|
|
|
srcfile.write("startp=$POS_ACT\n") |
|
|
|
|
|
|
|
#V = w.Velocity / 1000.0 # from mm/s to m/s |
|
|
|
#V = w.Velocity / 1000.0 # from mm/s to m/s |
|
|
|
CDIS = 2.3 |
|
|
|
CDIS = 2.3 |
|
|
|
CVEL = 95.0 |
|
|
|
CVEL = 95.0 |
|
|
|
|
|
|
|
srcfile.write(";- Process Parameters (change here)\n") |
|
|
|
|
|
|
|
srcfile.write("TRAVELSPEED = %f ; m/s\n" % self.vmax) |
|
|
|
|
|
|
|
srcfile.write("WELDSPEED = %f ; m/s\n" % self.vproc) |
|
|
|
|
|
|
|
srcfile.write("LASERPOWER = %f ; Set laser power\n" % self.laser_power) |
|
|
|
|
|
|
|
|
|
|
|
srcfile.write(";- Movement paramters\n") |
|
|
|
#srcfile.write("; hier teach punkt eingeben\n;FOLD PTP P1 Vel=25 % PDAT1 Tool[2]:LASER Base[2]:Laser;%{PE}%R 8.2.24,%MKUKATPBASIS,%CMOVE,%VPTP,%P 1:PTP, 2:P1, 3:, 5:25, 7:PDAT1\n$BWDSTART=FALSE\nPDAT_ACT=PPDAT1\nFDAT_ACT=FP1\nBAS(#PTP_PARAMS,25)\nPTP XP1\n;ENDFOLD\n") |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srcfile.write("startp=$POS_ACT\n") |
|
|
|
|
|
|
|
srcfile.write(";- Ab hier nicht mehr aendern!\n") |
|
|
|
|
|
|
|
srcfile.write(";- Movement parameters\n") |
|
|
|
|
|
|
|
srcfile.write("$VEL.CP = TRAVELSPEED\n") |
|
|
|
srcfile.write("$APO.CDIS = %f ; mm \n" % CDIS) |
|
|
|
srcfile.write("$APO.CDIS = %f ; mm \n" % CDIS) |
|
|
|
srcfile.write("$APO.CVEL = %f ; percent \n" % CVEL) |
|
|
|
srcfile.write("$APO.CVEL = %f ; percent \n" % CVEL) |
|
|
|
|
|
|
|
|
|
|
|
srcfile.write(";- Input/Output settings\n") |
|
|
|
srcfile.write(";- Input/Output settings\n") |
|
|
|
srcfile.write("$ANOUT[1] = %f ; Set laser power\n" % self.laser_power) |
|
|
|
srcfile.write("$ANOUT[1] = LASERPOWER ; Set laser power\n") |
|
|
|
srcfile.write("$OUT[%d] = FALSE ; Set Laser off\n" % self.use_laser_out) # don't know but must be on |
|
|
|
srcfile.write("$OUT[%d] = FALSE ; Set Laser off\n" % self.use_laser_out) # don't know but must be on |
|
|
|
if not self.simulation: |
|
|
|
if not self.simulation: |
|
|
|
srcfile.write("$OUT[2] = TRUE ; Set Laser activation on\n") # don't know but must be on |
|
|
|
srcfile.write("$OUT[2] = TRUE ; Set Laser activation on\n") # don't know but must be on |
|
|
|
@ -184,45 +263,52 @@ class Kuka_Prog: |
|
|
|
srcfile.write("point1.T = startp.T\n") |
|
|
|
srcfile.write("point1.T = startp.T\n") |
|
|
|
srcfile.write("LIN point1 C_VEL; GENERATED\n") |
|
|
|
srcfile.write("LIN point1 C_VEL; GENERATED\n") |
|
|
|
srcfile.write("WAIT SEC 7.0\n") |
|
|
|
srcfile.write("WAIT SEC 7.0\n") |
|
|
|
srcfile.write(";- Contourpaths\n") |
|
|
|
for layer_idx, layer in enumerate(self.layers): |
|
|
|
for (poses, seg_type) in self.contour_path_list: |
|
|
|
srcfile.write(";- =============================\n") |
|
|
|
# start laser code |
|
|
|
srcfile.write(";- Layer {}\n".format(layer_idx)) |
|
|
|
srcfile.write(";- Move to pose up from contour start\n") |
|
|
|
srcfile.write(";- Contourpaths\n") |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s (vmax)\n" % self.vmax) |
|
|
|
for contour_idx, (poses, seg_type) in enumerate(layer.contours): |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; relative 90mm up\n") |
|
|
|
srcfile.write(";- Contourpath {}\n".format(contour_idx)) |
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to start point but save z distance\n".format(poses[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
# start laser code |
|
|
|
if seg_type == 'LIN': |
|
|
|
srcfile.write(";- Move to pose up from contour start\n") |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(poses[0].translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s (vmax)\n" % self.vmax) |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True ; Turn on Laser at point\n" % self.use_laser_out) |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; relative 90mm up\n") |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s (vproc)\n" % self.vproc) |
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to start point but save z distance\n".format(poses[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
for pose in poses[1:]: |
|
|
|
if seg_type == 'LIN': |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(poses[0].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True ; Turn on Laser at point\n" % self.use_laser_out) |
|
|
|
if seg_type == 'SPLINE': |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s (vproc)\n" % self.vproc) |
|
|
|
srcfile.write("SPLINE\n") |
|
|
|
for pose in poses[1:]: |
|
|
|
for pose in poses: |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write(" SPL {} ; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
srcfile.write("ENDSPLINE\n") |
|
|
|
if seg_type == 'SPLINE': |
|
|
|
|
|
|
|
srcfile.write("SPLINE\n") |
|
|
|
srcfile.write(";- Turn off Laser\n") |
|
|
|
for pose in poses: |
|
|
|
srcfile.write("$OUT[%d] = FALSE\n" % self.use_laser_out) |
|
|
|
srcfile.write(" SPL {} ; GENERATED\n".format(pose.translate_with(self.baseorigin).to_string())) |
|
|
|
# end of subroutine |
|
|
|
srcfile.write("ENDSPLINE\n") |
|
|
|
|
|
|
|
|
|
|
|
srcfile.write(";- Hatchlines\n") |
|
|
|
srcfile.write(";- Turn off Laser\n") |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write("$OUT[%d] = FALSE\n" % self.use_laser_out) |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
# end of subroutine |
|
|
|
(line, seg_type) = self.hatchlines_list[0] |
|
|
|
|
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to first hatch point but with z_up\n".format(line[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
srcfile.write(";- =============================\n") |
|
|
|
for (line, seg_type) in self.hatchlines_list: |
|
|
|
srcfile.write(";- Hatchlines\n") |
|
|
|
# start laser code |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write(";- Hatchline\n") |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
if seg_type == 'LIN': |
|
|
|
(line, seg_type) = layer.hatchlines[0] |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to first hatch point but with z_up\n".format(line[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[0].translate_with(self.baseorigin).to_string())) |
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
# start laser code |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc) |
|
|
|
srcfile.write(";- Hatchline\n") |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[1].translate_with(self.baseorigin).to_string())) |
|
|
|
if seg_type == 'LIN': |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
|
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[0].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
|
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc) |
|
|
|
|
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[1].translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
|
|
|
|
srcfile.write(";- ========= END LAYER =========\n") |
|
|
|
|
|
|
|
srcfile.write(";- =============================\n") |
|
|
|
# end of subroutine |
|
|
|
# end of subroutine |
|
|
|
srcfile.write("$OUT[%d] = FALSE; laser off\n" % self.use_laser_out) |
|
|
|
srcfile.write("$OUT[%d] = FALSE; laser off\n" % self.use_laser_out) |
|
|
|
srcfile.write("$OUT[%d] = FALSE; powder off\n" % self.powder_out) |
|
|
|
srcfile.write("$OUT[%d] = FALSE; powder off\n" % self.powder_out) |
|
|
|
|