toolhead: Fill cmove in toolhead instead of in each kinematic class

This simplifies the kinematic classes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-07-13 10:52:40 -04:00
parent 8faab46ed2
commit b988596519
4 changed files with 15 additions and 28 deletions

View File

@ -20,8 +20,6 @@ class CartKinematics:
self.limits = [(1.0, -1.0)] * 3
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
self.move_fill = ffi_lib.move_fill
for axis, rail in zip('xyz', self.rails):
rail.setup_cartesian_itersolve(axis)
# Setup stepper max halt velocity
@ -141,15 +139,9 @@ class CartKinematics:
def move(self, print_time, move):
if self.need_motor_enable:
self._check_motor_enable(print_time, move)
self.move_fill(
self.cmove, print_time,
move.accel_t, move.cruise_t, move.decel_t,
move.start_pos[0], move.start_pos[1], move.start_pos[2],
move.axes_d[0], move.axes_d[1], move.axes_d[2],
move.start_v, move.cruise_v, move.accel)
for i, rail in enumerate(self.rails):
if move.axes_d[i]:
rail.step_itersolve(self.cmove)
rail.step_itersolve(move.cmove)
# Dual carriage support
def _activate_carriage(self, carriage):
toolhead = self.printer.lookup_object('toolhead')

View File

@ -22,8 +22,6 @@ class CoreXYKinematics:
self.limits = [(1.0, -1.0)] * 3
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
self.move_fill = ffi_lib.move_fill
self.rails[0].setup_itersolve(ffi_main.gc(
ffi_lib.corexy_stepper_alloc('+'), ffi_lib.free))
self.rails[1].setup_itersolve(ffi_main.gc(
@ -128,13 +126,7 @@ class CoreXYKinematics:
if self.need_motor_enable:
self._check_motor_enable(print_time, move)
axes_d = move.axes_d
cmove = self.cmove
self.move_fill(
cmove, print_time,
move.accel_t, move.cruise_t, move.decel_t,
move.start_pos[0], move.start_pos[1], move.start_pos[2],
axes_d[0], axes_d[1], axes_d[2],
move.start_v, move.cruise_v, move.accel)
cmove = move.cmove
rail_x, rail_y, rail_z = self.rails
if axes_d[0] or axes_d[1]:
rail_x.step_itersolve(cmove)

View File

@ -62,8 +62,6 @@ class DeltaKinematics:
for angle in self.angles]
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
self.move_fill = ffi_lib.move_fill
for r, a, t in zip(self.rails, self.arm2, self.towers):
sk = ffi_main.gc(ffi_lib.delta_stepper_alloc(a, t[0], t[1]),
ffi_lib.free)
@ -163,14 +161,8 @@ class DeltaKinematics:
def move(self, print_time, move):
if self.need_motor_enable:
self._check_motor_enable(print_time)
self.move_fill(
self.cmove, print_time,
move.accel_t, move.cruise_t, move.decel_t,
move.start_pos[0], move.start_pos[1], move.start_pos[2],
move.axes_d[0], move.axes_d[1], move.axes_d[2],
move.start_v, move.cruise_v, move.accel)
for rail in self.rails:
rail.step_itersolve(self.cmove)
rail.step_itersolve(move.cmove)
# Helper functions for DELTA_CALIBRATE script
def get_stable_position(self):
steppers = [rail.get_steppers()[0] for rail in self.rails]

View File

@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging, importlib
import mcu, homing, kinematics.extruder
import mcu, homing, chelper, kinematics.extruder
# Common suffixes: _d is distance (in mm), _v is velocity (in
# mm/second), _v2 is velocity squared (mm^2/s^2), _t is time (in
@ -17,6 +17,7 @@ class Move:
self.start_pos = tuple(start_pos)
self.end_pos = tuple(end_pos)
self.accel = toolhead.max_accel
self.cmove = toolhead.cmove
self.is_kinematic_move = True
self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
self.move_d = move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
@ -91,6 +92,12 @@ class Move:
# Generate step times for the move
next_move_time = self.toolhead.get_next_move_time()
if self.is_kinematic_move:
self.toolhead.move_fill(
self.cmove, next_move_time,
self.accel_t, self.cruise_t, self.decel_t,
self.start_pos[0], self.start_pos[1], self.start_pos[2],
self.axes_d[0], self.axes_d[1], self.axes_d[2],
self.start_v, self.cruise_v, self.accel)
self.toolhead.kin.move(next_move_time, self)
if self.axes_d[3]:
self.toolhead.extruder.move(next_move_time, self)
@ -226,6 +233,10 @@ class ToolHead:
self.motor_off_time = config.getfloat('motor_off_time', 600., above=0.)
self.motor_off_timer = self.reactor.register_timer(
self._motor_off_handler, self.reactor.NOW)
# Setup iterative solver
ffi_main, ffi_lib = chelper.get_ffi()
self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
self.move_fill = ffi_lib.move_fill
# Create kinematics class
self.extruder = kinematics.extruder.DummyExtruder()
self.move_queue.set_extruder(self.extruder)