From a3770565b96dac2ad14e3a17ee10138a2ac2d485 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Tue, 21 Apr 2026 16:59:26 +0200 Subject: [PATCH 1/2] Make sure motion control returns to main thread before stopping When the watchdog times out, we halt in the external_control script and call stopj() just before that. However, ongoing motion will never happen in the main thread, but we always use a motion thread. Thus, calling stopj() here will result in an error that currently another thread is controlling the robot's motion. Since we still want to stop the robot using the predefined deceleration, we have to stop all motion beforehand. Effectively returning motion control to the main thread before calling stopj(). --- resources/external_control.urscript | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/resources/external_control.urscript b/resources/external_control.urscript index 164db7358..8b6ef5f76 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -1083,6 +1083,13 @@ while control_mode > MODE_STOPPED: end else: textmsg("Socket timed out waiting for command on reverse_socket. The script will exit now.") + if control_mode == MODE_FREEDRIVE: + end_freedrive_mode() + end + control_mode = MODE_STOPPED + join thread_move + kill thread_trajectory + kill thread_script_commands stopj(STOPJ_ACCELERATION) halt end From 7a8334db4c851215f196656e2928cba3b707981c Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 22 Apr 2026 14:25:08 +0200 Subject: [PATCH 2/2] Update external_control.urscript --- resources/external_control.urscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/external_control.urscript b/resources/external_control.urscript index 8b6ef5f76..2462f3517 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -1087,7 +1087,7 @@ while control_mode > MODE_STOPPED: end_freedrive_mode() end control_mode = MODE_STOPPED - join thread_move + kill thread_move kill thread_trajectory kill thread_script_commands stopj(STOPJ_ACCELERATION)