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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2021-01-08 11:52:28 -05:00
parent f79187d726
commit c8434ec54b
9 changed files with 71 additions and 77 deletions

View File

@@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math
import stepper, homing
import stepper
class CoreXZKinematics:
def __init__(self, toolhead, config):
@@ -31,6 +31,9 @@ class CoreXZKinematics:
self.max_z_accel = config.getfloat(
'max_z_accel', max_accel, above=0., maxval=max_accel)
self.limits = [(1.0, -1.0)] * 3
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
# Setup stepper max halt velocity
max_halt_velocity = toolhead.get_max_axis_halt()
max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
@@ -94,14 +97,10 @@ class CoreXZKinematics:
self.max_z_velocity * z_ratio, self.max_z_accel * z_ratio)
def get_status(self, eventtime):
axes = [a for a, (l, h) in zip("xyz", self.limits) if l <= h]
axes_min = [0.0, 0.0, 0.0, 0.0]
axes_max = [0.0, 0.0, 0.0, 0.0]
for pos, rail in enumerate(self.rails):
axes_min[pos], axes_max[pos] = rail.get_range()
return {
'homed_axes': "".join(axes),
'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):