Hey, I’m having a question on programming the coBot (URe5) in polyscope. When I have stored a position
s = get_actual_tcp_pose()
I can access, for example the height, using
h = s
However, there are serveral occasions where it isn’t possible to call 2 consecutive commands, and instead I need one command. This is a problem, because (for example in a condition) I’m not allowed to write something like
get_actual_tcp_pose() < 0.003
How do I proceed in such cases? Or is there something I am missing?
You can add a thread to your program that is always monitoring the TCP pose, then use the appropriate value within a single line of your program. The example below would write the TCP pose to “s” every 0.2 seconds. s could then be evaluated in the main program at any time. Threads don’t begin running until the Robot Program starts, so if you need a value in a Before Start section, you’ll need to keep that in mind.
that is definitely a work-around to my problem. From your answer I guess that it is not possible to access the height in a single command (like writing get_actual_tcp_pose(), for example)?
At this time, there is no built-in script command to get a single dimension from a pose that isn’t already defined.
If you have a specific example of this causing a programming issue/limitation, you can file a feature request and the ability may be added to Polyscope in future revisions.
I see. Do I get right that I wouldn’t have the Problem if I’d program the Cobot in UR-Script, instead of using the polyscope gui?
I believe you would have the same issue whether you were programming in full script or using the Polyscope GUI.
I see. So I’d have to program one level below? What would that be?
I’m not sure under what other circumstances you cannot call 2 commands, but in the case of your conditional example, here is something that should work for you.
Defining functions inside a script file will allow you to smash as many lines as you want into a single function call. Functions defined like this are accessible by Polyscope anywhere you can type with the keyboard. You can assign variables this way, use results in conditionals, etc. You can even define them to take input parameters, allowing you to, for example, pick out each index of the TCP array, seen in the second “If” command in the screenshot.
Does this help?