delta_calibrate: Don't error on an invalid kinematic guess
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
6bba285f8e
commit
ad0b76bd4b
|
@ -182,21 +182,25 @@ class DeltaCalibrate:
|
||||||
z_weight = len(distances) / (MEASURE_WEIGHT * len(probe_positions))
|
z_weight = len(distances) / (MEASURE_WEIGHT * len(probe_positions))
|
||||||
# Perform coordinate descent
|
# Perform coordinate descent
|
||||||
def delta_errorfunc(params):
|
def delta_errorfunc(params):
|
||||||
# Build new delta_params for params under test
|
try:
|
||||||
delta_params = orig_delta_params.new_calibration(params)
|
# Build new delta_params for params under test
|
||||||
# Calculate z height errors
|
delta_params = orig_delta_params.new_calibration(params)
|
||||||
total_error = 0.
|
getpos = delta_params.get_position_from_stable
|
||||||
for z_offset, stable_pos in height_positions:
|
# Calculate z height errors
|
||||||
x, y, z = delta_params.get_position_from_stable(stable_pos)
|
total_error = 0.
|
||||||
total_error += (z - z_offset)**2
|
for z_offset, stable_pos in height_positions:
|
||||||
total_error *= z_weight
|
x, y, z = getpos(stable_pos)
|
||||||
# Calculate distance errors
|
total_error += (z - z_offset)**2
|
||||||
for dist, stable_pos1, stable_pos2 in distances:
|
total_error *= z_weight
|
||||||
x1, y1, z1 = delta_params.get_position_from_stable(stable_pos1)
|
# Calculate distance errors
|
||||||
x2, y2, z2 = delta_params.get_position_from_stable(stable_pos2)
|
for dist, stable_pos1, stable_pos2 in distances:
|
||||||
d = math.sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
|
x1, y1, z1 = getpos(stable_pos1)
|
||||||
total_error += (d - dist)**2
|
x2, y2, z2 = getpos(stable_pos2)
|
||||||
return total_error
|
d = math.sqrt((x1-x2)**2 + (y1-y2)**2 + (z1-z2)**2)
|
||||||
|
total_error += (d - dist)**2
|
||||||
|
return total_error
|
||||||
|
except ValueError:
|
||||||
|
return 9999999999999.9
|
||||||
new_params = mathutil.background_coordinate_descent(
|
new_params = mathutil.background_coordinate_descent(
|
||||||
self.printer, adj_params, params, delta_errorfunc)
|
self.printer, adj_params, params, delta_errorfunc)
|
||||||
# Log and report results
|
# Log and report results
|
||||||
|
|
Loading…
Reference in New Issue