So stopj()/stopl() is not allowed in a thread. You’re only allowed to control motion in the main program (or sub programs), not threads and events.
Also, stopj() only works after you’ve stopped a motion. stopj() is not a stop command, only a deceleration command. It allows the robot to decelerate instead of braking abrubtly, which can introduce wear to the joints of the robot arm.
So you need to stop the motion first.
This is how I would achieve this:
Remember to enable Check expression continuously with the If StopRobot = True. This allows the robot to “leave” the underlying commands, before they’re finished.
The stop motion doesn’t seem to take its time to slow to a halt. It happens instantly when it feels a force. If I uncheck the box, it will go through all the waypoints, then stop. I was hoping it would slow down and stop like one second later at any point in the program where it feels the force. This code is the same as just adding an event and making it halt after a force is over 5 Newtons. Do my waypoint speeds need to be faster for the stopj to work better?
As @efn points out. You can only control the motion from one thread at a time.
The argument you parse to stopj is the acceleration:
If you want the stopping time to be one second. You could use _ get_target_joint_speeds()_ find the maximum value(max_joint_speed) and calculate the acceleration by 1/max_joint_speed
If it is not important with one second and would like a simple solution. You could calculate the acceleration by:
1/norm(get_target_joint_speeds())
That will give a little longer time depending on the amount of joints moving.
Try lowering the value to 5 in the stopj(). If you do not see a proper deceleration, then there’s probably something wrong elsewhere.
If that’s the case, please take a screenshot or picture of your code and attach it.