diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-07-12 23:28:58 -0400 |
---|---|---|
committer | KevinOConnor <kevin@koconnor.net> | 2018-12-24 11:38:59 -0500 |
commit | 5dc74f315231121ed56695fb4f68499d9bc5b5fa (patch) | |
tree | 357bb1c9a6c9b6eeeed7ace31a34f3438eb4438e /klippy/kinematics/winch.py | |
parent | ec9cb3a1b302bddf10bde84fc87ae2a8ad6230b3 (diff) | |
download | kutter-5dc74f315231121ed56695fb4f68499d9bc5b5fa.tar.gz kutter-5dc74f315231121ed56695fb4f68499d9bc5b5fa.tar.xz kutter-5dc74f315231121ed56695fb4f68499d9bc5b5fa.zip |
winch: Add experimental support for cable winch kinematics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/kinematics/winch.py')
-rw-r--r-- | klippy/kinematics/winch.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py new file mode 100644 index 00000000..56b7658c --- /dev/null +++ b/klippy/kinematics/winch.py @@ -0,0 +1,62 @@ +# Code for handling the kinematics of cable winch robots +# +# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net> +# +# This file may be distributed under the terms of the GNU GPLv3 license. +import stepper, mathutil + +class WinchKinematics: + def __init__(self, toolhead, config): + # Setup steppers at each anchor + self.steppers = [] + self.anchors = [] + for i in range(26): + name = 'stepper_' + chr(ord('a') + i) + if i >= 3 and not config.has_section(name): + break + stepper_config = config.getsection(name) + s = stepper.PrinterStepper(stepper_config) + self.steppers.append(s) + a = tuple([stepper_config.getfloat('anchor_' + n) for n in 'xyz']) + self.anchors.append(a) + s.setup_itersolve('winch_stepper_alloc', *a) + # Setup stepper max halt velocity + max_velocity, max_accel = toolhead.get_max_velocity() + max_halt_velocity = toolhead.get_max_axis_halt() + for s in self.steppers: + s.set_max_jerk(max_halt_velocity, max_accel) + # Setup boundary checks + self.need_motor_enable = True + self.set_position([0., 0., 0.], ()) + def get_steppers(self, flags=""): + return list(self.steppers) + def calc_position(self): + # Use only first three steppers to calculate cartesian position + spos = [s.get_commanded_position() for s in self.steppers[:3]] + return mathutil.trilateration(self.anchors[:3], [sp*sp for sp in spos]) + def set_position(self, newpos, homing_axes): + for s in self.steppers: + s.set_position(newpos) + def home(self, homing_state): + # XXX - homing not implemented + homing_state.set_axes([0, 1, 2]) + homing_state.set_homed_position([0., 0., 0.]) + def motor_off(self, print_time): + for s in self.steppers: + s.motor_enable(print_time, 0) + self.need_motor_enable = True + def _check_motor_enable(self, print_time): + for s in self.steppers: + s.motor_enable(print_time, 1) + self.need_motor_enable = False + def check_move(self, move): + # XXX - boundary checks and speed limits not implemented + pass + def move(self, print_time, move): + if self.need_motor_enable: + self._check_motor_enable(print_time) + for s in self.steppers: + s.step_itersolve(move.cmove) + +def load_kinematics(toolhead, config): + return WinchKinematics(toolhead, config) |