Frix-x / klippain

Generic Klipper configuration for 3D printers
GNU General Public License v3.0
843 stars 222 forks source link

Diagonal movements for docking cause issues on certain setups #343

Open wight554 opened 9 months ago

wight554 commented 9 months ago

Klippain branch

Version

v4.1.1-1-gb49bcbfb

Describe the bug and expected behavior

Not really a bug, just a suggestion. On some setups with low tolerance (e.g. rook 2020) you might not be able freely move across Y on dock location. In my case X carriage hits Z idler because dock move macro tries to make diagonal movement which is not possible by design. How it looks in CAD:

Без імені

It's pretty easy to fix by moving X and Y consistently depending on location. Other fix would be creating some excluded area like in slicer but that feels too hard, so I started with simple fix. I've played with macro and created override. Might be useful for other people:

[gcode_macro _PROBE_MOVE_TO]
description: positioning toolhead for dock/attach operation
gcode: 
    {% set location = params.LOCATION|default('')|string %}
    {% set distance = params.DISTANCE|default(0)|float %}
    {% set speed = params.SPEED|default(0)|float %}

    {% set probe_dock_location_x, probe_dock_location_y = printer["gcode_macro _USER_VARIABLES"].probe_dock_location_xy|map('float') %}

    # define dict for location direction
    {% set location_factor = {
        'left'  : { 'x': -1, 'y':  0 },
        'right' : { 'x':  1, 'y':  0 },
        'front' : { 'x':  0, 'y': -1 },
        'back'  : { 'x':  0, 'y':  1 },
        'dock'  : { 'x':  0, 'y':  0 }
    } %}

    {% set vertical_positions = ["front", "back"] %}
    {% set horizontal_positions = ["left", "right"] %}

    {% if location in location_factor %}
        {% if location in horizontal_positions %}
            G1 X{probe_dock_location_x + location_factor[location].x * distance} F{speed}
            G1 Y{probe_dock_location_y + location_factor[location].y * distance} F{speed}
        {% elif location in vertical_positions %}
            G1 Y{probe_dock_location_y + location_factor[location].y * distance} F{speed}
            G1 X{probe_dock_location_x + location_factor[location].x * distance} F{speed}
        {% else %}
            G1 X{probe_dock_location_x + location_factor[location].x * distance} Y{probe_dock_location_y + location_factor[location].y * distance} F{speed}
        {% endif %}
    {% else %}
        { action_raise_error("Error in probe attach/dock movement. Check the directions in your variables.cfg file!") }
    {% endif %}

I'm using zeroclick as probe. My config:

## Position of the probe dock
variable_probe_dock_location_xy: 0, 124

## Positions of the toolhead when docking/undocking the probe
## See diagram below for help
variable_probe_before_attach_position: "right"
variable_probe_after_attach_position : "right"
variable_probe_before_dock_position : "right" # generaly same as probe_after_attach_position
variable_probe_after_dock_position : "front"

Additional information and klippy.log

No response

Surion79 commented 9 months ago

Looks really nice, but i don't use probes, so I can't verify/challenge it.