[2.0.x] Move firmware retraction to the planner#11578
[2.0.x] Move firmware retraction to the planner#11578thinkyhead merged 1 commit intoMarlinFirmware:bugfix-2.0.xfrom
Conversation
9ec2491 to
86c188b
Compare
|
This approach seems fine, though in the bigger picture I wonder how compatible it (and fw-retract in-general) is with the recover from power-loss feature. It currently doesn't save the retract flag, so if power goes out in-between a retract and a recover, the recover won't happen and the Z position might be off by the z-hop amount when the print resumes. Anyway, that feature needs other work too, but it's something to think about going forward. |
db7f42d to
e0d9d61
Compare
Marlin/src/module/planner.cpp
Outdated
There was a problem hiding this comment.
Every operation in the planner needs to be reversible for the benefit of converting stepper positions back into a cartesian position. So if there's an apply_retract there should also be unapply_retract. Since we already have apply_leveling and unapply_leveling the most consistent way to manage it is to move this code into the apply_leveling method (or call it from that method) and rename that method apply_modifiers. Then rename unapply_leveling to unapply_modifiers and add code there which removes the hop value. So far the (un)apply_leveling methods don't do anything with E, but if generalized to (un)apply_modifiers then it would be ok to have E modification there too.
UBL doesn't use apply_leveling or unapply_leveling at this time (except for delta), because it was written in its own sandbox, so the separate handling would still be needed in ubl_motion.cpp.
e0d9d61 to
4507d9c
Compare
Marlin/src/module/planner_bezier.cpp
Outdated
There was a problem hiding this comment.
Example: If apply_retract were added to the suggested planner.apply_modifiers then this wouldn't be needed here.
There was a problem hiding this comment.
UBL doesn't use apply_leveling or unapply_leveling at this time
This seems to be the one exception to that rule as apply_leveling is called a few lines further down if HAS_UBL_AND_CURVES is defined.
I agree that combining apply_leveling and apply_retract is the right thing to do, but I was concerned that it might open a can of worms trying to do so. Perhaps it would be best to keep this PR as is to address the issue at hand (i.e. the print becoming skewed when using firmware retraction) and perform the consolidation in a separate PR.
Marlin/src/module/planner.h
Outdated
Marlin/src/gcode/motion/G2_G3.cpp
Outdated
Marlin/src/gcode/motion/G2_G3.cpp
Outdated
Marlin/src/module/planner.cpp
Outdated
|
Would make me wonder if we wouldn't have a similar problem like this on Prusa. |
As the power-loss feature appears to only save Given the above, I actually think it would be easier to make Firmware Retraction compatible with the power-loss feature with this change as the previous method worked by hiding the fact that the retraction and Z-hop had occurred. While |
9fb4e95 to
ad12b9b
Compare
0cdf51f to
8f4f7c2
Compare
fb53048 to
f2849b8
Compare
Marlin/src/gcode/motion/G2_G3.cpp
Outdated
There was a problem hiding this comment.
Although on its face this commit moving feedrate scaling into the planner would seem to be a great idea, since it simplifies and consolidates this logic, it requires fr_mm_s / millimeters to be re-calculated on every segment, whereas previously this division was only done once, at the start of the line segmentation loop. So this updated code will be a bit slower.
There was a problem hiding this comment.
I hadn't thought about losing the optimization of pre-computing fr_mm_s / millimeters for every segment by moving the feedrate scaling into the planner. If it's a concern, one option could be to pass it as an optional argument to buffer_line in the same way as millimeters. Alternatively, buffer_line could keep track of the previous fr_mm_s, millimeters, and the scaled feedrate, and only re-compute the scaled feedrate if fr_mm_s or millimeters changes.
There was a problem hiding this comment.
I thought about that. Passing an extra float parameter on every segment is definitely going to be less costly than having a division operation. Another option which I've been contemplating would be to get #8311 done, and then presumably the high-level feedrate variables would already contain the duration of the move instead of the speed of the move. But, I'm not sure this would ultimately reduce the amount of calculation needed for kinematic segments.
There was a problem hiding this comment.
I suggest we have the extra parameter only for IS_KINEMATIC, and do the calculation in the Planner only for IS_CARTESIAN.
d4e526f to
cf1e3a9
Compare
|
UBL had its own implementation of feedrate scaling for SCARA in |
695c9db to
14de2d1
Compare
ffc3bdb to
2510fbb
Compare
|
Rebased and squashed. I'm still waiting for feedback from @JxpA that this is 100% copacetic. But, Thomas, you've got a delta, right? Since you're see nothing weird with this update I'm inclined to merge it sooner rather than later. If there are any oddities we can fix them up in the followup round…. |
|
I do have a delta machine, which I was using to verify that the fixes worked. However, I'm a bit concerned with the report that @JxpA provided. It's possible that something happened during one of the rebases, so I'll do some more testing tonight. |
462cc17 to
77b9304
Compare
Marlin/src/module/planner.cpp
Outdated
There was a problem hiding this comment.
A minor warning. The current_position does not have to be updated on a per-segment basis, and there may be code that calls this multiple times without ever updating current_position until the full move has been done. So we should check every call to buffer_segment to rule out this possibility.
There was a problem hiding this comment.
I've been thinking about that. One solution would be to only allow motion commands to call planner.buffer_line and not planner.buffer_segment. The planner could then keep a copy of the current Cartesian position, which is updated at the end of each call to buffer_line.
I believe I've already accomplished this on kinematic configurations, but UBL still calls buffer_segment for Cartesian machines.
There was a problem hiding this comment.
@thinkyhead - I just amended the commit to add planner_cart for kinematic machines only. Since current_position was only being used by kinematic machines, and they were already only using buffer_line, I think having the Planner track the current cartesian position mitigates your concern and should allow for accurate calculation of the delta between the target and current cartesian positions.
79223ab to
29edf0b
Compare
|
@thinkyhead - I've found an issue with this PR related to the original intent of fixing firmware retraction. It currently doesn't make use of recover lengths and only recovers what was initially retracted. I'll have to think about how I'm going to deal with that. |
29edf0b to
85bb05b
Compare
|
@thinkyhead - I've resolved the issue with the retract recover, so I believe this PR is good to go now. |
f1e85bc to
672fe08
Compare
- Move FWRETRACT to the planner - Combine leveling, skew, etc. in a single modifier method - Have kinematic and non-kinematic moves call one planner method
672fe08 to
b882bd4
Compare
|
Rebased and squashed. If it passes Travis testing then it will be merged shortly. |
|
@tcm0116 — What is your opinion of #6295 (comment) and should we add the proposed change? |
|
@thinkyhead I think the discussion in #6295 makes sense in that retractions can typically be performed at higher rates than normal extrusion. We do currently have a separate max velocity for travel vs non-travel movements, so there is precedence. I think it might also be a good idea for filament loading and unloading to be able to use the faster feedrate when pushing/pulling filament through the Bowden tubes. |
|
Perhaps I misunderstand, but don't we already have separate configurable feedrate settings for filament change? |
|
I think they want to have separate configurable limits for the extruder for when it's actually pushing filament through the hot end and when it's not. During normal extrusion, Marlin would enforce the first limit (which is presumably lower), and would enforce the second when doing things like retraction and loading/unloading filament, which can be faster due to the lack of back pressure on the filament. I currently have my max extruder speed at 50mm/s, but I know there's no way it could achieve that while actually pushing filament though the hot end, but I guess I just assume the slicing process will result in reasonably limited feedrates. |
|
Ah, I see. So, for these moves, a temporary removal of the speed limit in front of |
Description
Addresses #11512
The same issue exists in 1.1.x, so it could be applied there as well.