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>
This commit is contained in:
Kevin O'Connor
2025-01-10 11:27:30 -05:00
parent c72d73ec45
commit 4aa550837f
16 changed files with 28 additions and 23 deletions

View File

@@ -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:

View File

@@ -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):

View File

@@ -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):

View File

@@ -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

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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

View File

@@ -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):