FTM: constant jerk planner#28349
Draft
dbuezas wants to merge 12 commits intoMarlinFirmware:bugfix-2.1.xfrom
Draft
FTM: constant jerk planner#28349dbuezas wants to merge 12 commits intoMarlinFirmware:bugfix-2.1.xfrom
dbuezas wants to merge 12 commits intoMarlinFirmware:bugfix-2.1.xfrom
Conversation
Contributor
Author
|
On longer tests i found some bugs, please hold until i fix them. |
fix discontinuity bug use full BLOCK_BUFFER_SIZE remove 50% left/right cap cap left side by at most half full buffer left min size is old right (with bug) exit speed fix but over complicated wip remove left min size (works but risky?) fix with min size fmt move out cleanup (tested working in printer) cleanup (cherry picked from commit 8f5de41)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a constant-jerk trajectory planner and generator to FT Motion as a new trajectory type alongside Trapezoidal, Poly5, and Poly6.
Marlin's standard trapezoidal motion profile changes acceleration instantaneously, causing mechanical stress and resonance. This PR introduces 7-phase S-curve trajectories where jerk (the rate of change of acceleration) is bounded, so acceleration ramps up and down gradually. This is unrelated to Marlin's "classic jerk" (which is an axial delta-v threshold).
How it works
The system has two layers:
1. Trajectory generator (
trajectory_constant_jerk.h) — Plans the S-curve for a single junction-speed-optimized block:Uses binary search to find the highest feasible peak velocity given entry/exit speeds, distance, acceleration limit, and jerk limit. All phase boundaries have zero acceleration (smooth transitions).
2. Block planner (
constant_jerk_planner.h) — Sits between Marlin's planner and the trajectory generator. It:entry_speed/exit_speed(computed with trapezoidalv²=v₀²+2ad, not valid under jerk constraints)max_entry_speed_sqras junction speed ceiling (geometric, valid for any motion profile)maxReachableSpeed()(binary search with S-curve distance instead ofv²=v₀²+2ad)Block merging algorithm
Compatible blocks (same nominal speed, acceleration within 10%) are merged using a left/right superblock approach:
v_peakof the left group; if it exceeds any interior junction limit, binary-split the group and retryThis allows eliminating a variable during planning (when optimising junction speed at junctions). Acceleration is constrained to zero at junctions so the backwards and forward passes don't output complex vel+accel envelopes that are hard to compute and intersect. The trajectory merging algorithm then reduces the need for unnecessary slowdowns. The full generalised optimal planner would be prohibitively complex.
As far as I know this is a novel approach.
Although a single 7 phase trajectory now can cover multiple blocks, original block boundaries are tracked by distance so
ft_motion.cppcan release consumed planner blocks and update axis ratios.Configuration
G-code
M494 J<value>— Set maximum jerk (mm/s³). Higher values print faster at the cost of increased resonance. TheJparameter follows the sameset_jerkMax()pattern asset_smoothing_time(): it callsprep_for_shaper_change()to synchronize motion before updating.Trajectory type selection:
M494 T3(CONSTANT_JERK).LCD menu
Adds jerk max editing to the FT Motion settings menu and CONSTANT_JERK to the trajectory type selector. The unit in the menu is not mm/s3, but is m/s3 because the numbers are otherwise too large to show in the LCD (that's why I added the unit to the lcd string).
Files changed
ft_motion/trajectory_constant_jerk.hft_motion/constant_jerk_planner.hConfiguration_adv.hFTM_CONSTANT_JERKenable flag andFTM_DEFAULT_JERK_MAXdefaultConditionals-4-adv.hHAS_FTM_TRAJECTORY_SELECTION, defaultFTM_TRAJECTORY_TYPEft_motion.hcfg.jerk_max,cfg.set_jerkMax(),cjPlannermemberft_motion.cppplan_next_block()and block boundary tracking infill_stepper_plan_buffer()M494.cppJparameter parsing, jerk reportingtrajectory_generator.hCONSTANT_JERKenum valuemenu_motion.cpplanguage_en.hMSG_FTM_CONSTANT_JERK,MSG_FTM_JERK_MAXstringsRequirements
This uses considerably more cycles so probably requires an FPU, just try it out! :)
And it is available only in FTMotion.
Benefits
Configurations
Tested with
STM32H723VG_bttenvironment (SKR3 EZ). EnableFTM_CONSTANT_JERKin Configuration_adv.h.Related Issues