Skip to content

Commit

Permalink
Merge branch 'dev_change_unit_system_name' into 'main'
Browse files Browse the repository at this point in the history
changing "SImm" to "SI (mm)"

See merge request kit/fast/lb/collaboration/additive-manufacturing/pygcodedecode!39
  • Loading branch information
lukashof committed Jan 14, 2025
2 parents 83db10b + c8ffd2f commit 207c230
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions pyGCodeDecode/examples/benchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def benchy_example():
# set the start position of the extruder
printer_setup.set_initial_position(
initial_position={"X": 0.0, "Y": 0.0, "Z": 0.0, "E": 0.0},
input_unit_system="SImm",
input_unit_system="SI (mm)",
)

# running the simulation by creating a simulation object
benchy_simulation = simulation(
gcode_path=data_dir / "benchy.gcode",
initial_machine_setup=printer_setup,
output_unit_system="SImm",
output_unit_system="SI (mm)",
)

# save a short summary of the simulation
Expand All @@ -63,7 +63,7 @@ def benchy_example():
simulation=benchy_simulation,
filepath=output_dir / "benchy_prusa_mini_event_series.csv",
tolerance=1.0e-12,
output_unit_system="SImm",
output_unit_system="SI (mm)",
)

# create a 3D-plot and save a VTK as well as a screenshot
Expand Down
10 changes: 5 additions & 5 deletions pyGCodeDecode/gcode_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(
gcode_path: pathlib.Path,
machine_name: str = None,
initial_machine_setup: "setup" = None,
output_unit_system: str = "SImm",
output_unit_system: str = "SI (mm)",
):
"""Initialize the Simulation of a given G-code with initial machine setup or default machine.
Expand All @@ -182,7 +182,7 @@ def __init__(
gcode_path: (Path) path to GCode
machine name: (string, default = None) name of the default machine to use
initial_machine_setup: (setup, default = None) setup instance
output_unit_system: (string, default = "SImm") available unit systems: SI, SImm & inch
output_unit_system: (string, default = "SI (mm)") available unit systems: SI, SI (mm) & inch
Example:
```python
Expand All @@ -195,7 +195,7 @@ def __init__(
self.firmware = None

# set output unit system
self.available_unit_systems = {"SI": 1e-3, "SImm": 1.0, "inch": 1 / 25.4}
self.available_unit_systems = {"SI": 1e-3, "SI (mm)": 1.0, "inch": 1 / 25.4}
if output_unit_system in self.available_unit_systems:
self.output_unit_system = output_unit_system
else:
Expand Down Expand Up @@ -814,8 +814,8 @@ def __init__(
"""
# the input unit system is only implemented for 'set_initial_position'.
# Regardless, the class has this attribute so it's more similar to the simulation class.
self.available_unit_systems = {"SI": 1e3, "SImm": 1.0, "inch": 25.4}
self.input_unit_system = "SImm"
self.available_unit_systems = {"SI": 1e3, "SI (mm)": 1.0, "inch": 25.4}
self.input_unit_system = "SI (mm)"

