LinuxCNC S-Curve Accelerations
- ihavenofish
- Offline
- Platinum Member
-
- Posts: 988
- Thank you received: 281
For example YangYang is now looking at stopping to destination with vel0 acc0 jerk0 all at the same time at the ends of an arc segment, in the servo-thread we compute next position forward in time, they keep adding up, and this leads to numerical errors, which make the jerk overshoot near the final destination, then you have to clamp down the error smoothly to arrive at destination, within current architecture you have to overshoot, you have to readjust, he has tried multiple avenues to fix this, nothing so far has worked.
How commercial TP fix this? they don't plan forward, they plan from destination backwards at each time increment with dedicated hardware, and deal with feed override changes by re-planning to a different time destination.
You can probably understand how different LinuxCNC is from commercial controllers, they practically work in the complete opposite way...
Many of the issues we are faced with, have similar kind of solutions in the commercial space, they just don't do it how LinuxCNC does it.
When I wrote "we are limited to what we can do", I intended it in the scope of implementing jerk limiting within the current TP, with tangential jerk limiting code that is being enabled with planner_type 1, and some blending and look-ahead improvements, to try and stick to jerk limited motion, without introducing any non-realtime code in servo-thread, sure a complete rewrite you can do whatever, but that is not something you do overnight. And we are also limited by physics, you can't have high-speed accuracy smoothness all at the same time, physics just don't allow this. I understand most here would sacrifice speed, but there is a camp that would like to squeeze out a bit more speed if possible sacrificing some accuracy within what's allowed by the gcode.
You'll need to change the TP. I'm not offering a $3000 cnc as a bounty for something you can vibe code overnight
Speaking of, a little bird told me that someone with the skills should request tormachs latest source....
DO IT NOW!
Please Log in or Create an account to join the conversation.
- rodw
-
- Away
- Platinum Member
-
- Posts: 11744
- Thank you received: 3973
Another possibility would be to run a gcode filter to "normalize" the gcode for performance and jerk limiting. Joco's Monokrom filters out all holes and replaces them with its own optimised code with custom leadins so it can be powerful in the right hands...
Please Log in or Create an account to join the conversation.
- ihavenofish
- Offline
- Platinum Member
-
- Posts: 988
- Thank you received: 281
I thought it had already been established that Tormach do not have jerk limiting.
Another possibility would be to run a gcode filter to "normalize" the gcode for performance and jerk limiting. Joco's Monokrom filters out all holes and replaces them with its own optimised code with custom leadins so it can be powerful in the right hands...
Um, what? Where did you hear this?
Pathpilot for the 1500mx has jerk limiting and other g64 features. However the source people have had access to on here (like grotius) was an older version without these features.
So, ask tormach for the source again, it should now be the 1500mx version.
Please Log in or Create an account to join the conversation.
- grandixximo
-
Topic Author
- Away
- Premium Member
-
- Posts: 149
- Thank you received: 247
Quote:
Hi All,
Sorry for the wait this week! I'd love to do a zoom call and dig into the trajectory planner differences. The S-curve planner PR is an exciting change, and it would be awesome to learn more about it. There are a few times during the week that are good for me to do a long meeting:
Fridays between 10AM-4PM EST (Jan 16, 23, and 30)
Wednesday Jan 28th between 11AM-4PM EST
Thursdays in Jan, 9PM-11PM EST
Given the volume of things to discuss, a recurring meeting might be a good idea to spread things out. If we can get a weekly, biweekly, or monthly time on the calendar, it will be easier to get through all of the material, and also deal with new issues as they come up.
In the meantime, here are some quick answers for Greg C's questions:
Does Tormach have any 9 axis .ngc files they use for testing they could share? We have some test cases, but most of them are not real part programs, rather they just exercise the trajectory planner. Some of them may be in the Tormach linuxcnc fork, I'll look through my archives for the rest.
Does Tormach have any build tests set up that they are willing to share? The tormach linuxcnc fork has extended tests that would be great to include upstream, most of which are subdirectories in the "tests/motion". There are test cases for probing, cutter compensation, spindle synchronization, and a few others.
What changed from trivkins to square3kins, and is any of that worth considering for inclusion in our project? square3kins is an extension of "millkins" i.e. forum.linuxcnc.org/49-basic-configuratio...kins-or-millkins-xyz . I can discuss in more detail, but main additions are rigid rotation of the coordinate system (correct for table surface not parallel to the motion axes) and atomic update of parameters
Are there any parts of the implementation that were accepted as “good enough,” deferred for later cleanup, or known compromises that we should be aware of? Yes, depending on how stringent your definition is. Most of these are documented in code with TODO / FIXME tags. This is a detailed subject, but one example is how we handle blend tolerances in 9-axis blending. In lieu of solving the kinematics, we basically assume that "deg = inch" when sizing the blend arc. This is suboptimal but generally safe (1 deg is 1 inch displacement on a ~57" diameter part).
If you were implementing this today in a joint-based architecture, is there anything you would change about the overall approach or design? This is another long subject, but the biggest change would be to make the have the trajectory planner work in joint space, and use the realtime kinematics layer only for minor adjustments like squareness comp. To actually do that is a big effort (biggest change is incorporating kinematics earlier motion planning).
Also, to answer an earlier question, the limited jerk method we're using in the Tormach fork is an extension of the current planner. A quick summary of what we did (happy to discuss in more detail in the call):
Filter each axis independently with a moving average filter, and set the length of that filter via the new M59 command (M59 D# in ms)
Reduce the feed rate of high-curvature moves such that the axis filtering does not "round the corners" more than the specified tolerance (M59 H# in length units)
Apply custom settings in certain conditions to avoid lag (tapping, threading, probing)
Change the notion of "done" in the TP to wait for the nominal path to be done + average filters fully drained
The main benefit is the user has control over smoothness, path accuracy, and achievable feed rate. For example, you can do high-load roughing with more smoothing and looser path tolerances. For finish passes, you apply tighter path tolerances. This limits the achievable feed rates, which is generally tolerable on fine finish passes.
Best,
Rob
Please Log in or Create an account to join the conversation.
- grandixximo
-
Topic Author
- Away
- Premium Member
-
- Posts: 149
- Thank you received: 247
Mine and YangYang's approach: "We will deviate from the commanded path by at most P, using this specific mathematical curve."
Tormach's approach: "We will filter the output and try to keep deviation reasonable, probably, mostly."
For you to object to Beziers on path-purity grounds while advocating for Tormach's method is... inconsistent, to put it politely.
Please Log in or Create an account to join the conversation.
- ihavenofish
- Offline
- Platinum Member
-
- Posts: 988
- Thank you received: 281
If filtering is what you call s-curve, that will not take long to implement, but that is practically the same as setting s-curve on your servos, but you have a nice parameter in the gcode which you can tweak. But mind that jerk filtering WILL change your path, this is as far as I understand just a lazy afterthought patch fix.
Mine and YangYang's approach: "We will deviate from the commanded path by at most P, using this specific mathematical curve."
Tormach's approach: "We will filter the output and try to keep deviation reasonable, probably, mostly."
For you to object to Beziers on path-purity grounds while advocating for Tormach's method is... inconsistent, to put it politely.
Sigh.
There should be no deviation. ever. period. If the word deviation comes up, we are not talking about jerk control anymore.
Option 1, then option 2. Option 2 is mostly useless without Option 1. Filtering doesn't work for me as it is not controlled motion. As you say, we can just soften the servo response for that and we all know that is NOT a good plan.
So it does sound like we need a ground up new TP to actually get anywhere with this. A bit disappointed as this means tormach's implementation was kinda misrepresented to me (not by rob, I never talked to him directly).
That's said, I still feel like this would be great to get implemented anyway, as it might make a bit of a stop gap incremental improvement even if its not the end goal. it would not meet any of the requirements for the lemontart bounty though.
Sleepy time.
Please Log in or Create an account to join the conversation.
- grandixximo
-
Topic Author
- Away
- Premium Member
-
- Posts: 149
- Thank you received: 247
But I think you're mixing up two different things, how the machine speeds up and slows down is jerk control, whether we cut corners is G61 vs G64, these are separate knobs, if you want perfect path following, use G61, the machine will stop at every corner, follow the exact line, no deviation, with proper S-curve planning it'll do that smoothly instead of jerking around, you get accuracy, you give up speed, fair trade.
G64 P is for when you say "I'm okay with cutting corners by up to this much, just keep moving." That's already how LinuxCNC works today, S-curve doesn't change that, it just makes the motion smoother while respecting whatever tolerance you set.
Why Beziers instead of arcs for blending?
Arcs are a 2D thing. Works fine for XYZ, but what's an "arc" when you've got 9 axes moving at once? It doesn't really make sense.
Beziers are just smooth curves that work in any number of dimensions.Also arcs have constant curvature, so when you enter and exit a blend there's a sudden curvature change, the TP deals with this by speeding up and slowing down, which is why you see velocity bobbing up and down through corners, Beziers can match curvature at the transitions, so you get steadier speed through the blend, And on top of that, arcs need sin/cos every servo cycle while Beziers are just a handful of multiplies and adds, In a tight loop running 1kHz+, that matters. Same tolerance as before, just a better curve to fill it with.
This isn't like the clothoid thing, we're not trying to get fancy with exotic geometry, just trying to get smooth motion that respects whatever path constraints you set, does that make more sense?
Just to be clear, the only reason I'm talking about deviation is because S-curve has to work in all modes, including G64 P where the user has asked for corner blending, s-curve isn't only for G61 exact stop, and there will always be a fallback to trapezoidal via HAL pins, some operations like threading, tapping, and probing need the tighter timing that trapezoidal gives you. You can hook planner_type to an M-code and switch modes in your G-code when needed.
Please Log in or Create an account to join the conversation.
- ihavenofish
- Offline
- Platinum Member
-
- Posts: 988
- Thank you received: 281
@ihavenofish I think there's some confusion here worth clearing up, you're right that filtering (like Tormach does) gives you unpredictable deviation, the path ends up wherever the filters spits out, that's not what we're after.
But I think you're mixing up two different things, how the machine speeds up and slows down is jerk control, whether we cut corners is G61 vs G64, these are separate knobs, if you want perfect path following, use G61, the machine will stop at every corner, follow the exact line, no deviation, with proper S-curve planning it'll do that smoothly instead of jerking around, you get accuracy, you give up speed, fair trade.
G64 P is for when you say "I'm okay with cutting corners by up to this much, just keep moving." That's already how LinuxCNC works today, S-curve doesn't change that, it just makes the motion smoother while respecting whatever tolerance you set.
Why Beziers instead of arcs for blending?
Arcs are a 2D thing. Works fine for XYZ, but what's an "arc" when you've got 9 axes moving at once? It doesn't really make sense.
Beziers are just smooth curves that work in any number of dimensions.Also arcs have constant curvature, so when you enter and exit a blend there's a sudden curvature change, the TP deals with this by speeding up and slowing down, which is why you see velocity bobbing up and down through corners, Beziers can match curvature at the transitions, so you get steadier speed through the blend, And on top of that, arcs need sin/cos every servo cycle while Beziers are just a handful of multiplies and adds, In a tight loop running 1kHz+, that matters. Same tolerance as before, just a better curve to fill it with.
This isn't like the clothoid thing, we're not trying to get fancy with exotic geometry, just trying to get smooth motion that respects whatever path constraints you set, does that make more sense?
Just to be clear, the only reason I'm talking about deviation is because S-curve has to work in all modes, including G64 P where the user has asked for corner blending, s-curve isn't only for G61 exact stop, and there will always be a fallback to trapezoidal via HAL pins, some operations like threading, tapping, and probing need the tighter timing that trapezoidal gives you. You can hook planner_type to an M-code and switch modes in your G-code when needed.
I am not mixing up anything. This is literally what I've been saying the whole time. You literally just repeated what I said several posts ago.
S curve DOES NOT HAVE TO WORK IN ALL MODES. This is the point of my "option1" for exact stop as I described earlier (and lead ins and outs of g64 moves). This is the most important jerk control needed in linuxcnc. Option 2 is making it work fully with g64 and is FAR FAR less important. Option 1 is critical, option 2 is... optional. This is why every single jerk control project fails. People jump at option 2 and give up.
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
- Posts: 4661
- Thank you received: 2078
This is the most important jerk control needed in linuxcnc. Option 2 is making it work fully with g64 and is FAR FAR less important.
I think that this might actually be the point were many would beg to disagree.
Please Log in or Create an account to join the conversation.
- ihavenofish
- Offline
- Platinum Member
-
- Posts: 988
- Thank you received: 281
This is the most important jerk control needed in linuxcnc. Option 2 is making it work fully with g64 and is FAR FAR less important.
I think that this might actually be point were many would beg to disagree.
And this is a problem.
Please Log in or Create an account to join the conversation.