polar: Experimental support for polar kinematics

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-08-23 14:21:58 -04:00 committed by KevinOConnor
parent 7e3e02a17a
commit ec9cb3a1b3
5 changed files with 298 additions and 2 deletions

View file

@ -16,7 +16,8 @@ COMPILE_CMD = ("gcc -Wall -g -O2 -shared -fPIC"
" -o %s %s")
SOURCE_FILES = [
'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c',
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_extruder.c'
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_polar.c',
'kin_extruder.c',
]
DEST_LIB = "c_helper.so"
OTHER_FILES = [
@ -70,6 +71,10 @@ defs_kin_delta = """
, double tower_x, double tower_y);
"""
defs_kin_polar = """
struct stepper_kinematics *polar_stepper_alloc(char type);
"""
defs_kin_extruder = """
struct stepper_kinematics *extruder_stepper_alloc(void);
void extruder_move_fill(struct move *m, double print_time
@ -116,7 +121,8 @@ 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_extruder
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_polar,
defs_kin_extruder
]
# Return the list of file modification times

View file

@ -0,0 +1,41 @@
// Polar kinematics stepper pulse time generation
//
// 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 <stdlib.h> // malloc
#include <string.h> // memset
#include "compiler.h" // __visible
#include "itersolve.h" // struct stepper_kinematics
static double
polar_stepper_radius_calc_position(struct stepper_kinematics *sk, struct move *m
, double move_time)
{
struct coord c = move_get_coord(m, move_time);
return sqrt(c.x*c.x + c.y*c.y);
}
static double
polar_stepper_angle_calc_position(struct stepper_kinematics *sk, struct move *m
, double move_time)
{
struct coord c = move_get_coord(m, move_time);
// XXX - handle x==y==0
// XXX - handle angle wrapping
return atan2(c.y, c.x);
}
struct stepper_kinematics * __visible
polar_stepper_alloc(char type)
{
struct stepper_kinematics *sk = malloc(sizeof(*sk));
memset(sk, 0, sizeof(*sk));
if (type == 'r')
sk->calc_position = polar_stepper_radius_calc_position;
else if (type == 'a')
sk->calc_position = polar_stepper_angle_calc_position;
return sk;
}