Home› Applications
Discussion
Back to discussions page
Sebastien
Posts: 219 Handy
Universal robot stopping between two variable waypoints |
6.6K views
|
Answered | |
/ Most recent by matthewd92
in Applications
|
13 comments |
Hi pros,
we are working on a program where we would have two waypoints that are variable waypoints. We would move the robot to the first one. Then the robot would move to the second point but we would like to make the robot stop during that motion to the second point based on a Digital input signal.
How would you program that? Do you think using a thread that is checked continuously makes sense?
we are working on a program where we would have two waypoints that are variable waypoints. We would move the robot to the first one. Then the robot would move to the second point but we would like to make the robot stop during that motion to the second point based on a Digital input signal.
How would you program that? Do you think using a thread that is checked continuously makes sense?
Tagged:
Something like this
This would move to waypoint_1 and then monitor the input during the move to waypoint_2, if at any point the digital input turned on the move would be terminated. We use this a lot with our programs for instance placing one part onto another, only move until a certain force threshold is reached and then stop. Allows us to accommodate variation in parts or pick position for instance without causing the robot to fault.
How would you do that in script code?
Turns out I was not able to program this in a script. I tried the way you suggest but I did not know how to have the condition monitored at all time in my script file. I tried using a thread but my stopl commande was in the thread and because the move line had control of the robot, it did not allow the stopl to operate without an error appearing on the pendant.
I have never tried implementing this in script but it makes sense, basically if you get into the if statement you would kick off a thread that would execute the move. Then a while loop would be monitoring the status of the thread handler, as long as the thread was still executing then the if statement would interrupt the thread if the conditional was voided.
Takes a moment to kind of figure out whats going on but makes sense. Also, notice that the stopj is not inside of a thread, it just follows the of statement just like it would in a polyscope program.
This is a good tip that I never thought of doing. Going from a .urp to script!
Thanks for the tip!
When you add an If statement or Loop within Polyscope, you have the ability to click 'Check Statement Continuously'. This means that once you enter the If statement or Loop, it will execute the commands within only as long as the initial condition remains true.
So if I had my structural elements as follows (pseudocode):
The program would Wait until Digital Input 0 was True, then begin going through the list of waypoints. If Digital Input 0 ever dropped Low before reaching pose99, the program would halt.
We do not yet have a sensor so we cannot check if the programming is good enough... with False, the whole program works smoothly but we are not sure what will happen when the value is True.
1)
This is kind of a nonintuitive thing, but when you're using an If/Else and the If is checked continuously, you can enter the 'If DO[0]=True' portion of the program, start running the commands within it, and then jump into the Else portion if DO[0] ever goes false while headed to point_6.
Normally this isn't something that happens. If you have an If/Else that is NOT checked continuously, you have two hunks of code (one under If, one under Else) and only one of those hunks will ever run.
If you wanted to ensure that you jump completely out of the If/Else statement, you could replace the Else with an Elseif. Maybe it would look like this:
Started_If is just an arbitrary variable functioning as a flag that lets us know if we entered the first part of the If statement. If we do, it ensures we never enter the Else portion.
2)
Also please note the stopj(5) Script command. if you're checking things continuously there's a chance you could interrupt robot motion and lead to a protective stop. Putting in a stopj(a) command ensures that the robot will decelerate before moving on. That 'a' is the acceleration argument. Rule of thumb is 0.1=slow deceleration 5+=pretty rapid deceleration.
3)
Lastly, if your robot encounters that Halt it will never reach the 3F Basic Open after it in the Else statement.
There is one thing I don't understand though. 99% of the times, DO[0] will be false in the beginning. Our process consists of the tooling of some polypropylene tubes. These tubes have three longitudinal lines separated 120º on which we cannot tool or otherwise they would break. Therefore, we need to place them onto a support and position them according to a sensor that detects those lines over which we cannot tool.
My question is then: if started_if:=True when we enter the continuously checked if, and then DO[0]:=True, we would jump to the elseif with DO[0]:=True and started_if:=True as well, right? Or am I missing something?
PS: Thank you for the Halt, I have no idea why I entered that into the program.
I wonder if they thought that would make more sense to a non-programmer over a WHILE command?