Is it possible to cancel a move command to a target position mid movement? I have a thread that stops the robot in a certain conditions using “stopl”, but I cannot take control of the robot, and I’m getting the error “Another thread is already controlling the robot”, when the robot is in the middle of a movej command in the main thread. I’ve attached a simple program which mimics the error. As the thread calls the stop function in the middle of the movej, it throws the error. It is important the stop happens instantly, so I cannot wait for the movement to end.
I realised that putting the move commands in another thread and killing the thread does the trick. Or inserting the commands inside a continuously evaluated while loop in polyscope, which is basically the same functionality when looking at the code at script level.
Yep these will both work. Be careful of how you stop the movements though. These approaches will just jump out of the movement directly without proper deceleration, which if you’re moving at speed will have adverse effects on the robot joints over time. Look at calling stopl() or stopj() commands straight after the loop for a smoother stop.
I did it using a sensor. into a if continuously statement it was compare a signal while that signal is false the arm do a line move to get a X waypoint but if the signal become true the arm stop through a stopl() funtion and execute othre task.
there is also a built-in Function for this called Until which can be set inside a waypoint node (PolyScope 3.9+/5.3+)
The function @m.birkholz is mentioning, is a part of Direction, which can be found under the Structure > Advanced tab. You can put that into a L or P move, and then have it move in a direction, either a distance, or setting an “until expression”.