Skip to content

Commit

Permalink
added get_width()
Browse files Browse the repository at this point in the history
(cherry picked from commit 1a6465248f9ae56a58e397229ca89cf243ad07e6)
  • Loading branch information
lukashof committed Sep 11, 2024
1 parent cabee40 commit baef0e9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pyGCodeDecode/gcode_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,30 @@ def get_values(self, t: float, output_unit_system: str = None) -> Tuple[List[flo

return tmp_vel, tmp_pos

def get_width(self, t: float, extrusion_h: float, filament_dia: float):
"""Return the extrusion width for a certain extrusion height at time.
Args:
t (float): time
extrusion_h (float): extrusion height / layer height
filament_dia (float): filament_diameter
Returns:
float: width
"""
curr_val = self.get_values(t=t)

feed_rate = np.linalg.norm(curr_val[0][:3]) # calculate feed rate at current time
flow_rate = curr_val[0][3] # get extrusion rate at current time

filament_cross_sec = (np.pi * filament_dia**2) / 4 # calculate cross area of filament

width = (
(flow_rate * filament_cross_sec) / (extrusion_h * feed_rate) if feed_rate > 0 else 0
) # calculate width, zero if no movement.

return width

def check_initial_setup(self, initial_machine_setup):
"""Check the printer Dict for typos or missing parameters and raise errors if invalid.
Expand Down

0 comments on commit baef0e9

Please sign in to comment.