Browse Source

discretize Hatchlines and Contourlines for z-Height

master
Jörg Kurlbaum 3 years ago
parent
commit
8eeef38276
  1. 36
      freecad/LaserCladdingWorkbench/commands.py
  2. 20
      freecad/LaserCladdingWorkbench/kuka.py
  3. 15
      freecad/LaserCladdingWorkbench/pad.py
  4. 2
      freecad/LaserCladdingWorkbench/templates/lasercladding.dat
  5. 7
      freecad/LaserCladdingWorkbench/utils.py

36
freecad/LaserCladdingWorkbench/commands.py

@ -169,18 +169,30 @@ class LCSaveProg():
if re.match('Contour*', progpart.Name): if re.match('Contour*', progpart.Name):
# do Conoutes # do Conoutes
face = pad.ref_body.getSubObject(pad.ref_surface) face = pad.ref_body.getSubObject(pad.ref_surface)
edges = Part.__sortEdges__(progpart.Shape.Edges) #edges = Part.__sortEdges__(progpart.Shape.Edges)
vlist = [] wires = progpart.Shape.Wires
for edge in edges: print("Number Contourlines (should be 1): ", len(wires))
vlist.extend([v.Point for v in edge.Vertexes]) counter = 0
poly = Part.makePolygon(vlist) for wire in wires:
#Part.show(poly, "ContourPath") line = []
poses = get_list_of_poses(face, poly.Edges) for edge in Part.__sortEdges__(wire.Edges):
if not hasattr(progpart, 'pathtype'): p0 = edge.Vertexes[0].Point
pathtype = 'LIN' p1 = edge.Vertexes[1].Point
else: for p in [p0, p1]:
pathtype = progpart.pathtype uv = face.Surface.parameter(p)
prog.append_contour(poses, pathtype) normal = face.normalAt(uv[0], uv[1])
pose = Kuka_Pose.from_point_and_normal(p, normal)
line.append(pose)
print("append contour line (segment): ", counter)
counter += 1
pathtype = getattr(progpart, 'pathtype', 'LIN')
prog.append_contour(line, pathtype)
#vlist = []
#for edge in edges:
# vlist.extend([v.Point for v in edge.Vertexes])
#poly = Part.makePolygon(vlist)
##Part.show(poly, "ContourPath")
#poses = get_list_of_poses(face, poly.Edges)
elif re.match('Hatch*', progpart.Name): elif re.match('Hatch*', progpart.Name):
face = pad.ref_body.getSubObject(pad.ref_surface) face = pad.ref_body.getSubObject(pad.ref_surface)
wires = progpart.Shape.Wires wires = progpart.Shape.Wires

20
freecad/LaserCladdingWorkbench/kuka.py

