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:
parent
8faab46ed2
commit
b988596519
|
@ -20,8 +20,6 @@ class CartKinematics:
|
||||||
self.limits = [(1.0, -1.0)] * 3
|
self.limits = [(1.0, -1.0)] * 3
|
||||||
# Setup iterative solver
|
# Setup iterative solver
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
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):
|
for axis, rail in zip('xyz', self.rails):
|
||||||
rail.setup_cartesian_itersolve(axis)
|
rail.setup_cartesian_itersolve(axis)
|
||||||
# Setup stepper max halt velocity
|
# Setup stepper max halt velocity
|
||||||
|
@ -141,15 +139,9 @@ class CartKinematics:
|
||||||
def move(self, print_time, move):
|
def move(self, print_time, move):
|
||||||
if self.need_motor_enable:
|
if self.need_motor_enable:
|
||||||
self._check_motor_enable(print_time, move)
|
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):
|
for i, rail in enumerate(self.rails):
|
||||||
if move.axes_d[i]:
|
if move.axes_d[i]:
|
||||||
rail.step_itersolve(self.cmove)
|
rail.step_itersolve(move.cmove)
|
||||||
# Dual carriage support
|
# Dual carriage support
|
||||||
def _activate_carriage(self, carriage):
|
def _activate_carriage(self, carriage):
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
|
|
@ -22,8 +22,6 @@ class CoreXYKinematics:
|
||||||
self.limits = [(1.0, -1.0)] * 3
|
self.limits = [(1.0, -1.0)] * 3
|
||||||
# Setup iterative solver
|
# Setup iterative solver
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
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(
|
self.rails[0].setup_itersolve(ffi_main.gc(
|
||||||
ffi_lib.corexy_stepper_alloc('+'), ffi_lib.free))
|
ffi_lib.corexy_stepper_alloc('+'), ffi_lib.free))
|
||||||
self.rails[1].setup_itersolve(ffi_main.gc(
|
self.rails[1].setup_itersolve(ffi_main.gc(
|
||||||
|
@ -128,13 +126,7 @@ class CoreXYKinematics:
|
||||||
if self.need_motor_enable:
|
if self.need_motor_enable:
|
||||||
self._check_motor_enable(print_time, move)
|
self._check_motor_enable(print_time, move)
|
||||||
axes_d = move.axes_d
|
axes_d = move.axes_d
|
||||||
cmove = self.cmove
|
cmove = move.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)
|
|
||||||
rail_x, rail_y, rail_z = self.rails
|
rail_x, rail_y, rail_z = self.rails
|
||||||
if axes_d[0] or axes_d[1]:
|
if axes_d[0] or axes_d[1]:
|
||||||
rail_x.step_itersolve(cmove)
|
rail_x.step_itersolve(cmove)
|
||||||
|
|
|
@ -62,8 +62,6 @@ class DeltaKinematics:
|
||||||
for angle in self.angles]
|
for angle in self.angles]
|
||||||
# Setup iterative solver
|
# Setup iterative solver
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
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):
|
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]),
|
sk = ffi_main.gc(ffi_lib.delta_stepper_alloc(a, t[0], t[1]),
|
||||||
ffi_lib.free)
|
ffi_lib.free)
|
||||||
|
@ -163,14 +161,8 @@ class DeltaKinematics:
|
||||||
def move(self, print_time, move):
|
def move(self, print_time, move):
|
||||||
if self.need_motor_enable:
|
if self.need_motor_enable:
|
||||||
self._check_motor_enable(print_time)
|
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:
|
for rail in self.rails:
|
||||||
rail.step_itersolve(self.cmove)
|
rail.step_itersolve(move.cmove)
|
||||||
# Helper functions for DELTA_CALIBRATE script
|
# Helper functions for DELTA_CALIBRATE script
|
||||||
def get_stable_position(self):
|
def get_stable_position(self):
|
||||||
steppers = [rail.get_steppers()[0] for rail in self.rails]
|
steppers = [rail.get_steppers()[0] for rail in self.rails]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import math, logging, importlib
|
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
|
# 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
|
# 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.start_pos = tuple(start_pos)
|
||||||
self.end_pos = tuple(end_pos)
|
self.end_pos = tuple(end_pos)
|
||||||
self.accel = toolhead.max_accel
|
self.accel = toolhead.max_accel
|
||||||
|
self.cmove = toolhead.cmove
|
||||||
self.is_kinematic_move = True
|
self.is_kinematic_move = True
|
||||||
self.axes_d = axes_d = [end_pos[i] - start_pos[i] for i in (0, 1, 2, 3)]
|
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]]))
|
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
|
# Generate step times for the move
|
||||||
next_move_time = self.toolhead.get_next_move_time()
|
next_move_time = self.toolhead.get_next_move_time()
|
||||||
if self.is_kinematic_move:
|
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)
|
self.toolhead.kin.move(next_move_time, self)
|
||||||
if self.axes_d[3]:
|
if self.axes_d[3]:
|
||||||
self.toolhead.extruder.move(next_move_time, self)
|
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_time = config.getfloat('motor_off_time', 600., above=0.)
|
||||||
self.motor_off_timer = self.reactor.register_timer(
|
self.motor_off_timer = self.reactor.register_timer(
|
||||||
self._motor_off_handler, self.reactor.NOW)
|
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
|
# Create kinematics class
|
||||||
self.extruder = kinematics.extruder.DummyExtruder()
|
self.extruder = kinematics.extruder.DummyExtruder()
|
||||||
self.move_queue.set_extruder(self.extruder)
|
self.move_queue.set_extruder(self.extruder)
|
||||||
|
|
Loading…
Reference in New Issue