huh
This commit is contained in:
parent
6e88e23d92
commit
0f8fb9395c
2 changed files with 11 additions and 10 deletions
10
main.py
10
main.py
|
@ -3,21 +3,21 @@ import controller as ctl
|
|||
import GCode_Interpreterdc as gci
|
||||
import svgtroppagcode as sgc
|
||||
|
||||
instr = sgc.svg_to_gcode("test.svg").split("\n")
|
||||
instr = sgc.svg_to_gcode("clock.svg").split("\n")
|
||||
|
||||
|
||||
b = "socket.sock"
|
||||
sh = hw.SimuHardware(b)
|
||||
ctrl = ctl.DummyController()
|
||||
gtm1 = gci.GCodeToMotors(ctrl, sh)
|
||||
for i in instr:
|
||||
for i in instr[2:]:
|
||||
gtm1.instruction_converter(i)
|
||||
# gtm1.instruction_converter("G1 X25.000 Y25.000 F2.000")
|
||||
# gtm1.instruction_converter("G1 X30.000 Y25.000 F2.000")
|
||||
# gtm1.instruction_converter("G3 X30.000 Y45.000 I0 J10 F0.100")
|
||||
# gtm1.instruction_converter("G5 X50.000 Y45.000 I-5 J-5 P10 J5 F0.5000")
|
||||
# gtm1.instruction_converter("G5 X50.000 Y45.000 I-5 J-5 P10 J5 F0.5000")
|
||||
# gtm1.instruction_converter("G1 X50.000 Y50.000 F2.000")
|
||||
# gtm1.instruction_converter("G1 X50.000 Y100.000 F2.000")
|
||||
# gtm1.instruction_converter("G1 X100.000 Y-50.000 F2.000")
|
||||
gtm1.instruction_converter("G1 X-50.000 Y-100.000 F2.000")
|
||||
gtm1.instruction_converter("G1 X-100.000 Y50.000 F2.000")
|
||||
# gtm1.instruction_converter("G1 X-50.000 Y-100.000 F2.000")
|
||||
# gtm1.instruction_converter("G1 X-100.000 Y50.000 F2.000")
|
||||
|
|
|
@ -26,7 +26,7 @@ def extract_svg_paths(svg_file):
|
|||
|
||||
|
||||
# Function to compute time-reparametrized velocities using toppra based on segment type
|
||||
def compute_reparametrized_speeds(path, velocity_limit=100, acceleration_limit=500):
|
||||
def compute_reparametrized_speeds(path, velocity_limit=.5, acceleration_limit=1):
|
||||
sampled_points = []
|
||||
ss = []
|
||||
current_s = 0.0
|
||||
|
@ -57,8 +57,8 @@ def compute_reparametrized_speeds(path, velocity_limit=100, acceleration_limit=5
|
|||
]
|
||||
|
||||
instance = algo.TOPPRA(constraints, pc, solver_wrapper="seidel")
|
||||
sd_sq = instance.compute_parameterization(0, 0)
|
||||
return list(np.sqrt(sd_sq[1]))
|
||||
sd_sq = instance.compute_parameterization(0, 0)[1]
|
||||
return list(np.sqrt(sd_sq))
|
||||
|
||||
|
||||
|
||||
|
@ -69,8 +69,9 @@ def path_to_gcode(path, speeds):
|
|||
num_samples = 20 if isinstance(seg, svgpathtools.CubicBezier) else 10
|
||||
for t in np.linspace(0, 1, num_samples):
|
||||
point = seg.point(t)
|
||||
speed = speeds[speed_index] if speed_index < len(speeds) else 1000
|
||||
gcode.append(f"G1 X{point.real:.3f} Y{point.imag:.3f} F{speed}")
|
||||
speed = speeds[speed_index] if speed_index < len(speeds) else 1
|
||||
if speed != 0:
|
||||
gcode.append(f"G1 X{point.real:.3f} Y{point.imag:.3f} F{speed:.3f}")
|
||||
speed_index += 1
|
||||
|
||||
return '\n'.join(gcode)
|
||||
|
|
Loading…
Reference in a new issue