-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
add_y_axis_support and automatic_compensation to axis_twist_compensation #6624
base: master
Are you sure you want to change the base?
Conversation
2c39e55
to
29fc0ac
Compare
Thank you for submitting a PR, pleas refer to point 3 in "What to expect in a review" in https://github.com/Klipper3d/klipper/blob/master/docs/CONTRIBUTING.md and provide a signed off by line. Thanks |
c2fe44d
to
1fd8443
Compare
1fd8443
to
29fc0ac
Compare
axis_twist_compensation: Implement Y-axis support This commit implements support for the Y-axis in the axis_twist_compensation module. This update enables the module to handle corrections for printers with a twisted Y rail. Signed-off-by: Jorge Apaza Merma <[email protected]>
29fc0ac
to
bdf6ea1
Compare
axis_twist_compensation: new command implementation AXIS_TWIST_COMPENSATION_AUTOCALIBRATE This commit adds automatic calculation support for compensating X and Y axis twist in the axis_twist_compensation module. Signed-off-by: Jorge Apaza Merma <[email protected]>
cabc5b4
to
4585e73
Compare
Thank you for your feedback. I have reviewed point 3 in "What to Expect in a Review" and have now included a signed-off-by line in my commits. Thanks! |
Thanks. @koonweee, @blastrock - do you have any comments? On a quick glance through this PR, it seems some of the config options change ( -Kevin |
Signed-off-by: Jorge Apaza Merma <[email protected]>
Hi Kevin, Thanks for the feedback. I've updated docs/Config_Changes.md to document the change from z_compensations to zx_compensations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I have reviewed only the first commit for the moment, I'll try to read the rest asap.
default=[], parser=float) | ||
self.compensation_start_x = config.getfloat('compensation_start_x', | ||
default=None) | ||
self.compensation_end_x = config.getfloat('compensation_start_y', | ||
self.compensation_end_x = config.getfloat('compensation_end_x', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that was my bad. The variable seemed unused so it shouldn't have caused issues. Thanks for the fix.
if not all([ | ||
self.y_start_point[0], | ||
self.y_end_point[0], | ||
self.y_start_point[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't there a similar check for the X axis?
raise self.gcmd.error( | ||
"AXIS_TWIST_COMPENSATION_CALIBRATE: " | ||
"Invalid axis.") | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to return after a raise
compensation.calibrate_y) | ||
self.y_start_point = (compensation.calibrate_start_y, | ||
compensation.calibrate_x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why swap x and y for the y axis? I find it a bit confusing to have a point(y, x)
@@ -26,13 +26,24 @@ def __init__(self, config): | |||
self.calibrate_start_x = config.getfloat('calibrate_start_x') | |||
self.calibrate_end_x = config.getfloat('calibrate_end_x') | |||
self.calibrate_y = config.getfloat('calibrate_y') | |||
self.z_compensations = config.getlists('z_compensations', | |||
self.zx_compensations = config.getlists('zx_compensations', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be a matter of taste, but I'd factorize these 4 variables in a single type (a named tuple or a dataclass, I'm not sure what's preferred) since they represent the same thing between x and y, maybe AxisCalibration
. Then you can pass it as a single argument to _get_interpolated_z_compensation
instead of three.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks good to me, just a few minor issues.
I think the auto calibration feature deserves to be better documented. Especially how it works, and what are the downsides. It's still hard for me to understand why this would work, and to what extend the bed should be "completely flat" as the doc says. My bed has irregularities in the range of 0.2mm, the manual X axis twist calibration that I did resulted in values in the range of 0.1mm, how well would the auto calibration behave?
twist calibration wizard. `SAMPLE_COUNT` specifies the number of points along | ||
the X axis to calibrate at and defaults to 3. | ||
`axis` can either be X or Y | ||
|
||
`AXIS_TWIST_COMPENSATION_AUTOCALIBRATE` performs automatic calibration to calculate the twist of the X and Y axes without manual measurement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it take the same arguments as AXIS_TWIST_COMPENSATION_CALIBRATE? I would put this command in its own section.
) | ||
|
||
# check for valid sample_count | ||
if sample_count is None or sample_count < 2: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't test for None since it can't be None, it has a default value.
max_y = self.y_end_point[0] | ||
|
||
# calculate x positions | ||
spcx = (max_x - min_x) / (sample_count - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to interval_x, to be consistent with the manual implementation? Or maybe rename the variable in the other implementation to spc.
flip = not flip | ||
|
||
# verify no other manual probe is in progress | ||
manual_probe.verify_no_manual_probe(self.printer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this check earlier. More specifically, before the clear_compensations call.
|
||
# probe the point | ||
pos = probe.run_single_probe(self.probe, self.gcmd) | ||
#self.current_measured_z = pos[2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove?
y_coords = [coord[1] for coord in coordinates] | ||
z_coords = [coord[2] for coord in coordinates] | ||
|
||
# Calculate the desired point (average of all corner points in z) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why you take only the corners. My intuition tells me that the average of all points would better cancel out bed irregularities. Is there a particular reason this works better?
@@ -8,6 +8,10 @@ All dates in this document are approximate. | |||
|
|||
## Changes | |||
|
|||
20240709: The `z_compensations` parameter in the `[axis_twist_compensation]` | |||
config section has been renamed to `zx_compensations`. If you don't want | |||
to recalibrate your x_axis_twist_compensation, simply rename the parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would either maintain compatibility and print a warning about the setting being deprecated, or put a fatal error if that setting is present in the config file. At some point, I will upgrade my klipper and I will lose my calibration silently, this is not very user-friendly.
Thank you for your contribution to Klipper. Unfortunately, a reviewer has not assigned themselves to this GitHub Pull Request. All Pull Requests are reviewed before merging, and a reviewer will need to volunteer. Further information is available at: https://www.klipper3d.org/CONTRIBUTING.html There are some steps that you can take now:
Unfortunately, if a reviewer does not assign themselves to this GitHub Pull Request then it will be automatically closed. If this happens, then it is a good idea to move further discussion to the Klipper Discourse server. Reviewers can reach out on that forum to let you know if they are interested and when they are available. Best regards, PS: I'm just an automated script, not a human being. |
add support for Y-axis in axis_twist_compensation.