protoloft / klipper_z_calibration

Klipper plugin for self-calibrating z-offset
GNU General Public License v3.0
1.06k stars 152 forks source link

ZeroDivisionError: float division by zero #155

Closed BlackStump closed 1 month ago

BlackStump commented 2 months ago

Been struggling to get this to work after klipper update everything was working great prior to the update. I am not a programmer or developer just a 65 year old user and this is way beyond my skill set.

Internal error on command:"CALIBRATE_Z"
Internal Error on WebRequest: gcode/script
Traceback (most recent call last):
  File "/home/pi/klipper/klippy/webhooks.py", line 256, in _process_request
    func(web_request)
  File "/home/pi/klipper/klippy/webhooks.py", line 436, in _handle_script
    self.gcode.run_script(web_request.get_str('script'))
  File "/home/pi/klipper/klippy/gcode.py", line 229, in run_script
    self._process_commands(script.split('\n'), need_ack=False)
  File "/home/pi/klipper/klippy/gcode.py", line 211, in _process_commands
    handler(gcmd)
  File "/home/pi/klipper/klippy/gcode.py", line 137, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/extras/z_calibration.py", line 152, in cmd_CALIBRATE_Z
    state.calibrate_z(switch_offset, nozzle_site, switch_site, bed_site)
  File "/home/pi/klipper/klippy/extras/z_calibration.py", line 474, in calibrate_z
    nozzle_zero = self._probe_on_site(self.z_endstop,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/extras/z_calibration.py", line 450, in _probe_on_site
    return self.helper._calc_mean(positions)[2]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/extras/z_calibration.py", line 357, in _calc_mean
    return [sum([pos[i] for pos in positions]) / count
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/klipper/klippy/extras/z_calibration.py", line 357, in <listcomp>
    return [sum([pos[i] for pos in positions]) / count
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
ZeroDivisionError: float division by zero
BlackStump commented 1 month ago

I did the sledge hammer approach and deleted klipper and did a fresh install which seem to work , no idea what was causing the issue but this software works as intended. Sorry for opening a issue when there was none here.