self.initial_position = {
"X": 0,
Expand Down
4 changes: 2 additions & 2 deletions pyGCodeDecode/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class state:
class p_settings:
"""Store Printing Settings."""

def __init__(self, p_acc, jerk, vX, vY, vZ, vE, speed, units="SImm"):
def __init__(self, p_acc, jerk, vX, vY, vZ, vE, speed, units="SI (mm)"):
"""Initialize printing settings.
Args:
Expand All @@ -20,7 +20,7 @@ def __init__(self, p_acc, jerk, vX, vY, vZ, vE, speed, units="SImm"):
vZ: (float) max z velocity
vE: (float) max e velocity
speed: (float) default target velocity
units: (string, default = "SImm") unit settings
units: (string, default = "SI (mm)") unit settings
"""
self.p_acc = p_acc # printing acceleration
self.jerk = jerk # jerk settings
Expand Down
4 changes: 2 additions & 2 deletions pyGCodeDecode/state_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
default_virtual_machine = {
"absolute_position": True,
"absolute_extrusion": True,
"units": "SImm",
"units": "SI (mm)",
"initial_position": None,
# general properties
"nozzle_diam": 0.4,
Expand Down Expand Up @@ -281,7 +281,7 @@ def dict_list_traveler(line_dict_list: List[dict], initial_machine_setup: dict)
if "G20" in line_dict:
virtual_machine["units"] = "inch"
if "G21" in line_dict:
virtual_machine["units"] = "SImm"
virtual_machine["units"] = "SI (mm)"

# position & velocity
pos_keys = ["X", "Y", "Z"]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_end_to_end.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ def test_end_to_end_extensive():
# set the start position of the extruder
printer_setup.set_initial_position(
initial_position={"X": 0.0, "Y": 0.0, "Z": 0.0, "E": 0.0},
input_unit_system="SImm",
input_unit_system="SI (mm)",
)

# running the simulation by creating a simulation object
end_to_end_simulation = simulation(
gcode_path=data_dir / "test_state_generator.gcode",
initial_machine_setup=printer_setup,
output_unit_system="SImm",
output_unit_system="SI (mm)",
)

# save a short summary of the simulation
Expand All @@ -57,7 +57,7 @@ def test_end_to_end_extensive():
simulation=end_to_end_simulation,
filepath=output_dir / "test_end_to_end_event_series.csv",
tolerance=1.0e-12,
output_unit_system="SImm",
output_unit_system="SI (mm)",
)

# create a 3D-plot and save a VTK as well as a screenshot
Expand Down
6 changes: 3 additions & 3 deletions tests/test_planner_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_planner_block():
dist = 10
pos_0 = position(0, 0, 0, 0)
pos_1 = position(dist, 0, 0, 0)
settings = state.p_settings(p_acc=100, jerk=0, vX=100, vY=100, vZ=100, vE=100, speed=10, units="SImm")
settings = state.p_settings(p_acc=100, jerk=0, vX=100, vY=100, vZ=100, vE=100, speed=10, units="SI (mm)")
state_0 = state(state_position=pos_0, state_p_settings=settings)
state_1 = state(state_position=pos_1, state_p_settings=settings)
state_1.prev_state = state_0
Expand All @@ -45,7 +45,7 @@ def test_planner_block():
dist = 30
pos_0 = position(0, 0, 0, 0)
pos_1 = position(dist, 0, 0, 0)
settings = state.p_settings(p_acc=100, jerk=0, vX=100, vY=100, vZ=100, vE=100, speed=100, units="SImm")
settings = state.p_settings(p_acc=100, jerk=0, vX=100, vY=100, vZ=100, vE=100, speed=100, units="SI (mm)")
state_0 = state(state_position=pos_0, state_p_settings=settings)
state_1 = state(state_position=pos_1, state_p_settings=settings)
state_1.prev_state = state_0
Expand All @@ -67,7 +67,7 @@ def test_planner_block():
pos_1 = position(dist, 0, 0, 0)
pos_2 = position(dist * 2, 0, 0, 0)

settings = state.p_settings(p_acc=100, jerk=10, vX=100, vY=100, vZ=100, vE=100, speed=100, units="SImm")
settings = state.p_settings(p_acc=100, jerk=10, vX=100, vY=100, vZ=100, vE=100, speed=100, units="SI (mm)")
state_0 = state(state_position=pos_0, state_p_settings=settings)
state_1 = state(state_position=pos_1, state_p_settings=settings)
state_2 = state(state_position=pos_2, state_p_settings=settings)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_state_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def test_state_generator():
assert states[12].state_position.get_vec(withExtrusion=True) == [7, 7, 7, 7] # abs move
# assert states[13] # virtual null all axis
assert states[14].state_position.get_vec(withExtrusion=True) == [14, 14, 14, 14] # abs move with offset
assert states[14].state_p_settings.units == "SImm"
assert states[14].state_p_settings.units == "SI (mm)"
assert states[15].state_p_settings.units == "inch"
assert states[16].state_p_settings.units == "SImm"
assert states[16].state_p_settings.units == "SI (mm)"
assert states[16].layer == 0
assert states[17].comment == "LAYER cue"
assert states[17].layer == 1
Expand Down

0 comments on commit 207c230

Please sign in to comment.