I need to debug communications with an external device. In a certain part of my script, it all goes south, so I would like to have an equivalent to a software breakpoint in my script code. Is there such an option? Or what do you guys do?
In the newest version of Polyscope. You can set breakpoints in the program tree. I know it might not be convenient, but if it is a small part of interest it could be an option.
You can also use the function
textmsg(s1, s2=’’) to add runtime information to the log.
If I want my script to stop at a certain point I will use popup messages and then send the information I want to the log as @Ebbe recommended. Since we use external buttons for play/pause/stop I will simply pause the program when that happens and then dismiss the popup and I can read the logs. When I’m ready to resume I hit play again
Another thing you could do is define a breakPoint function like this:
def breakPoint(): socket_open("local_host",29999, "break") socket_send_line("pause", "break") socket_close("break") sleep(0.5) #Give the server time to pause the robot before returning from the function end
I have tested this on an e-series simulator and this works as designed. The sleep in the break function is simply to give the robot time to receive the command and execute it before returning from the function, this prevents code from being executed immediately following the break before the pause would occur.
These are just a couple of options that I would use for having debugs within a script function. I have not looked to deep into the new UR break functionality within Polyscope but I do not see a way to apply that to a script file and have checked the generated script and do not see anything that is added to the script so assume its handed at the UI level, not within the program.
One other thing you could do is add an argument to the break function that would be able to log a message to the logs doing something like:
def breakPoint(msg=""): textmsg("BREAK POINT REACHED: ", msg) socket_open("local_host",29999, "break") socket_send_line("pause", "break") socket_close("break") sleep(0.5) #Give the server time to pause the robot before returning from the function end
Then you could see in the log where you hit the break and could name them or have some message generated.