motion: defer mode transitions instead of dropping them when not in position - #4284
motion: defer mode transitions instead of dropping them when not in position#4284grandixximo wants to merge 1 commit into
Conversation
…osition
set_operating_mode() honored a requested mode change (teleop, coord, or
free) only if motion was in position in the very servo cycle that
processed the request. Otherwise the request was silently erased
(coordinating/teleoperating cleared, or coordinating forced back to 1
on a failed free-space exit).
Task, however, acknowledges EMC_TASK_SET_MODE as soon as it is read and
flips mdiOrAuto immediately, so a dropped transition left task mode and
traj mode permanently diverged: determineMode() reports MANUAL whenever
traj is FREE/TELEOP, and nothing re-issues the request. This wedges the
mode machine until some unrelated mode command happens by, and is the
likely cause of the intermittent halui/mdi CI failures ("timeout
waiting for task mode" / "halui to report mode"), which no timeout
bump can fix since the mode never converges.
Keep the request pending instead: the transition now completes as soon
as motion comes to rest, matching the documented EMCMOT_COORD contract
("can be done at any time") and the existing deferred-enable behavior.
Verified with a deterministic repro: requesting MANUAL mid-MDI-move
wedged task mode at AUTO on master, and converges to MANUAL at move
end with this change.
|
So:
I guess that multiple rapid sent commands about mode changes would not matter as long as motion is in progress. Both flags would be overwritten each time when There is a side-effect when going to teleop mode. The |
|
Good catch, I looked at that path in detail and ran some tests on it.
Tested on a sim config (trivkins):
So I think the early |
Motion's set_operating_mode() honored a requested mode change (teleop, coord, free) only if motion was in position in the single servo cycle that processed the request; otherwise the request was silently erased. Task acknowledges EMC_TASK_SET_MODE as soon as it is read and flips mdiOrAuto immediately, so a dropped transition left task mode and traj mode permanently diverged: determineMode() reports MANUAL whenever traj is FREE/TELEOP, nothing re-issues the request, and no error is reported anywhere. The mode machine stays wedged until some unrelated mode command happens by.
This is the likely cause of the intermittent halui/mdi CI failures tracked in #4283 ("timeout waiting for task mode" / "halui to report mode"). Those are wedges, not slowness, so no timeout bump can fix them.
Fix: keep the request pending when not in position; the transition completes as soon as motion comes to rest, matching the documented EMCMOT_COORD contract ("can be done at any time") and the existing deferred-enable behavior.
Verification: