mirror of https://github.com/Desuuuu/klipper.git
rotary_delta: Initial support for rotary delta kinematics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
a56484c98b
commit
ac863a95b6
|
@ -0,0 +1,130 @@
|
||||||
|
# This file serves as documentation for config parameters of rotary
|
||||||
|
# delta style printers. One may copy and edit this file to configure a
|
||||||
|
# new delta printer. Only parameters unique to delta printers are
|
||||||
|
# described here - see the "example.cfg" file for description of
|
||||||
|
# common config parameters.
|
||||||
|
|
||||||
|
# ROTARY DELTA KINEMATICS ARE A WORK IN PROGRESS. Homing moves may
|
||||||
|
# timeout and some boundary checks are not implemented.
|
||||||
|
|
||||||
|
# The stepper_a section describes the stepper controlling the rear
|
||||||
|
# right arm (at 30 degrees). This section also controls the homing
|
||||||
|
# parameters (homing_speed, homing_retract_dist) for all arms.
|
||||||
|
[stepper_a]
|
||||||
|
step_pin: ar54
|
||||||
|
dir_pin: ar55
|
||||||
|
enable_pin: !ar38
|
||||||
|
step_distance: 0.001963495
|
||||||
|
# On a rotary delta printer the step_distance is the amount each
|
||||||
|
# step pulse moves the upper arm in radians (for example, a directly
|
||||||
|
# connected 1.8 degree stepper with 16 micro-steps would be 2 * pi *
|
||||||
|
# (1.8 / 360) / 16 == 0.001963495). This parameter must be provided.
|
||||||
|
endstop_pin: ^ar2
|
||||||
|
homing_speed: 50
|
||||||
|
position_endstop: 252
|
||||||
|
# Distance (in mm) between the nozzle and the bed when the nozzle is
|
||||||
|
# in the center of the build area and the endstop triggers. This
|
||||||
|
# parameter must be provided for stepper_a; for stepper_b and
|
||||||
|
# stepper_c this parameter defaults to the value specified for
|
||||||
|
# stepper_a.
|
||||||
|
upper_arm_length: 170.000
|
||||||
|
# Length (in mm) of the arm connecting the "shoulder joint" to the
|
||||||
|
# "elbow joint". This parameter must be provided for stepper_a; for
|
||||||
|
# stepper_b and stepper_c this parameter defaults to the value
|
||||||
|
# specified for stepper_a.
|
||||||
|
lower_arm_length: 320.000
|
||||||
|
# Length (in mm) of the arm connecting the "elbow joint" to the
|
||||||
|
# "effector joint". This parameter must be provided for stepper_a;
|
||||||
|
# for stepper_b and stepper_c this parameter defaults to the value
|
||||||
|
# specified for stepper_a.
|
||||||
|
#angle:
|
||||||
|
# This option specifies the angle (in degrees) that the arm is at.
|
||||||
|
# The default is 30 for stepper_a, 150 for stepper_b, and 270 for
|
||||||
|
# stepper_c.
|
||||||
|
|
||||||
|
# The stepper_b section describes the stepper controlling the rear
|
||||||
|
# left arm (at 150 degrees).
|
||||||
|
[stepper_b]
|
||||||
|
step_pin: ar60
|
||||||
|
dir_pin: ar61
|
||||||
|
enable_pin: !ar56
|
||||||
|
step_distance: 0.001963495
|
||||||
|
endstop_pin: ^ar15
|
||||||
|
|
||||||
|
# The stepper_c section describes the stepper controlling the front
|
||||||
|
# arm (at 270 degrees).
|
||||||
|
[stepper_c]
|
||||||
|
step_pin: ar46
|
||||||
|
dir_pin: ar48
|
||||||
|
enable_pin: !ar62
|
||||||
|
step_distance: 0.001963495
|
||||||
|
endstop_pin: ^ar19
|
||||||
|
|
||||||
|
[extruder]
|
||||||
|
step_pin: ar26
|
||||||
|
dir_pin: ar28
|
||||||
|
enable_pin: !ar24
|
||||||
|
step_distance: .0022
|
||||||
|
nozzle_diameter: 0.400
|
||||||
|
filament_diameter: 1.750
|
||||||
|
heater_pin: ar10
|
||||||
|
sensor_type: ATC Semitec 104GT-2
|
||||||
|
sensor_pin: analog13
|
||||||
|
control: pid
|
||||||
|
pid_Kp: 22.2
|
||||||
|
pid_Ki: 1.08
|
||||||
|
pid_Kd: 114
|
||||||
|
min_temp: 0
|
||||||
|
max_temp: 250
|
||||||
|
|
||||||
|
[heater_bed]
|
||||||
|
heater_pin: ar8
|
||||||
|
sensor_type: EPCOS 100K B57560G104F
|
||||||
|
sensor_pin: analog14
|
||||||
|
control: watermark
|
||||||
|
min_temp: 0
|
||||||
|
max_temp: 130
|
||||||
|
|
||||||
|
# Print cooling fan (omit section if fan not present).
|
||||||
|
#[fan]
|
||||||
|
#pin: ar9
|
||||||
|
|
||||||
|
[mcu]
|
||||||
|
serial: /dev/ttyACM0
|
||||||
|
pin_map: arduino
|
||||||
|
|
||||||
|
[printer]
|
||||||
|
kinematics: rotary_delta
|
||||||
|
# This option must be "rotary_delta" for rotary delta printers.
|
||||||
|
max_velocity: 300
|
||||||
|
# Maximum velocity (in mm/s) of the toolhead relative to the
|
||||||
|
# print. This parameter must be specified.
|
||||||
|
max_accel: 3000
|
||||||
|
# Maximum acceleration (in mm/s^2) of the toolhead relative to the
|
||||||
|
# print. This parameter must be specified.
|
||||||
|
max_z_velocity: 50
|
||||||
|
# For delta printers this limits the maximum velocity (in mm/s) of
|
||||||
|
# moves with z axis movement. This setting can be used to reduce the
|
||||||
|
# maximum speed of up/down moves (which require a higher step rate
|
||||||
|
# than other moves on a delta printer). The default is to use
|
||||||
|
# max_velocity for max_z_velocity.
|
||||||
|
#minimum_z_position: 0
|
||||||
|
# The minimum Z position that the user may command the head to move
|
||||||
|
# to. The default is 0.
|
||||||
|
shoulder_radius: 33.900
|
||||||
|
# Radius (in mm) of the horizontal circle formed by the three
|
||||||
|
# shoulder joints, minus the radius of the circle formed by the
|
||||||
|
# effector joints. This parameter may also be calculated as:
|
||||||
|
# shoulder_radius = (delta_f - delta_e) / sqrt(12)
|
||||||
|
# This parameter must be provided.
|
||||||
|
shoulder_height: 412.900
|
||||||
|
# Distance (in mm) of the shoulder joints from the bed, minus the
|
||||||
|
# effector toolhead height. This parameter must be provided.
|
||||||
|
|
||||||
|
# The delta_calibrate section enables a DELTA_CALIBRATE extended
|
||||||
|
# g-code command that can calibrate the shoulder endstop positions.
|
||||||
|
[delta_calibrate]
|
||||||
|
radius: 50
|
||||||
|
#speed: 50
|
||||||
|
#horizontal_move_z: 5
|
||||||
|
# See example-delta.cfg for a description of these parameters.
|
|
@ -17,7 +17,7 @@ COMPILE_CMD = ("gcc -Wall -g -O2 -shared -fPIC"
|
||||||
SOURCE_FILES = [
|
SOURCE_FILES = [
|
||||||
'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c', 'trapq.c',
|
'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c', 'trapq.c',
|
||||||
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_polar.c',
|
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_polar.c',
|
||||||
'kin_winch.c', 'kin_extruder.c',
|
'kin_rotary_delta.c', 'kin_winch.c', 'kin_extruder.c',
|
||||||
]
|
]
|
||||||
DEST_LIB = "c_helper.so"
|
DEST_LIB = "c_helper.so"
|
||||||
OTHER_FILES = [
|
OTHER_FILES = [
|
||||||
|
@ -86,6 +86,12 @@ defs_kin_polar = """
|
||||||
struct stepper_kinematics *polar_stepper_alloc(char type);
|
struct stepper_kinematics *polar_stepper_alloc(char type);
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
defs_kin_rotary_delta = """
|
||||||
|
struct stepper_kinematics *rotary_delta_stepper_alloc(
|
||||||
|
double shoulder_radius, double shoulder_height
|
||||||
|
, double angle, double upper_arm, double lower_arm);
|
||||||
|
"""
|
||||||
|
|
||||||
defs_kin_winch = """
|
defs_kin_winch = """
|
||||||
struct stepper_kinematics *winch_stepper_alloc(double anchor_x
|
struct stepper_kinematics *winch_stepper_alloc(double anchor_x
|
||||||
, double anchor_y, double anchor_z);
|
, double anchor_y, double anchor_z);
|
||||||
|
@ -138,7 +144,7 @@ defs_all = [
|
||||||
defs_pyhelper, defs_serialqueue, defs_std,
|
defs_pyhelper, defs_serialqueue, defs_std,
|
||||||
defs_stepcompress, defs_itersolve, defs_trapq,
|
defs_stepcompress, defs_itersolve, defs_trapq,
|
||||||
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_polar,
|
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_polar,
|
||||||
defs_kin_winch, defs_kin_extruder
|
defs_kin_rotary_delta, defs_kin_winch, defs_kin_extruder
|
||||||
]
|
]
|
||||||
|
|
||||||
# Return the list of file modification times
|
# Return the list of file modification times
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
// Rotary delta kinematics stepper pulse time generation
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019 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
|
||||||
|
#include "trapq.h" // move_get_coord
|
||||||
|
|
||||||
|
// The arm angle calculation is based on the following two formulas:
|
||||||
|
// elbow_x**2 + elbow_y**2 = upper_arm**2
|
||||||
|
// (effector_x - elbow_x)**2 + (effector_y - elbow_y)**2 = lower_arm**2
|
||||||
|
|
||||||
|
// Calculate upper arm angle given xy position of effector joint
|
||||||
|
// (relative to shoulder joint), upper arm length, and lower arm length.
|
||||||
|
static inline double
|
||||||
|
rotary_two_arm_calc(double dx, double dy, double upper_arm2, double lower_arm2)
|
||||||
|
{
|
||||||
|
// Determine constants such that: elbow_y = c1 - c2*elbow_x
|
||||||
|
double inv_dy = 1. / dy;
|
||||||
|
double c1 = .5 * inv_dy * (dx*dx + dy*dy + upper_arm2 - lower_arm2);
|
||||||
|
double c2 = dx * inv_dy;
|
||||||
|
// Calculate scaled elbow coordinates via quadratic equation.
|
||||||
|
double scale = c2*c2 + 1.0;
|
||||||
|
double scaled_elbow_x = c1*c2 + sqrt(scale*upper_arm2 - c1*c1);
|
||||||
|
double scaled_elbow_y = c1*scale - c2*scaled_elbow_x;
|
||||||
|
// Calculate angle in radians
|
||||||
|
return atan2(scaled_elbow_y, scaled_elbow_x);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct rotary_stepper {
|
||||||
|
struct stepper_kinematics sk;
|
||||||
|
double cos, sin, shoulder_radius, shoulder_height;
|
||||||
|
double upper_arm2, lower_arm2;
|
||||||
|
};
|
||||||
|
|
||||||
|
static double
|
||||||
|
rotary_stepper_calc_position(struct stepper_kinematics *sk, struct move *m
|
||||||
|
, double move_time)
|
||||||
|
{
|
||||||
|
struct rotary_stepper *rs = container_of(sk, struct rotary_stepper, sk);
|
||||||
|
struct coord c = move_get_coord(m, move_time);
|
||||||
|
// Rotate and shift axes to an origin at shoulder joint with upper
|
||||||
|
// arm constrained to xy plane and x aligned to shoulder platform.
|
||||||
|
double sjz = c.y * rs->cos - c.x * rs->sin;
|
||||||
|
double sjx = c.x * rs->cos + c.y * rs->sin - rs->shoulder_radius;
|
||||||
|
double sjy = c.z - rs->shoulder_height;
|
||||||
|
// Calculate angle in radians
|
||||||
|
return rotary_two_arm_calc(sjx, sjy, rs->upper_arm2
|
||||||
|
, rs->lower_arm2 - sjz*sjz);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct stepper_kinematics * __visible
|
||||||
|
rotary_delta_stepper_alloc(double shoulder_radius, double shoulder_height
|
||||||
|
, double angle, double upper_arm, double lower_arm)
|
||||||
|
{
|
||||||
|
struct rotary_stepper *rs = malloc(sizeof(*rs));
|
||||||
|
memset(rs, 0, sizeof(*rs));
|
||||||
|
rs->cos = cos(angle);
|
||||||
|
rs->sin = sin(angle);
|
||||||
|
rs->shoulder_radius = shoulder_radius;
|
||||||
|
rs->shoulder_height = shoulder_height;
|
||||||
|
rs->upper_arm2 = upper_arm * upper_arm;
|
||||||
|
rs->lower_arm2 = lower_arm * lower_arm;
|
||||||
|
rs->sk.calc_position_cb = rotary_stepper_calc_position;
|
||||||
|
rs->sk.active_flags = AF_X | AF_Y | AF_Z;
|
||||||
|
return &rs->sk;
|
||||||
|
}
|
|
@ -0,0 +1,224 @@
|
||||||
|
# Code for handling the kinematics of rotary delta robots
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
|
||||||
|
#
|
||||||
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
import math, logging
|
||||||
|
import stepper, homing, mathutil, chelper
|
||||||
|
|
||||||
|
class RotaryDeltaKinematics:
|
||||||
|
def __init__(self, toolhead, config):
|
||||||
|
# Setup tower rails
|
||||||
|
stepper_configs = [config.getsection('stepper_' + a) for a in 'abc']
|
||||||
|
rail_a = stepper.PrinterRail(
|
||||||
|
stepper_configs[0], need_position_minmax=False,
|
||||||
|
units_in_radians=True)
|
||||||
|
a_endstop = rail_a.get_homing_info().position_endstop
|
||||||
|
rail_b = stepper.PrinterRail(
|
||||||
|
stepper_configs[1], need_position_minmax=False,
|
||||||
|
default_position_endstop=a_endstop, units_in_radians=True)
|
||||||
|
rail_c = stepper.PrinterRail(
|
||||||
|
stepper_configs[2], need_position_minmax=False,
|
||||||
|
default_position_endstop=a_endstop, units_in_radians=True)
|
||||||
|
self.rails = [rail_a, rail_b, rail_c]
|
||||||
|
config.get_printer().register_event_handler("stepper_enable:motor_off",
|
||||||
|
self._motor_off)
|
||||||
|
# Setup stepper max halt velocity
|
||||||
|
max_velocity, max_accel = toolhead.get_max_velocity()
|
||||||
|
self.max_z_velocity = config.getfloat('max_z_velocity', max_velocity,
|
||||||
|
above=0., maxval=max_velocity)
|
||||||
|
for rail in self.rails:
|
||||||
|
rail.set_max_jerk(9999999.9, 9999999.9)
|
||||||
|
# Read config
|
||||||
|
shoulder_radius = config.getfloat('shoulder_radius', above=0.)
|
||||||
|
shoulder_height = config.getfloat('shoulder_height', above=0.)
|
||||||
|
a_upper_arm = stepper_configs[0].getfloat('upper_arm_length', above=0.)
|
||||||
|
upper_arms = [
|
||||||
|
sconfig.getfloat('upper_arm_length', a_upper_arm, above=0.)
|
||||||
|
for sconfig in stepper_configs]
|
||||||
|
a_lower_arm = stepper_configs[0].getfloat('lower_arm_length', above=0.)
|
||||||
|
lower_arms = [
|
||||||
|
sconfig.getfloat('lower_arm_length', a_lower_arm, above=0.)
|
||||||
|
for sconfig in stepper_configs]
|
||||||
|
angles = [sconfig.getfloat('angle', angle)
|
||||||
|
for sconfig, angle in zip(stepper_configs, [30., 150., 270.])]
|
||||||
|
# Setup rotary delta calibration helper
|
||||||
|
endstops = [rail.get_homing_info().position_endstop
|
||||||
|
for rail in self.rails]
|
||||||
|
stepdists = [rail.get_steppers()[0].get_step_dist()
|
||||||
|
for rail in self.rails]
|
||||||
|
self.calibration = RotaryDeltaCalibration(
|
||||||
|
shoulder_radius, shoulder_height, angles, upper_arms, lower_arms,
|
||||||
|
endstops, stepdists)
|
||||||
|
# Setup iterative solver
|
||||||
|
for r, a, ua, la in zip(self.rails, angles, upper_arms, lower_arms):
|
||||||
|
r.setup_itersolve('rotary_delta_stepper_alloc',
|
||||||
|
shoulder_radius, shoulder_height,
|
||||||
|
math.radians(a), ua, la)
|
||||||
|
for s in self.get_steppers():
|
||||||
|
s.set_trapq(toolhead.get_trapq())
|
||||||
|
toolhead.register_step_generator(s.generate_steps)
|
||||||
|
# Setup boundary checks
|
||||||
|
self.need_home = True
|
||||||
|
self.limit_xy2 = -1.
|
||||||
|
eangles = [r.calc_position_from_coord([0., 0., ep])
|
||||||
|
for r, ep in zip(self.rails, endstops)]
|
||||||
|
self.home_position = tuple(
|
||||||
|
self.calibration.actuator_to_cartesian(eangles))
|
||||||
|
self.max_z = min(endstops)
|
||||||
|
self.min_z = config.getfloat('minimum_z_position', 0, maxval=self.max_z)
|
||||||
|
min_ua = min([shoulder_radius + ua for ua in upper_arms])
|
||||||
|
min_la = min([la - shoulder_radius for la in lower_arms])
|
||||||
|
self.max_xy2 = min(min_ua, min_la)**2
|
||||||
|
arm_z = [self.calibration.elbow_coord(i, ea)[2]
|
||||||
|
for i, ea in enumerate(eangles)]
|
||||||
|
self.limit_z = min([az - la for az, la in zip(arm_z, lower_arms)])
|
||||||
|
logging.info(
|
||||||
|
"Delta max build height %.2fmm (radius tapered above %.2fmm)"
|
||||||
|
% (self.max_z, self.limit_z))
|
||||||
|
self.set_position([0., 0., 0.], ())
|
||||||
|
def get_steppers(self, flags=""):
|
||||||
|
return [s for rail in self.rails for s in rail.get_steppers()]
|
||||||
|
def calc_tag_position(self):
|
||||||
|
spos = [rail.get_tag_position() for rail in self.rails]
|
||||||
|
return self.calibration.actuator_to_cartesian(spos)
|
||||||
|
def set_position(self, newpos, homing_axes):
|
||||||
|
for rail in self.rails:
|
||||||
|
rail.set_position(newpos)
|
||||||
|
self.limit_xy2 = -1.
|
||||||
|
if tuple(homing_axes) == (0, 1, 2):
|
||||||
|
self.need_home = False
|
||||||
|
def home(self, homing_state):
|
||||||
|
# All axes are homed simultaneously
|
||||||
|
homing_state.set_axes([0, 1, 2])
|
||||||
|
forcepos = list(self.home_position)
|
||||||
|
#min_angles = [-.5 * math.pi] * 3
|
||||||
|
#forcepos[2] = self.calibration.actuator_to_cartesian(min_angles)[2]
|
||||||
|
forcepos[2] = -1.
|
||||||
|
homing_state.home_rails(self.rails, forcepos, self.home_position)
|
||||||
|
def _motor_off(self, print_time):
|
||||||
|
self.limit_xy2 = -1.
|
||||||
|
self.need_home = True
|
||||||
|
def check_move(self, move):
|
||||||
|
end_pos = move.end_pos
|
||||||
|
end_xy2 = end_pos[0]**2 + end_pos[1]**2
|
||||||
|
if end_xy2 <= self.limit_xy2 and not move.axes_d[2]:
|
||||||
|
# Normal XY move
|
||||||
|
return
|
||||||
|
if self.need_home:
|
||||||
|
raise homing.EndstopMoveError(end_pos, "Must home first")
|
||||||
|
end_z = end_pos[2]
|
||||||
|
limit_xy2 = self.max_xy2
|
||||||
|
if end_z > self.limit_z:
|
||||||
|
limit_xy2 = min(limit_xy2, (self.max_z - end_z)**2)
|
||||||
|
if end_xy2 > limit_xy2 or end_z > self.max_z or end_z < self.min_z:
|
||||||
|
# Move out of range - verify not a homing move
|
||||||
|
if (end_pos[:2] != self.home_position[:2]
|
||||||
|
or end_z < self.min_z or end_z > self.home_position[2]):
|
||||||
|
raise homing.EndstopMoveError(end_pos)
|
||||||
|
limit_xy2 = -1.
|
||||||
|
if move.axes_d[2]:
|
||||||
|
move.limit_speed(self.max_z_velocity, move.accel)
|
||||||
|
limit_xy2 = -1.
|
||||||
|
self.limit_xy2 = limit_xy2
|
||||||
|
def get_status(self):
|
||||||
|
return {'homed_axes': '' if self.need_home else 'XYZ'}
|
||||||
|
def get_calibration(self):
|
||||||
|
return self.calibration
|
||||||
|
|
||||||
|
# Rotary delta parameter calibration for DELTA_CALIBRATE tool
|
||||||
|
class RotaryDeltaCalibration:
|
||||||
|
def __init__(self, shoulder_radius, shoulder_height, angles,
|
||||||
|
upper_arms, lower_arms, endstops, stepdists):
|
||||||
|
self.shoulder_radius = shoulder_radius
|
||||||
|
self.shoulder_height = shoulder_height
|
||||||
|
self.angles = angles
|
||||||
|
self.upper_arms = upper_arms
|
||||||
|
self.lower_arms = lower_arms
|
||||||
|
self.endstops = endstops
|
||||||
|
self.stepdists = stepdists
|
||||||
|
# Calculate the absolute angle of each endstop
|
||||||
|
ffi_main, self.ffi_lib = chelper.get_ffi()
|
||||||
|
self.sks = [ffi_main.gc(self.ffi_lib.rotary_delta_stepper_alloc(
|
||||||
|
shoulder_radius, shoulder_height, math.radians(a), ua, la),
|
||||||
|
self.ffi_lib.free)
|
||||||
|
for a, ua, la in zip(angles, upper_arms, lower_arms)]
|
||||||
|
self.abs_endstops = [
|
||||||
|
self.ffi_lib.itersolve_calc_position_from_coord(sk, 0., 0., es)
|
||||||
|
for sk, es in zip(self.sks, endstops)]
|
||||||
|
def coordinate_descent_params(self, is_extended):
|
||||||
|
# Determine adjustment parameters (for use with coordinate_descent)
|
||||||
|
adj_params = ('shoulder_height', 'endstop_a', 'endstop_b', 'endstop_c')
|
||||||
|
if is_extended:
|
||||||
|
adj_params += ('shoulder_radius', 'angle_a', 'angle_b')
|
||||||
|
params = { 'shoulder_radius': self.shoulder_radius,
|
||||||
|
'shoulder_height': self.shoulder_height }
|
||||||
|
for i, axis in enumerate('abc'):
|
||||||
|
params['angle_'+axis] = self.angles[i]
|
||||||
|
params['upper_arm_'+axis] = self.upper_arms[i]
|
||||||
|
params['lower_arm_'+axis] = self.lower_arms[i]
|
||||||
|
params['endstop_'+axis] = self.endstops[i]
|
||||||
|
params['stepdist_'+axis] = self.stepdists[i]
|
||||||
|
return adj_params, params
|
||||||
|
def new_calibration(self, params):
|
||||||
|
# Create a new calibration object from coordinate_descent params
|
||||||
|
shoulder_radius = params['shoulder_radius']
|
||||||
|
shoulder_height = params['shoulder_height']
|
||||||
|
angles = [params['angle_'+a] for a in 'abc']
|
||||||
|
upper_arms = [params['upper_arm_'+a] for a in 'abc']
|
||||||
|
lower_arms = [params['lower_arm_'+a] for a in 'abc']
|
||||||
|
endstops = [params['endstop_'+a] for a in 'abc']
|
||||||
|
stepdists = [params['stepdist_'+a] for a in 'abc']
|
||||||
|
return RotaryDeltaCalibration(
|
||||||
|
shoulder_radius, shoulder_height, angles, upper_arms, lower_arms,
|
||||||
|
endstops, stepdists)
|
||||||
|
def elbow_coord(self, elbow_id, spos):
|
||||||
|
# Calculate elbow position in coordinate system at shoulder joint
|
||||||
|
sj_elbow_x = self.upper_arms[elbow_id] * math.cos(spos)
|
||||||
|
sj_elbow_y = self.upper_arms[elbow_id] * math.sin(spos)
|
||||||
|
# Shift and rotate to main cartesian coordinate system
|
||||||
|
angle = math.radians(self.angles[elbow_id])
|
||||||
|
x = (sj_elbow_x + self.shoulder_radius) * math.cos(angle)
|
||||||
|
y = (sj_elbow_x + self.shoulder_radius) * math.sin(angle)
|
||||||
|
z = sj_elbow_y + self.shoulder_height
|
||||||
|
return (x, y, z)
|
||||||
|
def actuator_to_cartesian(self, spos):
|
||||||
|
sphere_coords = [self.elbow_coord(i, sp) for i, sp in enumerate(spos)]
|
||||||
|
lower_arm2 = [la**2 for la in self.lower_arms]
|
||||||
|
return mathutil.trilateration(sphere_coords, lower_arm2)
|
||||||
|
def get_position_from_stable(self, stable_position):
|
||||||
|
# Return cartesian coordinates for the given stable_position
|
||||||
|
spos = [ea - sp * sd
|
||||||
|
for ea, sp, sd in zip(self.abs_endstops, stable_position,
|
||||||
|
self.stepdists)]
|
||||||
|
return self.actuator_to_cartesian(spos)
|
||||||
|
def calc_stable_position(self, coord):
|
||||||
|
# Return a stable_position from a cartesian coordinate
|
||||||
|
pos = [ self.ffi_lib.itersolve_calc_position_from_coord(
|
||||||
|
sk, coord[0], coord[1], coord[2])
|
||||||
|
for sk in self.sks ]
|
||||||
|
return [(ep - sp) / sd
|
||||||
|
for sd, ep, sp in zip(self.stepdists, self.abs_endstops, pos)]
|
||||||
|
def save_state(self, configfile):
|
||||||
|
# Save the current parameters (for use with SAVE_CONFIG)
|
||||||
|
configfile.set('printer', 'shoulder_radius', "%.6f"
|
||||||
|
% (self.shoulder_radius,))
|
||||||
|
configfile.set('printer', 'shoulder_height', "%.6f"
|
||||||
|
% (self.shoulder_height,))
|
||||||
|
for i, axis in enumerate('abc'):
|
||||||
|
configfile.set('stepper_'+axis, 'angle', "%.6f" % (self.angles[i],))
|
||||||
|
configfile.set('stepper_'+axis, 'position_endstop',
|
||||||
|
"%.6f" % (self.endstops[i],))
|
||||||
|
gcode = configfile.get_printer().lookup_object("gcode")
|
||||||
|
gcode.respond_info(
|
||||||
|
"stepper_a: position_endstop: %.6f angle: %.6f\n"
|
||||||
|
"stepper_b: position_endstop: %.6f angle: %.6f\n"
|
||||||
|
"stepper_c: position_endstop: %.6f angle: %.6f\n"
|
||||||
|
"shoulder_radius: %.6f shoulder_height: %.6f"
|
||||||
|
% (self.endstops[0], self.angles[0],
|
||||||
|
self.endstops[1], self.angles[1],
|
||||||
|
self.endstops[2], self.angles[2],
|
||||||
|
self.shoulder_radius, self.shoulder_height))
|
||||||
|
|
||||||
|
def load_kinematics(toolhead, config):
|
||||||
|
return RotaryDeltaKinematics(toolhead, config)
|
|
@ -6,6 +6,7 @@ DICTIONARY atmega2560.dict
|
||||||
CONFIG ../../config/example.cfg
|
CONFIG ../../config/example.cfg
|
||||||
CONFIG ../../config/example-corexy.cfg
|
CONFIG ../../config/example-corexy.cfg
|
||||||
CONFIG ../../config/example-delta.cfg
|
CONFIG ../../config/example-delta.cfg
|
||||||
|
CONFIG ../../config/example-rotary-delta.cfg
|
||||||
CONFIG ../../config/example-winch.cfg
|
CONFIG ../../config/example-winch.cfg
|
||||||
|
|
||||||
# Printers using the atmega2560
|
# Printers using the atmega2560
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
# Test config for the DELTA_CALIBRATE command (on rotary delta robots)
|
||||||
|
[stepper_a]
|
||||||
|
step_pin: ar54
|
||||||
|
dir_pin: ar55
|
||||||
|
enable_pin: !ar38
|
||||||
|
step_distance: 0.000010
|
||||||
|
endstop_pin: ^ar2
|
||||||
|
homing_speed: 50
|
||||||
|
#position_endstop: 252
|
||||||
|
upper_arm_length: 170.000
|
||||||
|
lower_arm_length: 320.000
|
||||||
|
|
||||||
|
[stepper_b]
|
||||||
|
step_pin: ar60
|
||||||
|
dir_pin: ar61
|
||||||
|
enable_pin: !ar56
|
||||||
|
step_distance: 0.000010
|
||||||
|
endstop_pin: ^ar15
|
||||||
|
|
||||||
|
[stepper_c]
|
||||||
|
step_pin: ar46
|
||||||
|
dir_pin: ar48
|
||||||
|
enable_pin: !ar62
|
||||||
|
step_distance: 0.000010
|
||||||
|
endstop_pin: ^ar19
|
||||||
|
|
||||||
|
[mcu]
|
||||||
|
serial: /dev/ttyACM0
|
||||||
|
pin_map: arduino
|
||||||
|
|
||||||
|
[printer]
|
||||||
|
kinematics: rotary_delta
|
||||||
|
max_velocity: 300
|
||||||
|
max_accel: 3000
|
||||||
|
max_z_velocity: 50
|
||||||
|
#shoulder_radius: 33.900
|
||||||
|
#shoulder_height: 412.900
|
||||||
|
|
||||||
|
[delta_calibrate]
|
||||||
|
radius: 50
|
||||||
|
|
||||||
|
#*# <---------------------- SAVE_CONFIG ---------------------->
|
||||||
|
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
|
||||||
|
#*#
|
||||||
|
#*# [printer]
|
||||||
|
#*# shoulder_radius = 33.900000
|
||||||
|
#*# shoulder_height = 412.900000
|
||||||
|
#*#
|
||||||
|
#*# [stepper_a]
|
||||||
|
#*# angle = 30.000000
|
||||||
|
#*# lower_arm = 320.000011
|
||||||
|
#*# position_endstop = 251.999999
|
||||||
|
#*#
|
||||||
|
#*# [stepper_b]
|
||||||
|
#*# angle = 150.000000
|
||||||
|
#*# lower_arm = 320.000000
|
||||||
|
#*# position_endstop = 251.999973
|
||||||
|
#*#
|
||||||
|
#*# [stepper_c]
|
||||||
|
#*# angle = 270.000000
|
||||||
|
#*# lower_arm = 319.999985
|
||||||
|
#*# position_endstop = 251.999902
|
||||||
|
#*#
|
||||||
|
#*# [delta_calibrate]
|
||||||
|
#*# height0 = 0.0
|
||||||
|
#*# height0_pos = 162606.000,162606.000,162605.000
|
||||||
|
#*# height1 = 0.0
|
||||||
|
#*# height1_pos = 157814.000,157814.000,177775.000
|
||||||
|
#*# height2 = 0.0
|
||||||
|
#*# height2_pos = 170956.000,151002.000,170956.000
|
||||||
|
#*# height3 = 0.0
|
||||||
|
#*# height3_pos = 176042.000,158122.000,158122.000
|
||||||
|
#*# height4 = 0.0
|
||||||
|
#*# height4_pos = 168774.000,168774.000,153337.000
|
||||||
|
#*# height5 = 0.0
|
||||||
|
#*# height5_pos = 158477.000,174341.000,158477.000
|
||||||
|
#*# height6 = 0.0
|
||||||
|
#*# height6_pos = 152152.000,169841.000,169841.000
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Test case for basic movement on delta printers
|
||||||
|
CONFIG rotary_delta_calibrate.cfg
|
||||||
|
DICTIONARY atmega2560.dict
|
||||||
|
|
||||||
|
# Start by homing the printer.
|
||||||
|
G28
|
||||||
|
|
||||||
|
# Run basic delta calibration (in manual mode)
|
||||||
|
DELTA_ANALYZE MANUAL_HEIGHT=252
|
||||||
|
DELTA_CALIBRATE METHOD=manual
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
G1 Z0.1
|
||||||
|
ACCEPT
|
||||||
|
|
||||||
|
# Run extended delta calibration
|
||||||
|
DELTA_ANALYZE CENTER_DISTS=74,74,74,74,74,74
|
||||||
|
DELTA_ANALYZE OUTER_DISTS=74,74,74,74,74,74
|
||||||
|
DELTA_ANALYZE CENTER_PILLAR_WIDTHS=9,9,9
|
||||||
|
DELTA_ANALYZE OUTER_PILLAR_WIDTHS=9,9,9,9,9,9
|
||||||
|
DELTA_ANALYZE SCALE=1
|
||||||
|
DELTA_ANALYZE CALIBRATE=extended
|
Loading…
Reference in New Issue