Skip to content

Commit 6eb3e6a

Browse files
author
Luca Toniolo
committed
new global default max jerk is 1e9 bigger will throw off the calculations
1 parent 53b41dc commit 6eb3e6a

10 files changed

Lines changed: 32 additions & 11 deletions

File tree

configs/sim/axis/axis_9axis_scurve.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
# acceleration profiles that can reduce machine vibration and
88
# improve surface finish.
99
#
10-
# IMPORTANT: S-curve planning is OPTIONAL and DISABLED by default.
10+
# IMPORTANT: S-curve planning is OPTIONAL.
1111
# Traditional trapezoidal acceleration is used when:
1212
# - PLANNER_TYPE = 0, OR
13-
# - MAX_LINEAR_JERK = 0 (or not specified)
13+
# - MAX_LINEAR_JERK = 0
14+
#
15+
# NOTE: If MAX_LINEAR_JERK is not specified, it defaults to 1e9 (1 billion),
16+
# which effectively disables jerk limiting while still using S-curve calculations.
17+
# This produces motion similar to trapezoidal but not identical.
1418
#
1519
# ========================================================
1620
[EMC]
@@ -64,6 +68,8 @@ PLANNER_TYPE = 1
6468
# Units: machine-units/second^3 (e.g., mm/s^3 or inch/s^3)
6569
#
6670
# Setting this to 0 disables S-curve planning regardless of PLANNER_TYPE
71+
# If not specified, defaults to 1e9 (effectively no jerk limiting)
72+
# Maximum allowed value is 1e9 (values above are automatically clamped)
6773
#
6874
# Recommended starting values (adjust based on your machine):
6975
# - Light/rigid machines: 1000-10000

configs/sim/axis/axis_mm_scurve.ini

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
# acceleration profiles that can reduce machine vibration and
88
# improve surface finish.
99
#
10-
# IMPORTANT: S-curve planning is OPTIONAL and DISABLED by default.
10+
# IMPORTANT: S-curve planning is OPTIONAL.
1111
# Traditional trapezoidal acceleration is used when:
1212
# - PLANNER_TYPE = 0, OR
13-
# - MAX_LINEAR_JERK = 0 (or not specified)
13+
# - MAX_LINEAR_JERK = 0
14+
#
15+
# NOTE: If MAX_LINEAR_JERK is not specified, it defaults to 1e9 (1 billion),
16+
# which effectively disables jerk limiting while still using S-curve calculations.
17+
# This produces motion similar to trapezoidal but not identical.
1418
#
1519
# ========================================================
1620
[EMC]
@@ -64,6 +68,8 @@ PLANNER_TYPE = 1
6468
# Units: machine-units/second^3 (e.g., mm/s^3 or inch/s^3)
6569
#
6670
# Setting this to 0 disables S-curve planning regardless of PLANNER_TYPE
71+
# If not specified, defaults to 1e9 (effectively no jerk limiting)
72+
# Maximum allowed value is 1e9 (values above are automatically clamped)
6773
#
6874
# Recommended starting values (adjust based on your machine):
6975
# - Light/rigid machines: 1000-10000

docs/src/config/ini-config.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,10 @@ Finally, no amount of tweaking will speed up a tool path with lots of small, tig
863863
* `PLANNER_TYPE = 0` - (((PLANNER TYPE))) Selects the trajectory planner type: 0 = trapezoidal (default), 1 = S-curve with jerk limiting.
864864
S-curve planning is only active when `PLANNER_TYPE = 1` AND `MAX_LINEAR_JERK > 0`.
865865
* `MAX_LINEAR_JERK = 10000.0` - (((MAX JERK))) The maximum jerk (rate of change of acceleration) for coordinated moves, in 'machine units' per second cubed.
866-
Default is 10000.0.
866+
Default is 1e9 (1 billion) if not specified, which effectively disables jerk limiting while avoiding numerical instability.
867+
Values are clamped to a maximum of 1e9 to prevent numerical issues in S-curve calculations.
867868
When `PLANNER_TYPE = 1`, this enables S-curve trajectory planning.
869+
Note: Not specifying MAX_LINEAR_JERK (defaulting to 1e9) produces motion similar to trapezoidal planning (PLANNER_TYPE = 0) but not identical, as extremely high jerk still uses S-curve calculations.
868870
* `POSITION_FILE =` _position.txt_ - If set to a non-empty value, the joint positions are stored between runs in this file.
869871
This allows the machine to start with the same coordinates it had on shutdown.
870872
This assumes there was no movement of the machine while powered off.

