From a1bc52363e305dcc4b8f63b52ebc063d5559ff77 Mon Sep 17 00:00:00 2001 From: david mueller Date: Mon, 5 Jan 2026 20:38:34 +0100 Subject: [PATCH] Set motion mode to FREE when volatile joints have been unhomed Joints set to volatile are automatically unhomed when task state switches to OFF or ESTOP If a joint is thus unhomed motion state needs to be set to 'free' --- src/emc/motion/command.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/emc/motion/command.c b/src/emc/motion/command.c index 9b3d16b937c..1138e6f4850 100644 --- a/src/emc/motion/command.c +++ b/src/emc/motion/command.c @@ -1376,7 +1376,7 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) break; case EMCMOT_JOINT_UNHOME: - /* unhome the specified joint, or all joints if -1 */ + /* unhome the specified joint, or all joints if -1, or volatile joints if -2 */ rtapi_print_msg(RTAPI_MSG_DBG, "JOINT_UNHOME"); rtapi_print_msg(RTAPI_MSG_DBG, " %d", joint_num); @@ -1386,8 +1386,22 @@ void emcmotCommandHandler_locked(void *arg, long servo_period) return; } - //Negative joint_num specifies unhome_method (-1,-2) - set_unhomed(joint_num,emcmotStatus->motion_state); + // For configs that require homing and have joints configured as VOLATILE_HOME + // 'get_allhomed()' will change from TRUE to FALSE. If that happens we need to + // switch motion mode to 'free'. + if ( get_allhomed() && (joint_num == -2) ) { + set_unhomed(joint_num,emcmotStatus->motion_state); + if (!get_allhomed()) { + emcmotInternal->teleoperating = 0; + SET_MOTION_TELEOP_FLAG(0); + emcmotInternal->coordinating = 0; + SET_MOTION_COORD_FLAG(0); + } + } + else { + set_unhomed(joint_num,emcmotStatus->motion_state); + } + break; case EMCMOT_CLEAR_PROBE_FLAGS: