diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-09-30 14:47:45 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-09-30 21:27:46 -0400 |
commit | 275b38685603eb34f832dfc3fbd8b63e5f610e18 (patch) | |
tree | 898f2c79748f217a1314f0c233ae0676dd5049f8 /klippy/cartesian.py | |
parent | e9505697fb587d7fa46f4c598cb13d20042879d1 (diff) | |
download | kutter-275b38685603eb34f832dfc3fbd8b63e5f610e18.tar.gz kutter-275b38685603eb34f832dfc3fbd8b63e5f610e18.tar.xz kutter-275b38685603eb34f832dfc3fbd8b63e5f610e18.zip |
toolhead: Allow kinematics class to verify the move prior to queuing it
Introduce a check_move() method in the extruder and cartesian
kinematic classes. This allows the lower level classes to verify the
contents of the move prior to queing that move.
The speed and acceleration handling for special Z and extrude only
moves are also moved from the generic toolhead class to the low-level
classes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/cartesian.py')
-rw-r--r-- | klippy/cartesian.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/klippy/cartesian.py b/klippy/cartesian.py index bc141c12..18a22382 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -22,17 +22,10 @@ class CartKinematics: def set_position(self, newpos): self.stepper_pos = [int(newpos[i]*self.steppers[i].inv_step_dist + 0.5) for i in StepList] - def get_max_xy_speed(self): + def get_max_speed(self): max_xy_speed = min(s.max_velocity for s in self.steppers[:2]) max_xy_accel = min(s.max_accel for s in self.steppers[:2]) return max_xy_speed, max_xy_accel - def get_max_speed(self, axes_d, move_d): - # Calculate max speed and accel for a given move - velocity_factor = min([self.steppers[i].max_velocity / abs(axes_d[i]) - for i in StepList if axes_d[i]]) - accel_factor = min([self.steppers[i].max_accel / abs(axes_d[i]) - for i in StepList if axes_d[i]]) - return velocity_factor * move_d, accel_factor * move_d def get_homed_position(self): return [s.get_homed_position() for s in self.steppers] def home(self, toolhead, axes): @@ -69,6 +62,18 @@ class CartKinematics: stepper.motor_enable(move_time, 0) def query_endstops(self, move_time): return homing.QueryEndstops(["x", "y", "z"], self.steppers) + def check_move(self, move): + if not move.axes_d[2]: + # Normal XY move - use defaults + return + # Move with Z - update velocity and accel for slower Z axis + axes_d = move.axes_d + move_d = move.move_d + velocity_factor = min([self.steppers[i].max_velocity / abs(axes_d[i]) + for i in StepList if axes_d[i]]) + accel_factor = min([self.steppers[i].max_accel / abs(axes_d[i]) + for i in StepList if axes_d[i]]) + move.limit_speed(velocity_factor * move_d, accel_factor * move_d) def move(self, move_time, move): inv_accel = 1. / move.accel inv_cruise_v = 1. / move.cruise_v |