delta: Minor change to get_position_from_stable()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2018-07-14 11:35:13 -04:00
parent 244d0aa65b
commit ce0f4fe038
2 changed files with 22 additions and 20 deletions

View File

@@ -4,7 +4,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging
import probe, mathutil, kinematics.delta
import probe, mathutil
class DeltaCalibrate:
def __init__(self, config):
@@ -40,20 +40,18 @@ class DeltaCalibrate:
logging.info("Initial delta_calibrate parameters: %s", params)
adj_params = ('endstop_a', 'endstop_b', 'endstop_c', 'radius',
'angle_a', 'angle_b')
get_position_from_stable = kinematics.delta.get_position_from_stable
def delta_errorfunc(params):
total_error = 0.
for spos in positions:
x, y, z = get_position_from_stable(spos, params)
for x, y, z in kin.get_positions_from_stable(positions, params):
total_error += (z - z_offset)**2
return total_error
new_params = mathutil.coordinate_descent(
adj_params, params, delta_errorfunc)
logging.info("Calculated delta_calibrate parameters: %s", new_params)
for spos in positions:
logging.info("orig: %s new: %s",
get_position_from_stable(spos, params),
get_position_from_stable(spos, new_params))
old_positions = kin.get_positions_from_stable(positions, params)
new_positions = kin.get_positions_from_stable(positions, new_params)
for oldpos, newpos in zip(old_positions, new_positions):
logging.info("orig: %s new: %s", oldpos, newpos)
self.gcode.respond_info(
"stepper_a: position_endstop: %.6f angle: %.6f\n"
"stepper_b: position_endstop: %.6f angle: %.6f\n"