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

Simplify kinematic set_position() and clear_homing_state() calls #6782

Merged
merged 3 commits into from
Jan 22, 2025

Conversation

KevinOConnor
Copy link
Collaborator

Now that clear_homing_state() has been implemented, there is no longer a need for each kinematic class to manually register for the "motor_off" event, as the stepper_enable class can directly call clear_homing_state().

Also this changes the homing_axes and clear_axes parameters of the set_position() and clear_homing_state() to pass strings (eg, "xyz") instead of a list of numbers.

@twelho - fyi.

-Kevin

@nefelim4ag
Copy link
Contributor

nefelim4ag commented Jan 12, 2025

I cherry-picked and tried to test it:

SET_KINEMATIC_POSITION X=200 CLEAR=Y

I got klippy crashed:

Internal error on command:"SET_KINEMATIC_POSITION"
Traceback (most recent call last):
  File "/home/user/klipper/klippy/gcode.py", line 212, in _process_commands
    handler(gcmd)
  File "/home/user/klipper/klippy/gcode.py", line 140, in <lambda>
    func = lambda params: origfunc(self._get_extended_params(params))
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/klipper/klippy/extras/force_move.py", line 137, in cmd_SET_KINEMATIC_POSITION
    x, y, z, ','.join((axes[i] for i in clear_axes)))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/klipper/klippy/extras/force_move.py", line 137, in <genexpr>
    x, y, z, ','.join((axes[i] for i in clear_axes)))
                       ^^^^
NameError: name 'axes' is not defined

axes = ['X', 'Y', 'Z']
clear_axes = [axes.index(a) for a in axes if a in clear]
clear = gcmd.get('CLEAR', '').lower()
clear_axes = "".join([a for a in "xyz" 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)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing axes[i]
Possibly there should be:

i for i in clear_axes

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Thanks for testing and reporting. Hopefully should be fixed now.

-Kevin

Call clear_homing_state() on each motor off event.  This simplifies
the kinematic classes as they no longer need to register and handle
the motor_off event.

Signed-off-by: Kevin O'Connor <[email protected]>
Use strings such as "xyz" to specify which axes are to be considered
homing during a set_position() call.  This makes the parameter a
little less cryptic.

Signed-off-by: Kevin O'Connor <[email protected]>
Pass a string such as "xyz" to kin.clear_homing_state().  This makes
the parameter a little less cryptic.

Signed-off-by: Kevin O'Connor <[email protected]>
@KevinOConnor KevinOConnor force-pushed the work-stepper-20250110 branch from 38de633 to 6ab2533 Compare January 21, 2025 23:58
@KevinOConnor KevinOConnor merged commit 6ab2533 into master Jan 22, 2025
2 checks passed
@KevinOConnor KevinOConnor deleted the work-stepper-20250110 branch January 22, 2025 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants