Get Controller Time

Need some help.

So I have a time sensitive operation that needs to be completed within 1 HR. I have been able to use timers, threads, if-statements, and installation variables to monitor time of the program when RUNNING (program is built in Polyscope)

Features I have:
a) monitor time elapsed in program (timer and thread, stored in installation variable)
b) warn operator if time is exceeded, halt operation if operator tries to STOP then START program (if-statement, continuously checked)
c) present operation time when complete ( popup string looks like “<#> mins <#> secs”)
d) reset timer, if need be (digital input button)

My pitfall is once the program is STOPPED I lose this functionality. I don’t plan on the operator stopping the program and I’ve accounted for resuming if it is stopped by using CASES. But the edge case IS if someone triggers a protective stop or the operator stops the program for alittle while then starts the program up again.

I’ve looked at a few posts and the best thing I’ve found is getControllerTime. I do have UR SDK and I’ve built 1 URcap (myfirsturcap, basically just to learn and see how involved it is) I’ve pulled the getControllerTime urcap into eclipse however i have issues modifying and installing the maven because the Apache license is not found or is now old and not compatible?? I would like to just modify the python file and add a few functions:

getStartTime() → Return “mm/dd/yyyy hh:mm:ss” (save as string in installation variable)
getElapsedTime(prg_start_time) → Return int value in SECONDS (save to installation variable for calculations)
isExceeded(prg_start_time,window_secs) → Return TRUE or FALSE (quick check for thread running at start and throughout program)

I mean I could try and build the urcap from scratch, but adding the daemon and stuff seems like quite the undertaking as I’m still understanding coding in Polyscope. I guess Im wondering if someone else has a better solution or if it would be possible to add this functionality to URscript for those applications where someone may need this. The goal is to keep everything local on the UR and not need another device monitoring the UR. (I understand like ALL PC’s that aren’t connected to the NET that the clock drifts but I have a procedure for checking and changing if need be on a weekly basis and I’m more worried that someone will stop a program for 58 mins and come back and start the program with it ONLY recording 2 mins total time) Ill probably end up just figuring out how to replicate the URcap and go from there (which will take me some time), but any suggestions or advice would be greatly appreciated!

Sorry for the long post but thank you for the help!


I think the conditions of a)~d) are not losted if the program is paused.
There is the way how to pause in robot program by using external device or urscripts.

I did not know timers still track after program is paused, that’s good to know though. I’m assuming this doesn’t apply to threads, or does it? And this does address one of the edge cases for pausing the program but I’m really interested in cases below:

  1. Operator STOPS program 30mins IN and does something else for 40min, NEW operator unaware returns to robot and STARTS program (during that time the TIMERS have only recorded 30min not actual time of 70min which would be outside of 1 HR window)

  2. Operator sees movement they don’t like, they press Emergency Stop Button and notify someone to back-drive robot and restart program (here there is no way to track the time passed if it was 5-10mins that it took to re-initialize robot, move out of a safety violation (if it’s in one), back drive to safe position, then resume the program)

  3. Operator leaves object in the way of robot and a collision triggers a Protective Stop (this I believe PAUSES the program but I’m not 100% sure, again I still need to account for some time that the operator spends trying to figure out why it’s not moving, clear the obstacle, close the safety popup, and resume program. Could be short (<1min) or long(>5min, operator doesn’t realize its not moving), I’m basically trying to future proof for new operators if there is a shuffle)

In addition, I’m trying to avoid using an external device to monitor time (dashboard server) and keep everything contained within Polyscope and UR robot. Program is actually very simple, it’s just the TIME is giving me problems if robot is NOT running a program. I know these are probably very strict requirements but Polyscope tracks TIME and DATE in the settings (I’m assuming from Linux or is setting the Linux clock) but I’m wondering if there is a way to leverage with a single line like the functions listed above (which using xml-rpc and python you can do) but instead like URscript or socket commands like “get variable” but “get ControllerTime”. Thanks for the help though, this may be useful for some other operations I need.

Unfortunately, there is no way to get to the time on the controller from within the Polyscope program, unless UR very recently released that. I do not know how timers would keep running if the program is paused or stopped because behind the scenes all they are is a fancy thread wrapper and anytime the program is paused or stopped all program execution stops until the program is restarted or resumed.

What we have done in the past is have an RPC call that we could make to an external device that would pass back the time of the external device. That way anytime we wanted to know a timestamp we just asked for it. This would require you to create an external RPC server but if you are a little savvy with programming they are not that hard to do. You would need something where that could run though, could be a PC or even a Raspberry Pi.

@mbush yea I wasn’t too sure of the threads/timers in PAUSED but I tried it, and yea… no dice they don’t continue tracking. Thanks for clarifying.

So I kind of figured it was going to come down to RPC, I havent spent much time in the SDK but the getControllerTime URcap linked above is I guess what I’m looking for with some modifications to the python code (add addition URscript functions) but it’s an older version and every time I try to modify it I have issues in Eclipse on the VM software, however if I just take the .urcap and put it on the UR it has no issues. (kind of a one man show right now, so I don’t have a ton of time to go down the rabbit hole) I may just have to bite the bullet and built it from scratch, I’ve been spending some time reading the URcap development documents and I think see how you add in daemons for this type of application.

Thanks for the help.