Skip to content

Commit 4134464

Browse files
committed
fixed freezing up on non-tangent
1 parent 10bdc6b commit 4134464

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/emc/motion_planning/motion_planning_9d.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,10 +2111,14 @@ int applyLimitingVelocities_9D(TC_QUEUE_STRUCT *queue,
21112111

21122112
double v_new = smoothing.v_smooth[k];
21132113

2114-
if (tc->term_cond == TC_TERM_COND_TANGENT && tc->finalvel > 0.0) {
2115-
if (v_new < 1e-6) {
2114+
if (tc->term_cond == TC_TERM_COND_TANGENT) {
2115+
if (tc->finalvel > 0.0 && v_new < 1e-6) {
21162116
v_new = tc->finalvel;
21172117
}
2118+
} else {
2119+
// STOP and EXACT segments must decelerate to zero — never apply
2120+
// a non-zero backward-pass velocity to their exit fields.
2121+
v_new = 0.0;
21182122
}
21192123

21202124
atomicStoreDouble(&tc->shared_9d.final_vel, v_new);

src/emc/motion_planning/motion_planning_9d_userspace.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,9 @@ extern "C" int tpAddLine_9D(
14681468
}
14691469
}
14701470

1471-
// Mark for re-optimization (geometry changed)
1471+
// Invalidate stale profile (target distance changed) so
1472+
// replanForward recomputes with the new target.
1473+
__atomic_store_n(&prev_tc->shared_9d.profile.valid, 0, __ATOMIC_RELEASE);
14721474
__atomic_store_n((int*)&prev_tc->shared_9d.optimization_state,
14731475
TC_PLAN_UNTOUCHED, __ATOMIC_RELEASE);
14741476

src/emc/tp/tp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5326,8 +5326,10 @@ int tpRunCycle(TP_STRUCT * const tp, long period)
53265326
if (opt_state >= TC_PLAN_OPTIMIZED) {
53275327
double opt_vel = atomicLoadDouble(&tc->shared_9d.final_vel);
53285328

5329-
// Sanity check: velocity should be positive and reasonable
5330-
if (opt_vel > 0.0 && opt_vel < 1e6) {
5329+
// Sanity check: velocity should be positive and reasonable.
5330+
// Only apply to TANGENT segments — STOP/EXACT must keep target_vel=0.
5331+
if (opt_vel > 0.0 && opt_vel < 1e6 &&
5332+
tc->term_cond == TC_TERM_COND_TANGENT) {
53315333
tc->target_vel = opt_vel;
53325334
tc_debug_print("9D: Applied optimized velocity %g (state=%d)\n", opt_vel, opt_state);
53335335
}

0 commit comments

Comments
 (0)