Skip to content

Commit 4dda6d5

Browse files
authored
Make sure motion control returns to main thread before stopping (UniversalRobots#490)
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(). Alternatively, we could remove the `stopj()` command (it is effectively not doing anything right now, anyway), but that would result in a very sudden stop of the robot.
1 parent 40bc3c8 commit 4dda6d5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

resources/external_control.urscript

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,13 @@ while control_mode > MODE_STOPPED:
10831083
end
10841084
else:
10851085
textmsg("Socket timed out waiting for command on reverse_socket. The script will exit now.")
1086+
if control_mode == MODE_FREEDRIVE:
1087+
end_freedrive_mode()
1088+
end
1089+
control_mode = MODE_STOPPED
1090+
kill thread_move
1091+
kill thread_trajectory
1092+
kill thread_script_commands
10861093
stopj(STOPJ_ACCELERATION)
10871094
halt
10881095
end

0 commit comments

Comments
 (0)