Repository navigation
Conversation
|
Interesting, thanks. I have some high-level comments (in no particular order). There is a lot of dense math here that I wont be able to review nor maintain. It's still possible that this code could reside in the main Klipper repository, but if that is the goal you would need to agree to maintain the code (answer questions, run tests, and make updates well into the future). Alternatively, perhaps @dmbutyugin would be willing to review. If you are looking to merge into the repo, the existing build test cases would need to pass. Also, note that the directory Similarly, if looking to merge into this repo, a signed-off-by line containing your real full name would be needed ( https://www.klipper3d.org/CONTRIBUTING.html#format-of-commit-messages ). Any file copyrights added should also contain a full name. Although I did not review the code, I get the impression that the new Note that there have been some other users of "cable winch" kinematics outside of the "hang printer" category. At least one person is using that kinematics for extreme speed prints. I'll followup on Discourse. FYI, for this upstream repo, we basically never add old-style "M1234" type commands. All new commands are expected to be in the new format (eg, Cheers, |
|
I'm afraid I would not be able to provide an in-depth review of the math here, but I could do a sanity-check review. That said, I may have misunderstood, but did you actually do real-life tests of this compensations besides simulation? If yes, it would be interesting to see the effects of this compensation on the real prints. And if not yet, could we do them? |
|
Hi, thanks for the comments! There's no rush to merge this now but your input is super useful, so I can work in that direction. We can look at it again when it's matured a little bit. I'm noting these todos:
Some Notes on PerformanceI don't expect performance will be a problem, but we'll see. The default QP algorithm and the other one ("Tikhonov", which uses gradient descent) have different performance properties. I'll try and get some real numbers today. Does Klipper have a target machine or a minimum requirement on the users CPU? Appendix Notes on PerformanceYou're right to be a bit suspicious about the numerical solving, it needs to be tightly measured/tuned/controlled, especially since performance/solve times varies in different areas/volumes: To my knowledge the numerical iterations is what it takes to solve this (most often underdetermined) non-linear optimization problem in a stable, reliable, and general manner. Some setups have (potentially a lot of) closed form solutions but I don't think they're worth implementing individually. It's possible to get forces faster by trading away perfection for speed. It depends on how close to "optimial" we want/need the (already correct) forces to be. I've used different definitions of "optimal" for the two algorithms: QP forces are:
Tikhonov forces are:
|
|
I'm noting that you mention Raspberry models down to Raspberry Pi Zero2W in the FAQ docs here. Quad-core 1GHz Cortex-A53 processor. I'll see what Raspberrys I can get my hands on. |
|
Ok I did some preliminary performace checks on my desktop machine. I did it like this. Results in I used this gcode as the example object: Main Result in the Slideprinter (three low anchors) CaseOut of 2050 s print time, the Comments About Number of Lines Effect on PerformanceWe currently calculate forces in all directions each time we calculate one single line length. We could optimize this. So for a machine with 3 lines we could cut the number of calls by 1/3 with some caching mechanism. Results also depend a lot on the number of anchors and the max/min force limits we configure. I've used Increasing the number of anchors from 3 to 4 (standard HP3 setup) gave: We see that Tikhonov does not scale as well as the default QP. This got me curious so I added another (high up) anchor and got: The results are roughly the same if the 5 anchors are arranged like HP5 will have them, with 4 low and 1 high anchor: We can conclude that the current Tikhonov algorithm is too slow for machines with more than 3 anchors. They should probably stick to the default QP algorithm. Comments About Whether this Will Work On Raspberry Pi Zero2WMy desktop cpu: 12th Gen Intel(R) Core(TM) i7-12700K The Pi Zero2W has a Quad-core 1GHz Cortex-A53 which is a lot slower. But if we can fit the matrices in the Zero's cache (which I think we can, the matrices are small), then 10s on my desktop will probably expand to ca 300 s on the Pi Zero2W (assuming we run single threaded). That's just my guess. Is that ok, or would 300 s of flex calculation on a 2050 s print be too slow? |
|
Thanks for the additional information.
For what it is worth, I don't think there is a hard requirement for CPU efficiency here. If it takes a lot of processing to get higher quality prints on these printers then that's what it takes. The main issue I think is being clear with users on what they should expect. Said another way, if the host computer needs to be a higher end computer to implement flex compensation then I think that is reasonable, but if it is the case then we should be clear on the hardware expectations in the documentation. (If 300/2050s ~= 15% increase, then that's not necessarily worth worrying about, but adding a blanket statement like "expect to use an Rpi5 or similar host machine if enabling flex compensation" is also fine.)
I think it would also be good to see at least a few different people using the implementation regularly on real world machines prior to merging into the mainline repo. Cheers, |
|
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. |
Also removes reference to "legacy" algorithm, updates config/example-winch.cfg and adds more explanation to config reference.
See ai_docs/test.sh
…all specified motors
Some machines pull the effector towards one anchor with several parallel lines, e.g. Hangprinter v4 with two lines on each of A, B, C and three on D. These lines share the planned force, so each one stretches less. Flex compensation treated every axis as a single line and so commanded roughly 2-3x the intended pretension. winch_lines_per_axis (default 1) divides the flex length by the number of parallel lines: flex = -F / (k * mechanical_advantage * lines). It is separate from mechanical advantage, which still also drives the spool buildup model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Convert per-line stretch to effector distance by dividing by mechanical advantage a second time. Add a Hooke's-law regression covering MA 1, 2 and 4, parallel lines and guy-wire lengths.
Flex compensation planned line tensions for a point mover: three force equations. On a mover held by single lines from spread out points, such as a cube held from its eight corners, those tensions leave a moment that the lines resolve by tilting the mover. On the simulated CubeCorners machine that put the nozzle about 1 mm off. New optional stepper options attachment_x, attachment_y and attachment_z give where each line attaches to the mover, measured from its centre of mass. When set, the tension solve adds three moment equations, scaled by the RMS attachment distance. Balancing moments can take large tension changes, so the existing ridge solver gave up moment balance for lower tensions, and its optimality test stops working with a ridge small enough to avoid that. The six equation case therefore gets its own bounded solver, which solves the 6x6 system over the free tensions and tests bounds in Newton. The point model keeps its solver and its results for the qp algorithm. The tikhonov algorithm takes the same six equations. Its 3x3 inverse is now a Cholesky solve of any size. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Use the existing bounded minimum-norm solver for point and attachment models. Remove the stalled ridge solver and test five-anchor force optimality and compensated inverse/forward round trips with direct and reduced winches. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Continue allocation after a released variable reaches its opposite bound. Respect physical output limits with pretension disabled and exercise that path through the real C helper. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
pulley_radius and swivel_axis_x/y/z make a winch anchor a swivel pulley whose line leaves from a moving tangent point (swivel_pulley.h, shared with RepRapFirmware and the development repo). Line lengths, flex force directions and the forward solve follow the wrap. winch_home_tension adds back the stretch lines already had when the motors were zeroed. Pinhole configs produce the same MCU messages as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also flush all step generation before a batch-mode exit, so .serial output is complete. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…only in batch mode Also reject an infinite winch_spring_constant with the spool options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
I meant to try and talk to you before creating a full PR, but here it is.
After a lot of effort I managed to post something on your Discourse:
https://klipper.discourse.group/t/flex-compensation-for-winch-kinematics/25031/3
Please answer here, your Discourse is unusable for me since I'm a new user.
It supports any purely translational cable robot configuration that has a central effector, including SpiderCam-like setups (all anchors high up), Slideprinter (2D robots), HP3-like setups (one high, several low anchors). Up to 26 anchors.
The "Print Logo" and "Print Squares" over at https://tobbelobb.github.io/hp-sim5/hp-sim/ now do flex compensation.
See https://gitlab.com/tobben/hangprinter-flex-compensation/ for the algorithm development.
See https://github.com/tobbelobb/klipper for the klipper implementation.
See https://github.com/tobbelobb/klipper/blob/master/docs/Config_Reference.md#cable-winch-flex-compensation for documentation on how to configure flex compensation.