@ -15,7 +15,7 @@ header_src = """&ACCESS RVP
&PARAM EDITMASK = * &PARAM EDITMASK = *
""" """
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 30.0, A 0.0, B 0.0, C 0.0, E1 0.0, E2 0.0}"""
class Kuka_Layer: class Kuka_Layer:
def __init__(self): def __init__(self):
@ -168,28 +168,34 @@ class Kuka_Prog:
if len(layer.hatchlines): if len(layer.hatchlines):
print("Number Hatchlines: ", len(layer.hatchlines)) print("Number Hatchlines: ", len(layer.hatchlines))
f.write(";- Hatchlines\n") f.write(";- Hatchlines\n")
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) f.write("$VEL.CP = TRAVELSPEED ; m/s (vmax)\n")
f.write("LIN_REL {Z 90.0} C_VEL; just move up \n") f.write("LIN_REL {Z 90.0} C_VEL; just move up \n")
# to first point on part
(first_hatch_line, _) = layer.hatchlines[0]
segment = first_hatch_line[0]
f.write("LIN refpose:{}:{} C_VEL; move to first hatch point but with z_up\n".format(segment.translate_with(self.baseorigin).to_string(), z_up_pose))
for (line, seg_type) in layer.hatchlines: for (line, seg_type) in layer.hatchlines:
# a line has many segments # a line has many segments
# start laser at first segment # start laser at first segment
# stop with last # stop with last
f.write(";- Hatchline\n") f.write(";- Hatchline\n")
segment = line[0]
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax)
f.write("LIN refpose:{}:{} C_VEL; move to first hatch point but with z_up\n".format(segment.translate_with(self.baseorigin).to_string(), z_up_pose))
# One Hatchline
f.write(";- First Point in line \n") f.write(";- First Point in line \n")
segment = line[0]
f.write("$VEL.CP = TRAVELSPEED ; m/s (vproc)\n")
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.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("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 (vproc)\n")
# each segment # each segment
for segment in line[1:-1]: for segment in line[1:-1]:
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc)
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string()))
segment = line[-1] segment = line[-1]
f.write(";- Last Point in line \n") f.write(";- Last Point in line \n")
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) f.write("LIN refpose:{} C_VEL; GENERATED\n".format(segment.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("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out)
# if z height difference between this and next point, we should move up, else it's faster to just go on.
#f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax)
#f.write("LIN refpose:{}:{} C_VEL; move up from last hatch point \n".format(segment.translate_with(self.baseorigin).to_string(), z_up_pose))
f.write(";- End line \n") f.write(";- End line \n")

15
freecad/LaserCladdingWorkbench/pad.py

@ -102,13 +102,21 @@ class LaserPad:
contours = create_contour_lines(contours_geoms) contours = create_contour_lines(contours_geoms)
hatchlines = create_hatch_lines(hatch_geoms) hatchlines = create_hatch_lines(hatch_geoms)
for debug1 in contours:
Part.show(debug1, "Debug_Contours")
proj_contours = project_to_face(contours, face) proj_contours = project_to_face(contours, face)
proj_hatchlines = project_to_face(hatchlines, face) proj_hatchlines = project_to_face(hatchlines, face)
# DEBUG Part.show(Part.makeCompound(hatchlines)) # DEBUG Part.show(Part.makeCompound(hatchlines))
obj.purgeTouched() obj.purgeTouched()
for pc in proj_contours: for debug_shape in proj_contours:
p = Part.makeCompound(pc) Part.show(debug_shape, "Debug_Projected_Contours")
for contourline in proj_contours:
p = Part.makeCompound([])
wire = Part.makePolygon(contourline.Wires[0].discretize(Distance=3.0))
p.add(wire)
contours_comp = obj.newObject("Part::Feature", "Contours") contours_comp = obj.newObject("Part::Feature", "Contours")
LaserPath(contours_comp) LaserPath(contours_comp)
contours_comp.Shape = p contours_comp.Shape = p
@ -120,8 +128,7 @@ class LaserPad:
p = Part.makeCompound([]) p = Part.makeCompound([])
for hatchline in proj_hatchlines: for hatchline in proj_hatchlines:
# discretize by length # discretize by length
for line in hatchline: wire_sections = hatchline.Wires[0].discretize(Distance=3.0)
wire_sections = line.Wires[0].discretize(Distance=3.0)
wire = Part.makePolygon(wire_sections) wire = Part.makePolygon(wire_sections)
p.add(wire) p.add(wire)

2
freecad/LaserCladdingWorkbench/templates/lasercladding.dat

@ -20,5 +20,5 @@ DECL INT SUCCESS
DECL BASIS_SUGG_T LAST_BASIS={POINT1[] "P1 ",POINT2[] "P1 ",CP_PARAMS[] "CPDAT0 ",PTP_PARAMS[] "PDAT1 ",CONT[] " ",CP_VEL[] "2.0 ",PTP_VEL[] "100 ",SYNC_PARAMS[] "SYNCDAT ",SPL_NAME[] "S0 "} DECL BASIS_SUGG_T LAST_BASIS={POINT1[] "P1 ",POINT2[] "P1 ",CP_PARAMS[] "CPDAT0 ",PTP_PARAMS[] "PDAT1 ",CONT[] " ",CP_VEL[] "2.0 ",PTP_VEL[] "100 ",SYNC_PARAMS[] "SYNCDAT ",SPL_NAME[] "S0 "}
DECL E6POS XP1={X 1007.93701,Y 220.6707,Z 616.796082,A -59.0254211,B -89.0309219,C -120.955002,S 6,T 27,E1 4.45351398E-05,E2 12600.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0} DECL E6POS XP1={X 1007.93701,Y 220.6707,Z 616.796082,A -59.0254211,B -89.0309219,C -120.955002,S 6,T 27,E1 4.45351398E-05,E2 12600.0,E3 0.0,E4 0.0,E5 0.0,E6 0.0}
DECL FDAT FP1={TOOL_NO 6,BASE_NO 6,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE} DECL FDAT FP1={TOOL_NO 6,BASE_NO 6,IPO_FRAME #BASE,POINT2[] " ",TQ_STATE FALSE}
DECL PDAT PPDAT1={VEL 100.0,ACC 100.0,APO_DIST 100.0,GEAR_JERK 50.0} DECL PDAT PPDAT1={VEL 60.0,ACC 100.0,APO_DIST 100.0,GEAR_JERK 50.0}
ENDDAT ENDDAT

7
freecad/LaserCladdingWorkbench/utils.py

@ -17,11 +17,8 @@ def project_to_face(compounds, face):
# proj = Part.makeCompound([]) # proj = Part.makeCompound([])
proj = [] proj = []
for c in compounds: for c in compounds:
projection_result = [] shape = face.makeParallelProjection(c, App.Vector(0, 0, 1))
for e in c.Edges: proj.append(shape)
projection_result.append(face.makeParallelProjection(e, App.Vector(0, 0, 1)))
# proj.add(Part.makeCompound(projection_result))
proj.append(projection_result)
return proj return proj

Loading…
Cancel
Save