-
-
Notifications
You must be signed in to change notification settings - Fork 235
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 additional z height safety checks to homing #299
base: develop
Are you sure you want to change the base?
Conversation
Sorry for all the unverified commits, I'm away from home and using Codespaces which doesn't have my git security key setup. It is actually me making those commits. I think a commit squash is probably in order too since I didn't anticipate making more than one commit. Forgive me, this is first real PR on an actual project. Summary of changes:
|
Hello, Thank you very much for this PR. This is a change on a very important part of the config, so I will definitely try it and check everything before merging it. Be aware that I just moved into a new house and my printers aren't unpacked at the moment, so it could take a couple of days before I find some time to proceed :) Also, I'm not sure you have seen #169 but it was already an attempt to improve the homing sequence we are aware that there is definitely room for improvements. So your PR is welcomed! |
Take your time! I know how fast life can move so don't feel pressured to rush to merge or test. 👍 These edge cases are pretty unlikely to occur during normal use. I only found them because I was doing some testing. I hadn't seen #169, but it looks like things didn't pan out. Hopefully we can get this working properly this time! Let me know if there are any issues with the PR and I'll try my best to fix it. I really like this project, so I want to see this through. Keep up the great work and thanks for this repo! Also, if you're curious, I'm using Klippain on my V2.4 and that's what I do all my testing on as well. |
On my first look, it looks like that something could be combined. |
I suggest using something like this: (identation might not be 100% correct) |
@Surion79 Ya, it probably isn't the most clean implementation. Let me revisit it and see if I can make it more elegant. I should get back to you sometime tomorrow. |
This reverts commit a36cd7f because I made a mistake in removing the SG buffer clear.
well, my last post is basically the PR content (excluding the deletion of the Kinematic zhop under Z). Not sure what else to add for the functionality. But I am curious what else you have in mind :) |
if Z is homed and at -5 (which is position_min in Klippain), it would scratch at a very tiny edge case. |
I opened a new PR with my change and i tested it on my machine and this is not working. Because only homing X/Y will home Z in a fictious state of "current+5". And if z is never homed again, it will never have the real z height. and it is marked as homed for all running macros. even if you just home X and Y and then start a print, Conditional G28 will not trigger, messing up the whole print. The only clean solution would be to home with zhop and then do a |
that was the issue why it didn't get through the first time with my old PR. There is no clean solution unless you unhome only Z explicietly after a fictuous z home. |
I like this approach and I'll probably update this PR to incorporate the change, but I think you introduced a bug in your change.
I think this line here is responsible for the Z height issue you're having. You're literally telling the printer it's at position 0, 0, 0 wherever it happens to actually be when homing any axis. Then when you home XY only, Z thinks it's a zero and does a Z hop and thus it thinks it's at "current position + 5" on Z. You wouldn't see it before the change because that was previously in the Z homing section and directly after it's called the printer homes every axis. I think it's in there to prevent any weird "move out of range" errors when homing all axes. Just put that line back where it came from and it should be fixed. |
We could just make the Z hop taller by a millimeter. Honestly though, we can't save the user from everything. I think that scenario is very unlikely compared to the scraping scenario I described. I'f you're at -5 on Z, you probably already crashed the nozzle and should be moving the toolhead by hand. |
@austinrdennis seriously... look who did it here in the beginning. |
Good catch. 🙏 I still think the use of that is wrong here, but the fault is mine. Did the removal of that line end up fixing the weird z homing behavior? Forgive me, I had your PR commit and an older commit form this PR open at the same time and must have gotten confused. These commits were originally from a time where I had much less experience with Klipper. |
no worries, i was thinking: what is he thinking :D |
well if your goal is to do a zhop check only if z is homed, then the macro would be still at the beginning just
|
but that wouldn't fix "only x/y homing" when the printer shut down on "tap" |
Ok, so we move SET_KINIMATIC_POSTION back to where it came from and that fixes that weird z height behavior and add this to the beginning of homing macro. What do you think of this?
|
that doesnt work. if z is not homed, it doesn't do a zhop. It requires the kinematic setting. |
Damn, ok I get why we need it. I see what you were dealing with in the earlier PR. What about this?
It does the safety hop and then turns off the motors before homing the requested axis. Not a perfect solution, but you get the safety benefit and the downsides would be mostly mitigated. I'd test it but I'm in the middle of a super long print. I should be able to test tomorrow. |
i had the same thought, but then you would intentionally unhome other axis as well, which is not desired. you have homed X and then you home Y and then you have unhomed X and Z |
i even looked in klipper source code in G28. They do a manual toolhead move which we can't use, since they did not implement axis movements, just stepper movements on as gcode command |
Unfortunately, I think this the best option we got. At least we can add more safety to the homing process here. I think un-homing all the unspecified axes is a small price to pay and if you home x and y in the same command. Just do a full G28/CG28 right before you print and you'd be set which is how the start_print macro is written anyway. I don't think Klipper has a way to do all the things we want here. I wish force_move could be done on an entire bank of steppers, but it is what it is. I'll do some testing with it to look for edge cases today then I'll commit the changes into this PR. |
Ok, just tested it on my machine and it is operating well for me. @Surion79 If you home an axis previously, you'll only invalidate an axis if z-height is unknown. If Z height is known, it will check for z hop via the other branch and the other axis (X or Y) will not be invalidated. It would exhibit that behavior only if you home x or y individually with an unknown z-height. I don't see a problem with this other than it may confuse people. The printer should refuse to move if they try to do something unsafe with invalid axes or simply rehome the needed axes in some cases on it's own. I'll add some yellow warning messages into the console for the edge cases so people know their previously homed axes are now invalid and need to be homed again. That way people are not caught off guard and know why it's doing what it it's doing. I'm ok with this slight inconvenience in the name of added plate safety, but I guess that's ultimately up to @Frix-x. |
As discussed in PR Frix-x#299
Ok, that should do it. Have a look and let me know if you disagree. I couldn't get the text to change color without re-doing all the action_respond_info snippets into respond format and creating an extension macro. I know how to do it, it is just beyond the scope of this PR. Maybe I'll submit another PR to redo all that throughout the project to give us more flexibility with message format down the road. |
Well, that is @Frix-x choice. Last time he didn't agree. Let's see. |
@austinrdennis Seems we get the solution soon in klipper: |
It's indeed something that would fix this problem very easily! |
similar to Marlins |
Fantastic! I'll work on those changes when I can get my hands on that new release 😄 |
Quick update before I forget to update this for the klipper changes that remove max_accel_to_decel and introduce minimum_cruise_ratio.
Fixes issue #298. Request THOROUGH code review. I'm not that experienced with Jinja2 or klipper.