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

@ -1,10 +1,10 @@
# Code for handling the kinematics of polar robots
#
# Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
# Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import logging, math
import stepper, homing
import stepper
class PolarKinematics:
def __init__(self, toolhead, config):
@ -32,6 +32,10 @@ class PolarKinematics:
'max_z_accel', max_accel, above=0., maxval=max_accel)
self.limit_z = (1.0, -1.0)
self.limit_xy2 = -1.
max_xy = self.rails[0].get_range()[1]
min_z, max_z = self.rails[1].get_range()
self.axes_min = toolhead.Coord(-max_xy, -max_xy, min_z, 0.)
self.axes_max = toolhead.Coord(max_xy, max_xy, max_z, 0.)
# Setup stepper max halt velocity
max_halt_velocity = toolhead.get_max_axis_halt()
stepper_bed.set_max_jerk(max_halt_velocity, max_accel)
@ -108,14 +112,10 @@ class PolarKinematics:
def get_status(self, eventtime):
xy_home = "xy" if self.limit_xy2 >= 0. else ""
z_home = "z" if self.limit_z[0] <= self.limit_z[1] else ""
lim_xy = self.rails[0].get_range()
lim_z = self.rails[1].get_range()
axes_min = [lim_xy[0], lim_xy[0], lim_z[0], 0.]
axes_max = [lim_xy[1], lim_xy[1], lim_z[1], 0.]
return {
'homed_axes': xy_home + z_home,
'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):