aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-01-10 11:27:30 -0500
committerKevin O'Connor <kevin@koconnor.net>2025-01-21 18:58:23 -0500
commit4aa550837fc170d0b77a0d461ca4f970b7bee7ae (patch)
tree7a185d949b9179c5f9b3977539e9cfda5ca7756e
parentc72d73ec450119b5fbe13d98409037a21ae97101 (diff)
downloadkutter-4aa550837fc170d0b77a0d461ca4f970b7bee7ae.tar.gz
kutter-4aa550837fc170d0b77a0d461ca4f970b7bee7ae.tar.xz
kutter-4aa550837fc170d0b77a0d461ca4f970b7bee7ae.zip
toolhead: Pass set_position() homing_axes parameter as a string
Use strings such as "xyz" to specify which axes are to be considered homing during a set_position() call. This makes the parameter a little less cryptic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/force_move.py2
-rw-r--r--klippy/extras/homing.py5
-rw-r--r--klippy/extras/homing_override.py4
-rw-r--r--klippy/extras/manual_stepper.py2
-rw-r--r--klippy/extras/safe_z_home.py2
-rw-r--r--klippy/kinematics/cartesian.py3
-rw-r--r--klippy/kinematics/corexy.py2
-rw-r--r--klippy/kinematics/corexz.py2
-rw-r--r--klippy/kinematics/delta.py4
-rw-r--r--klippy/kinematics/deltesian.py7
-rw-r--r--klippy/kinematics/hybrid_corexy.py3
-rw-r--r--klippy/kinematics/hybrid_corexz.py3
-rw-r--r--klippy/kinematics/polar.py4
-rw-r--r--klippy/kinematics/rotary_delta.py4
-rw-r--r--klippy/kinematics/winch.py2
-rw-r--r--klippy/toolhead.py2
16 files changed, 28 insertions, 23 deletions
diff --git a/klippy/extras/force_move.py b/klippy/extras/force_move.py
index 598783a4..0b2187fd 100644
--- a/klippy/extras/force_move.py
+++ b/klippy/extras/force_move.py
@@ -136,7 +136,7 @@ class ForceMove:
clear_axes = [axes.index(a) for a in axes if a in clear]
logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f clear=%s",
x, y, z, ','.join((axes[i] for i in clear_axes)))
- toolhead.set_position([x, y, z, curpos[3]], homing_axes=(0, 1, 2))
+ toolhead.set_position([x, y, z, curpos[3]], homing_axes="xyz")
toolhead.get_kinematics().clear_homing_state(clear_axes)
def load_config(config):
diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py
index bbad5337..add209ec 100644
--- a/klippy/extras/homing.py
+++ b/klippy/extras/homing.py
@@ -187,7 +187,8 @@ class Homing:
# Notify of upcoming homing operation
self.printer.send_event("homing:home_rails_begin", self, rails)
# Alter kinematics class to think printer is at forcepos
- homing_axes = [axis for axis in range(3) if forcepos[axis] is not None]
+ force_axes = [axis for axis in range(3) if forcepos[axis] is not None]
+ homing_axes = "".join(["xyz"[i] for i in force_axes])
startpos = self._fill_coord(forcepos)
homepos = self._fill_coord(movepos)
self.toolhead.set_position(startpos, homing_axes=homing_axes)
@@ -231,7 +232,7 @@ class Homing:
+ self.adjust_pos.get(s.get_name(), 0.))
for s in kin.get_steppers()}
newpos = kin.calc_position(kin_spos)
- for axis in homing_axes:
+ for axis in force_axes:
homepos[axis] = newpos[axis]
self.toolhead.set_position(homepos)
diff --git a/klippy/extras/homing_override.py b/klippy/extras/homing_override.py
index e498c8b8..0a987d59 100644
--- a/klippy/extras/homing_override.py
+++ b/klippy/extras/homing_override.py
@@ -46,11 +46,11 @@ class HomingOverride:
# Calculate forced position (if configured)
toolhead = self.printer.lookup_object('toolhead')
pos = toolhead.get_position()
- homing_axes = []
+ homing_axes = ""
for axis, loc in enumerate(self.start_pos):
if loc is not None:
pos[axis] = loc
- homing_axes.append(axis)
+ homing_axes += "xyz"[axis]
toolhead.set_position(pos, homing_axes=homing_axes)
# Perform homing
context = self.template.create_template_context()
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index 40db4a50..9f21cc8d 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -109,7 +109,7 @@ class ManualStepper:
self.sync_print_time()
def get_position(self):
return [self.rail.get_commanded_position(), 0., 0., 0.]
- def set_position(self, newpos, homing_axes=()):
+ def set_position(self, newpos, homing_axes=""):
self.do_set_position(newpos[0])
def get_last_move_time(self):
self.sync_print_time()
diff --git a/klippy/extras/safe_z_home.py b/klippy/extras/safe_z_home.py
index ca0756cf..3ebaa13e 100644
--- a/klippy/extras/safe_z_home.py
+++ b/klippy/extras/safe_z_home.py
@@ -37,7 +37,7 @@ class SafeZHoming:
if 'z' not in kin_status['homed_axes']:
# Always perform the z_hop if the Z axis is not homed
pos[2] = 0
- toolhead.set_position(pos, homing_axes=[2])
+ toolhead.set_position(pos, homing_axes="z")
toolhead.manual_move([None, None, self.z_hop],
self.z_hop_speed)
toolhead.get_kinematics().clear_homing_state((2,))
diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py
index 1db40f4f..0c22172b 100644
--- a/klippy/kinematics/cartesian.py
+++ b/klippy/kinematics/cartesian.py
@@ -65,7 +65,8 @@ class CartKinematics:
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
- for axis in homing_axes:
+ for axis_name in homing_axes:
+ axis = "xyz".index(axis_name)
if self.dc_module and axis == self.dc_module.axis:
rail = self.dc_module.get_primary_rail().get_rail()
else:
diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py
index 15169e50..891e58e0 100644
--- a/klippy/kinematics/corexy.py
+++ b/klippy/kinematics/corexy.py
@@ -39,7 +39,7 @@ class CoreXYKinematics:
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
- if i in homing_axes:
+ if "xyz"[i] in homing_axes:
self.limits[i] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
diff --git a/klippy/kinematics/corexz.py b/klippy/kinematics/corexz.py
index 5298698d..34def72a 100644
--- a/klippy/kinematics/corexz.py
+++ b/klippy/kinematics/corexz.py
@@ -39,7 +39,7 @@ class CoreXZKinematics:
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
- if i in homing_axes:
+ if "xyz"[i] in homing_axes:
self.limits[i] = rail.get_range()
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py
index f10586b7..beb1826f 100644
--- a/klippy/kinematics/delta.py
+++ b/klippy/kinematics/delta.py
@@ -88,7 +88,7 @@ class DeltaKinematics:
math.sqrt(self.very_slow_xy2)))
self.axes_min = toolhead.Coord(-max_xy, -max_xy, self.min_z, 0.)
self.axes_max = toolhead.Coord(max_xy, max_xy, self.max_z, 0.)
- self.set_position([0., 0., 0.], ())
+ self.set_position([0., 0., 0.], "")
def get_steppers(self):
return [s for rail in self.rails for s in rail.get_steppers()]
def _actuator_to_cartesian(self, spos):
@@ -101,7 +101,7 @@ class DeltaKinematics:
for rail in self.rails:
rail.set_position(newpos)
self.limit_xy2 = -1.
- if tuple(homing_axes) == (0, 1, 2):
+ if homing_axes == "xyz":
self.need_home = False
def clear_homing_state(self, axes):
# Clearing homing state for each axis individually is not implemented
diff --git a/klippy/kinematics/deltesian.py b/klippy/kinematics/deltesian.py
index d0865475..e0118b34 100644
--- a/klippy/kinematics/deltesian.py
+++ b/klippy/kinematics/deltesian.py
@@ -87,7 +87,7 @@ class DeltesianKinematics:
self.axes_min = toolhead.Coord(*[l[0] for l in self.limits], e=0.)
self.axes_max = toolhead.Coord(*[l[1] for l in self.limits], e=0.)
self.homed_axis = [False] * 3
- self.set_position([0., 0., 0.], ())
+ self.set_position([0., 0., 0.], "")
def get_steppers(self):
return [s for rail in self.rails for s in rail.get_steppers()]
def _actuator_to_cartesian(self, sp):
@@ -113,8 +113,9 @@ class DeltesianKinematics:
def set_position(self, newpos, homing_axes):
for rail in self.rails:
rail.set_position(newpos)
- for n in homing_axes:
- self.homed_axis[n] = True
+ for axis_name in homing_axes:
+ axis = "xyz".index(axis_name)
+ self.homed_axis[axis] = True
def clear_homing_state(self, axes):
for i, _ in enumerate(self.limits):
if i in axes:
diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py
index 72b0b85b..6d72a89c 100644
--- a/klippy/kinematics/hybrid_corexy.py
+++ b/klippy/kinematics/hybrid_corexy.py
@@ -67,7 +67,8 @@ class HybridCoreXYKinematics:
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
- for axis in homing_axes:
+ for axis_name in homing_axes:
+ axis = "xyz".index(axis_name)
if self.dc_module and axis == self.dc_module.axis:
rail = self.dc_module.get_primary_rail().get_rail()
else:
diff --git a/klippy/kinematics/hybrid_corexz.py b/klippy/kinematics/hybrid_corexz.py
index 041df8d7..05fe096e 100644
--- a/klippy/kinematics/hybrid_corexz.py
+++ b/klippy/kinematics/hybrid_corexz.py
@@ -67,7 +67,8 @@ class HybridCoreXZKinematics:
def set_position(self, newpos, homing_axes):
for i, rail in enumerate(self.rails):
rail.set_position(newpos)
- for axis in homing_axes:
+ for axis_name in homing_axes:
+ axis = "xyz".index(axis_name)
if self.dc_module and axis == self.dc_module.axis:
rail = self.dc_module.get_primary_rail().get_rail()
else:
diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py
index 8369d386..548b4bac 100644
--- a/klippy/kinematics/polar.py
+++ b/klippy/kinematics/polar.py
@@ -45,9 +45,9 @@ class PolarKinematics:
def set_position(self, newpos, homing_axes):
for s in self.steppers:
s.set_position(newpos)
- if 2 in homing_axes:
+ if "z" in homing_axes:
self.limit_z = self.rails[1].get_range()
- if 0 in homing_axes and 1 in homing_axes:
+ if "x" in homing_axes and "y" in homing_axes:
self.limit_xy2 = self.rails[0].get_range()[1]**2
def clear_homing_state(self, axes):
if 0 in axes or 1 in axes:
diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py
index 89f963d2..6b457ccb 100644
--- a/klippy/kinematics/rotary_delta.py
+++ b/klippy/kinematics/rotary_delta.py
@@ -74,7 +74,7 @@ class RotaryDeltaKinematics:
max_xy = math.sqrt(self.max_xy2)
self.axes_min = toolhead.Coord(-max_xy, -max_xy, self.min_z, 0.)
self.axes_max = toolhead.Coord(max_xy, max_xy, self.max_z, 0.)
- self.set_position([0., 0., 0.], ())
+ self.set_position([0., 0., 0.], "")
def get_steppers(self):
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_position(self, stepper_positions):
@@ -84,7 +84,7 @@ class RotaryDeltaKinematics:
for rail in self.rails:
rail.set_position(newpos)
self.limit_xy2 = -1.
- if tuple(homing_axes) == (0, 1, 2):
+ if homing_axes == "xyz":
self.need_home = False
def clear_homing_state(self, axes):
# Clearing homing state for each axis individually is not implemented
diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py
index c69d1b6d..0003826b 100644
--- a/klippy/kinematics/winch.py
+++ b/klippy/kinematics/winch.py
@@ -26,7 +26,7 @@ class WinchKinematics:
acoords = list(zip(*self.anchors))
self.axes_min = toolhead.Coord(*[min(a) for a in acoords], e=0.)
self.axes_max = toolhead.Coord(*[max(a) for a in acoords], e=0.)
- self.set_position([0., 0., 0.], ())
+ self.set_position([0., 0., 0.], "")
def get_steppers(self):
return list(self.steppers)
def calc_position(self, stepper_positions):
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index 256915da..f1a9afda 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -457,7 +457,7 @@ class ToolHead:
# Movement commands
def get_position(self):
return list(self.commanded_pos)
- def set_position(self, newpos, homing_axes=()):
+ def set_position(self, newpos, homing_axes=""):
self.flush_step_generation()
ffi_main, ffi_lib = chelper.get_ffi()
ffi_lib.trapq_set_position(self.trapq, self.print_time,