Home› Programming
Discussion
Back to discussions page
james77
Posts: 10 Apprentice
Question regarding functions and stuffs |
121 views
|
Answered | |
/ Most recent by james77
in Programming
|
4 comments |
in Programming
I was disassembling functions in polyscope to understand URscripts.
Whild I was looking into the Direction, I found this:
Whild I was looking into the Direction, I found this:
$ 1 "Robot Program"
$ 2 "MoveL"
$ 3 "Direction: Base Z+"
global move_thread_flag_3=0
thread move_thread_3():
enter_critical
move_thread_flag_3 = 1
local towardsPos=calculate_point_to_move_towards(p[0.0,0.0,0.0,0.0,0.0,0.0], [0.0,0.0,1.0], 1000.0)
movel(towardsPos, a=1.2, v=0.25)
move_thread_flag_3 = 2
exit_critical
end
Also, why the enter_critical and exit_critical are matter?
Thank you for answers
move_thread_flag_3 = 0
move_thread_han_3 = run move_thread_3()
while (True):
if (get_standard_digital_in(0) == True):
kill move_thread_han_3
stopl(3.0)
$ 4 "Until (io)"
break
end
sync()
end
I couldn't find the what the "calculate_point_to_move_towards(variables)" do, it's not on the manual that I found.Also, why the enter_critical and exit_critical are matter?
Thank you for answers
Best Answers
-
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
So the critical flags allow that thread to have the main execution meaning no other thread can prevent that thread from executing. If there is not enough physical time to execute all threads this one gets priority.Looks like you are using some of the new functions in the e-series where you can move in a direction until something happens like touching a surface. So the function is calculating the waypoint to move to. You will find other script functions that are not listed in the manual. These are generally functions that UR has not exposed to the URScript community but as you’ve found they are always discoverable but you would have to do the work to understand what the arguments mean.Also, always make sure you are using the script manual that corresponds to the Polyscope version because as they introduce new stuff in Polyscope sometimes they update the manual to match and give an API reference. -
matthewd92 Founding Pro, Tactile Sensor Beta Testers Posts: 1,267 Handy
Basically it keeps your thread in sync with the robot cyclesSay I have a thread that uses 1 millisecond of physical time performing calculations. Sync would then “sleep” for 1 millisecond to have the thread consume the 2 milliseconds of clock time each cycle lasts (assuming e-series, CB3 is 8ms clock cycle)
. Make sense?
This may irrelevant to current thread, but what sync() does?
I looked up the manual, and it says
"Uses up the remaining "physical" time a thread has in the current frame"
and I'm not quite sure what is exact role of the sync() function.