kinematics: Convert get_rails() method to get_steppers()

All callers of get_rails() actually just want the steppers, so return
them directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-07-16 10:16:16 -04:00
parent 89835940f7
commit ca505bf4ac
6 changed files with 14 additions and 21 deletions

View File

@ -44,9 +44,8 @@ class PrinterProbe:
'QUERY_PROBE', self.cmd_QUERY_PROBE, desc=self.cmd_QUERY_PROBE_help)
def build_config(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
for rail in kin.get_rails("Z"):
for stepper in rail.get_steppers():
stepper.add_to_endstop(self.mcu_probe)
for stepper in kin.get_steppers('Z'):
stepper.add_to_endstop(self.mcu_probe)
def setup_pin(self, pin_params):
if (pin_params['pin'] != 'z_virtual_endstop'
or pin_params['type'] != 'endstop'):

View File

@ -18,6 +18,8 @@ class ZTilt:
except:
raise config.error("Unable to parse z_positions in %s" % (
config.get_name()))
if len(z_positions) < 2:
raise config.error("z_tilt requires at least two z_positions")
self.probe_helper = probe.ProbePointsHelper(config, self)
self.z_steppers = []
# Register Z_TILT_ADJUST command
@ -30,12 +32,7 @@ class ZTilt:
self.handle_connect()
def handle_connect(self):
kin = self.printer.lookup_object('toolhead').get_kinematics()
try:
z_steppers = kin.get_rails('Z')[0].get_steppers()
except:
logging.exception("z_tilt stepper lookup")
raise self.printer.config_error(
"z_tilt requires multiple Z steppers")
z_steppers = kin.get_steppers('Z')
if len(z_steppers) != len(self.z_positions):
raise self.printer.config_error(
"z_tilt z_positions needs exactly %d items" % (len(z_steppers),))

View File

@ -602,10 +602,7 @@ class GCodeParser:
self.cmd_default(params)
return
kin = self.toolhead.get_kinematics()
steppers = []
rails = kin.get_rails()
for rail in rails:
steppers += rail.get_steppers()
steppers = kin.get_steppers()
mcu_pos = " ".join(["%s:%d" % (s.get_name(), s.get_mcu_position())
for s in steppers])
stepper_pos = " ".join(

View File

@ -43,10 +43,10 @@ class CartKinematics:
self.printer.lookup_object('gcode').register_command(
'SET_DUAL_CARRIAGE', self.cmd_SET_DUAL_CARRIAGE,
desc=self.cmd_SET_DUAL_CARRIAGE_help)
def get_rails(self, flags=""):
def get_steppers(self, flags=""):
if flags == "Z":
return [self.rails[2]]
return list(self.rails)
return self.rails[2].get_steppers()
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_position(self):
return [rail.get_commanded_position() for rail in self.rails]
def set_position(self, newpos, homing_axes):

View File

@ -32,10 +32,10 @@ class CoreXYKinematics:
self.rails[1].set_max_jerk(max_xy_halt_velocity, max_accel)
self.rails[2].set_max_jerk(
min(max_halt_velocity, self.max_z_velocity), self.max_z_accel)
def get_rails(self, flags=""):
def get_steppers(self, flags=""):
if flags == "Z":
return [self.rails[2]]
return list(self.rails)
return self.rails[2].get_steppers()
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_position(self):
pos = [rail.get_commanded_position() for rail in self.rails]
return [0.5 * (pos[0] + pos[1]), 0.5 * (pos[0] - pos[1]), pos[2]]

View File

@ -80,8 +80,8 @@ class DeltaKinematics:
% (math.sqrt(self.max_xy2), math.sqrt(self.slow_xy2),
math.sqrt(self.very_slow_xy2)))
self.set_position([0., 0., 0.], ())
def get_rails(self, flags=""):
return list(self.rails)
def get_steppers(self, flags=""):
return [s for rail in self.rails for s in rail.get_steppers()]
def _actuator_to_cartesian(self, spos):
sphere_coords = [(t[0], t[1], sp) for t, sp in zip(self.towers, spos)]
return mathutil.trilateration(sphere_coords, self.arm2)