aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-07-12 23:28:58 -0400
committerKevinOConnor <kevin@koconnor.net>2018-12-24 11:38:59 -0500
commit5dc74f315231121ed56695fb4f68499d9bc5b5fa (patch)
tree357bb1c9a6c9b6eeeed7ace31a34f3438eb4438e /klippy/chelper
parentec9cb3a1b302bddf10bde84fc87ae2a8ad6230b3 (diff)
downloadkutter-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/chelper')
-rw-r--r--klippy/chelper/__init__.py9
-rw-r--r--klippy/chelper/kin_winch.c40
2 files changed, 47 insertions, 2 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 6427ba0f..fba5eb48 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -17,7 +17,7 @@ COMPILE_CMD = ("gcc -Wall -g -O2 -shared -fPIC"
SOURCE_FILES = [
'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c',
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_polar.c',
- 'kin_extruder.c',
+ 'kin_winch.c', 'kin_extruder.c',
]
DEST_LIB = "c_helper.so"
OTHER_FILES = [
@@ -75,6 +75,11 @@ defs_kin_polar = """
struct stepper_kinematics *polar_stepper_alloc(char type);
"""
+defs_kin_winch = """
+ struct stepper_kinematics *winch_stepper_alloc(double anchor_x
+ , double anchor_y, double anchor_z);
+"""
+
defs_kin_extruder = """
struct stepper_kinematics *extruder_stepper_alloc(void);
void extruder_move_fill(struct move *m, double print_time
@@ -122,7 +127,7 @@ defs_std = """
defs_all = [
defs_pyhelper, defs_serialqueue, defs_std, defs_stepcompress, defs_itersolve,
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_polar,
- defs_kin_extruder
+ defs_kin_winch, defs_kin_extruder
]
# Return the list of file modification times
diff --git a/klippy/chelper/kin_winch.c b/klippy/chelper/kin_winch.c
new file mode 100644
index 00000000..df894352
--- /dev/null
+++ b/klippy/chelper/kin_winch.c
@@ -0,0 +1,40 @@
+// Cable winch stepper kinematics
+//
+// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include <math.h> // sqrt
+#include <stddef.h> // offsetof
+#include <stdlib.h> // malloc
+#include <string.h> // memset
+#include "compiler.h" // __visible
+#include "itersolve.h" // struct stepper_kinematics
+
+struct winch_stepper {
+ struct stepper_kinematics sk;
+ struct coord anchor;
+};
+
+static double
+winch_stepper_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ struct winch_stepper *hs = container_of(sk, struct winch_stepper, sk);
+ struct coord c = move_get_coord(m, move_time);
+ double dx = hs->anchor.x - c.x, dy = hs->anchor.y - c.y;
+ double dz = hs->anchor.z - c.z;
+ return sqrt(dx*dx + dy*dy + dz*dz);
+}
+
+struct stepper_kinematics * __visible
+winch_stepper_alloc(double anchor_x, double anchor_y, double anchor_z)
+{
+ struct winch_stepper *hs = malloc(sizeof(*hs));
+ memset(hs, 0, sizeof(*hs));
+ hs->anchor.x = anchor_x;
+ hs->anchor.y = anchor_y;
+ hs->anchor.z = anchor_z;
+ hs->sk.calc_position = winch_stepper_calc_position;
+ return &hs->sk;
+}