Skip to content

Commit 39d6f92

Browse files
author
Luca Toniolo
committed
motion/control: guard jerk decomposition for identity kinematics only
The S-curve jerk decomposition assumed joint[0,1,2] = X,Y,Z, which is only true for identity kinematics. For KINEMATICS_BOTH (e.g. XXYYYZ or rotatekins) joint indices don't map to axis letters, making the decomposition incorrect. Guard with KINEMATICS_IDENTITY check so non-trivial kinematics fall back to cubic interpolator jerk values.
1 parent 69b1f80 commit 39d6f92

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/emc/motion/control.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,21 +1398,17 @@ static void get_pos_cmds(long period)
13981398
joint->pos_cmd = cubicInterpolate(&(joint->cubic), 0, &(joint->vel_cmd), &(joint->acc_cmd), &(joint->jerk_cmd));
13991399
}
14001400

1401-
/* Use accurate jerk values from TP output (for Cartesian machines only)
1402-
* For standard XYZ machines, joint[0-2] correspond to X, Y, Z axes
1403-
* TP outputs: current_jerk (path jerk) and current_dir (direction unit vector)
1404-
* Per-axis jerk = path_jerk * direction_component
1401+
/* Use accurate jerk values from TP output for identity kinematics only.
1402+
* For KINEMATICS_BOTH (non-trivial joint mapping), joint indices don't
1403+
* necessarily correspond to XYZ axes, so keep cubic interpolator values.
14051404
*/
1406-
if (emcmotStatus->planner_type == 1) {
1407-
// S-curve mode: use accurate jerk values
1405+
if (emcmotStatus->planner_type == 1
1406+
&& emcmotConfig->kinType == KINEMATICS_IDENTITY) {
14081407
double path_jerk = emcmotStatus->current_jerk;
14091408
PmCartesian dir = emcmotStatus->current_dir;
1410-
1411-
// For the first 3 joints (assuming X, Y, Z), use accurate jerk
14121409
if (NO_OF_KINS_JOINTS >= 1) joints[0].jerk_cmd = path_jerk * dir.x;
14131410
if (NO_OF_KINS_JOINTS >= 2) joints[1].jerk_cmd = path_jerk * dir.y;
14141411
if (NO_OF_KINS_JOINTS >= 3) joints[2].jerk_cmd = path_jerk * dir.z;
1415-
// Rotary axes (A, B, C) keep the cubic interpolator values for now
14161412
}
14171413

14181414
/* report motion status */

0 commit comments

Comments
 (0)