Commit 7fe18002 authored by Nicholas Gar Hei Chan's avatar Nicholas Gar Hei Chan
Browse files

Bug fixes for sampling algorithm

parent dbea48d2
......@@ -61,14 +61,23 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
""" Sample a layer
"""
layer = self.model.layers[current_layer]
layer = self.model.layers[current_layer-1]
if len(layer.sample_points['x']):
result = 0
self._printer.pause_print()
self._logger.info("Starting sampling run...")
result = True
for point in zip(layer.sample_points['x'], layer.sample_points['y']):
if probe_point(point[0], point[1], layer.z_height):
return True
if self.probe_point(point[0], point[1], layer.z_height):
self._logger.info("Good reading at X={}, Y={}".format(point[0], point[1]))
else:
return False
self._logger.info("Bad reading at X={}, Y={}".format(point[0], point[1]))
result = False
break
if result:
self._printer.resume_print()
else:
self._printer.cancel_print()
else:
return True
......@@ -89,7 +98,7 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
# Go to 2mm above the sample position, accounting for tool offset
self._printer.commands('G0 X{} Y{} Z{}'.format(probe_x,
probe_y,
probe_z)
probe_z))
reading = subprocess.run("./sample.sh", capture_output=True).stdout.decode("utf-8").strip() == '1'
......@@ -139,10 +148,10 @@ class AutofdpPlugin(octoprint.plugin.SettingsPlugin,
try:
current_layer = self.model.layer_heights.index(currentZ)
self._logger.info('Current layer: {}'.format(current_layer))
self.sample_layer(current_layer)
except:
self._logger.info('Not a valid layer at z = {}'.format(currentZ))
return
self.sample_layer(current_layer)
#self._logger.info('Layer changed. currentZ = {}'.format(data))
##~~ TemplatePlugin mixin
......
......@@ -9,6 +9,7 @@ if grep -q "Raspberry Pi" /proc/cpuinfo; then
gpio read 0
gpio write 7 0
else
sleep 2
echo 1
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment