Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sensorless retract dist fix #109

Merged
merged 2 commits into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,15 @@ def home_rails(self, rails, forcepos, movepos):
for i, dist in enumerate(hmove.distance_elapsed)
if i in homing_axes
]

needs_rehome = False
retract_dist = hi.retract_dist
if any(
[abs(dist) < hi.min_home_dist for dist in homing_axis_distances]
):
needs_rehome = True
retract_dist = hi.min_home_dist
# Perform second home
if hi.retract_dist:
needs_rehome = False
retract_dist = hi.retract_dist
if any(
[abs(dist) < hi.min_home_dist for dist in homing_axis_distances]
):
needs_rehome = True
retract_dist = hi.min_home_dist

if retract_dist:
logging.info("needs rehome: %s", needs_rehome)
# Retract
startpos = self._fill_coord(forcepos)
Expand Down Expand Up @@ -321,17 +319,17 @@ def home_rails(self, rails, forcepos, movepos):
"Endstop %s still triggered after retract"
% (hmove.check_no_movement(),)
)

# Retract (again)
startpos = self._fill_coord(forcepos)
homepos = self._fill_coord(movepos)
axes_d = [hp - sp for hp, sp in zip(homepos, startpos)]
move_d = math.sqrt(sum([d * d for d in axes_d[:3]]))
retract_r = min(1.0, hi.retract_dist / move_d)
retractpos = [
hp - ad * retract_r for hp, ad in zip(homepos, axes_d)
]
self.toolhead.move(retractpos, hi.retract_speed)
if hi.retract_dist:
# Retract (again)
startpos = self._fill_coord(forcepos)
homepos = self._fill_coord(movepos)
axes_d = [hp - sp for hp, sp in zip(homepos, startpos)]
move_d = math.sqrt(sum([d * d for d in axes_d[:3]]))
retract_r = min(1.0, hi.retract_dist / move_d)
retractpos = [
hp - ad * retract_r for hp, ad in zip(homepos, axes_d)
]
self.toolhead.move(retractpos, hi.retract_speed)
self._set_current_post_homing(homing_axes)
# Signal home operation complete
self.toolhead.flush_step_generation()
Expand Down