diff --git a/docs/G-Codes.md b/docs/G-Codes.md index 2444c53b19ee..d6c0a5cd9260 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -553,15 +553,16 @@ state; issue a G28 afterwards to reset the kinematics. This command is intended for low-level diagnostics and debugging. #### SET_KINEMATIC_POSITION -`SET_KINEMATIC_POSITION [X=] [Y=] [Z=]`: Force -the low-level kinematic code to believe the toolhead is at the given -cartesian position. This is a diagnostic and debugging command; use -SET_GCODE_OFFSET and/or G92 for regular axis transformations. If an -axis is not specified then it will default to the position that the -head was last commanded to. Setting an incorrect or invalid position -may lead to internal software errors. This command may invalidate -future boundary checks; issue a G28 afterwards to reset the -kinematics. +`SET_KINEMATIC_POSITION [X=] [Y=] [Z=] +[CLEAR=<[X][Y][Z]>]`: Force the low-level kinematic code to believe the +toolhead is at the given cartesian position. This is a diagnostic and +debugging command; use SET_GCODE_OFFSET and/or G92 for regular axis +transformations. If an axis is not specified then it will default to the +position that the head was last commanded to. Setting an incorrect or +invalid position may lead to internal software errors. Use the CLEAR +parameter to forget the homing state for the given axes. This command +may invalidate future boundary checks; issue a G28 afterwards to reset +the kinematics. ### [gcode] diff --git a/klippy/extras/force_move.py b/klippy/extras/force_move.py index 50b801412dbd..fefedc3df5a4 100644 --- a/klippy/extras/force_move.py +++ b/klippy/extras/force_move.py @@ -131,8 +131,16 @@ def cmd_SET_KINEMATIC_POSITION(self, gcmd): x = gcmd.get_float('X', curpos[0]) y = gcmd.get_float('Y', curpos[1]) z = gcmd.get_float('Z', curpos[2]) - logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f", x, y, z) - toolhead.set_position([x, y, z, curpos[3]], homing_axes=(0, 1, 2)) + clear = gcmd.get('CLEAR', '').upper() + axes = ['X', 'Y', 'Z'] + clear_axes = [axes.index(a) for a in axes if a in clear] + logging.info("SET_KINEMATIC_POSITION pos=%.3f,%.3f,%.3f clear=%s", + x, y, z, ','.join((axes[i] for i in clear_axes))) + toolhead.set_position( + [x, y, z, curpos[3]], + homing_axes=(0, 1, 2), + clear_axes=clear_axes + ) def load_config(config): return ForceMove(config) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 4149d53b12f6..48a1b354988e 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -453,13 +453,14 @@ def _flush_handler(self, eventtime): # Movement commands def get_position(self): return list(self.commanded_pos) - def set_position(self, newpos, homing_axes=()): + def set_position(self, newpos, homing_axes=(), clear_axes=()): self.flush_step_generation() ffi_main, ffi_lib = chelper.get_ffi() ffi_lib.trapq_set_position(self.trapq, self.print_time, newpos[0], newpos[1], newpos[2]) self.commanded_pos[:] = newpos self.kin.set_position(newpos, homing_axes) + self.kin.clear_homing_state(clear_axes) self.printer.send_event("toolhead:set_position") def move(self, newpos, speed): move = Move(self, self.commanded_pos, newpos, speed)