winch: Add experimental support for cable winch kinematics

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-07-12 23:28:58 -04:00
committed by KevinOConnor
parent ec9cb3a1b3
commit 5dc74f3152
6 changed files with 209 additions and 2 deletions

View File

@@ -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

View File

@@ -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;
}