From c8434ec54b0517503af4aeee9016783d508118b0 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 8 Jan 2021 11:52:28 -0500 Subject: kinematics: Calculate axis_minimum/axis_maximum in advance Calculate the get_status() axis_minimum and axis_maximum fields in advance so that they don't need to be calculated on each get_status() call. Signed-off-by: Kevin O'Connor --- klippy/kinematics/winch.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'klippy/kinematics/winch.py') diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py index 4785d8ac..b5d3c245 100644 --- a/klippy/kinematics/winch.py +++ b/klippy/kinematics/winch.py @@ -1,9 +1,9 @@ # Code for handling the kinematics of cable winch robots # -# Copyright (C) 2018-2019 Kevin O'Connor +# Copyright (C) 2018-2021 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. -import stepper, mathutil, homing +import stepper, mathutil class WinchKinematics: def __init__(self, toolhead, config): @@ -28,6 +28,9 @@ class WinchKinematics: for s in self.steppers: s.set_max_jerk(max_halt_velocity, max_accel) # Setup boundary checks + acoords = 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.], ()) def get_steppers(self): return list(self.steppers) @@ -47,15 +50,10 @@ class WinchKinematics: pass def get_status(self, eventtime): # XXX - homed_checks and rail limits not implemented - axes_min = [0.0, 0.0, 0.0, 0.0] - axes_max = [0.0, 0.0, 0.0, 0.0] - for pos, axis in enumerate('xyz'): - axes_min[pos] = min([a[pos] for a in self.anchors]) - axes_max[pos] = max([a[pos] for a in self.anchors]) return { 'homed_axes': 'xyz', - 'axis_minimum': homing.Coord(*axes_min), - 'axis_maximum': homing.Coord(*axes_max) + 'axis_minimum': self.axes_min, + 'axis_maximum': self.axes_max, } def load_kinematics(toolhead, config): -- cgit v1.2.3-70-g09d2