docs/src/config/integrator-concepts.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ MAX_JERK = 1000.0
279279

280280
S-curve planning is only active when `PLANNER_TYPE = 1` and `MAX_LINEAR_JERK > 0`.
281281

282+
NOTE: If `MAX_LINEAR_JERK` is not specified, it defaults to 1e9 (1 billion), which effectively disables jerk limiting while maintaining S-curve calculations. This produces motion similar to trapezoidal planning but not identical. The maximum allowed value is 1e9 to prevent numerical instability.
283+
282284
=== Tuning
283285

284286
Start with a conservative jerk value and increase gradually:
@@ -293,6 +295,8 @@ Typical values: 100-100,000 units/s^3^ depending on machine rigidity and units
293295
Increase `MAX_LINEAR_JERK` until motion becomes sluggish or following errors
294296
increase, then reduce slightly. Test with coordinated moves and arcs.
295297

298+
Values above 1e9 are automatically clamped to 1e9 to avoid numerical issues in the S-curve trajectory calculations.
299+
296300
== RTAI
297301

298302
The Real Time Application Interface (RTAI) is used to provide the best

src/emc/ini/initraj.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ static int loadTraj(EmcIniFile *trajInifile)
203203
}
204204
old_inihal_data.traj_max_acceleration = acc;
205205

206-
// Set max jerk (default to 10000 if not specified in INI)
207-
jerk = 10000.0;
206+
// Set max jerk (default to 1e9 if not specified in INI)
207+
jerk = 1e9;
208208
trajInifile->Find(&jerk, "MAX_LINEAR_JERK", "TRAJ");
209209
if (0 != emcTrajSetMaxJerk(jerk)) {
210210
if (emc_debug & EMC_DEBUG_CONFIG) {

src/emc/task/taskintf.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,9 @@ int emcTrajSetMaxJerk(double jerk)
12281228
{
12291229
if (jerk < 0.0) {
12301230
jerk = 0.0;
1231+
} else if (jerk > 1e9) {
1232+
// Clamp to 1e9 to prevent numerical instability in S-curve calculations
1233+
jerk = 1e9;
12311234
}
12321235

12331236
TrajConfig.MaxJerk = jerk;

tests/interp/m98m99/12-M99-endless-main-program/expected.motion-logger

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SET_NUM_SPINDLES 1
33
SET_VEL vel=0, ini_maxvel=1.2
44
SET_VEL_LIMIT vel=4
55
SET_ACC acc=1e+99
6-
SET_JERK jerk=10000
6+
SET_JERK jerk=1e+09
77
SET_PLANNER_TYPE planner_type=0
88
SETUP_ARC_BLENDS
99
SET_MAX_FEED_OVERRIDE 1

tests/motion-logger/basic/expected.builtin-startup.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SET_NUM_SPINDLES 1
33
SET_VEL vel=0, ini_maxvel=1.2
44
SET_VEL_LIMIT vel=4
55
SET_ACC acc=1e+99
6-
SET_JERK jerk=10000
6+
SET_JERK jerk=1e+09
77
SET_PLANNER_TYPE planner_type=0
88
SETUP_ARC_BLENDS
99
SET_MAX_FEED_OVERRIDE 1

tests/motion-logger/mountaindew/expected.motion-logger

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ SET_NUM_SPINDLES 1
33
SET_VEL vel=0, ini_maxvel=120
44
SET_VEL_LIMIT vel=400
55
SET_ACC acc=1e+99
6-
SET_JERK jerk=10000
6+
SET_JERK jerk=1e+09
77
SET_PLANNER_TYPE planner_type=0
88
SETUP_ARC_BLENDS
99
SET_MAX_FEED_OVERRIDE 1

tests/motion-logger/startup-gcode-abort/expected.motion-logger.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SET_NUM_SPINDLES 1
88
SET_VEL vel=0, ini_maxvel=1.2
99
SET_VEL_LIMIT vel=4
1010
SET_ACC acc=1e+99
11-
SET_JERK jerk=10000
11+
SET_JERK jerk=1e+09
1212
SET_PLANNER_TYPE planner_type=0
1313
SETUP_ARC_BLENDS
1414
SET_MAX_FEED_OVERRIDE 1

0 commit comments

Comments
 (0)