Logging Data in Polyscope
by Gaurav Shetty, on Jul 23, 2020 12:47:02 PM
In this Age of Analytics, data helps us make better decisions. It allows organizations to visualize relations between different systems and effectively determine the cause of problems. Logging of critical data for any application is one of the most important methods to track performance and troubleshoot an issue. Gone are those days where you have to wait for an error to repeat itself to be able to put in a fix. By having access to high quality data, you will be better informed to make a decision.
The Log Tab
The UR platform has built-in tools which makes it fairly easy to view and retrieve data around the operation of the robot. When an error occurs in the Polyscope program, a log of the error is generated. The log tab in Polyscope by default tracks these errors and other critical information such as protective stops, Polyscope program exceptions, safety violations and faults. These log entries are time stamped and populate the screen in real time as the robot performs its task. The log entries can be filtered by selecting the toggle buttons which correspond to the severity of the event. The different levels of severity are Informative, warnings and error messages. Some messages are designed to provide additional information by selecting the log entry.
The error reports can be exported to a usb drive as a text file and shared as desired or the log entries can be viewed directly on your smartphone using Beacon on the Hirebotics App! Here is a post which talks more about this cool product.
Apart from the controller level log entries, the log file will also display custom user-defined messages. These user driven messages can be descriptive sentences in text or numerical readings and can be defined in the Polyscope program using the “textmsg()” script line command.
Custom Log Messages
Custom messages can be displayed in the log file by selecting the “script node” from the “Advanced Tab” and by typing in the command textmsg(“var_1”, var_2) which will be executed as a script code by the UR controller. Please refer to the UR script manual of the appropriate Polyscope version to learn more about the syntax and more UR script commands.
The parameters of textmsg() command can be a combination of data types separated by a comma. This can include a string text and a variable value, waypoints values, mathematical results, state of input/output pins or sensor readings.
Where to use logs
The art of troubleshooting is integral to the performance of any system, and installing a robot comes with its fair share of troubleshooting to optimize the robot logic and motion. The main goal is to find the root cause of the issue and initiate a fix to prevent it from repeating.
A log file is one of the most important resource for troubleshooting as it captures error reports and system warnings. The file does not specify which line of your Polyscope program the error has occurred at. Hence, supplementing this information with custom log messages at relevant parts of your program to track the robot in the cell often helps narrowing down the issue by providing more context to the error logged. The goal is to log data in a manner which makes it easy to read, which in turn will make the process easier to maintain.
Let us consider a standard pick and place machine tending application where the robot loads a part into a turning machine. Let's say that the robot tends to crash every once in a while (but never when you're watching). These crashed will be reported in the log file, but unless you're watching the robot and wait for the crash to replicate itself, it will be difficult to pinpoint which part of your code needs attention.
This is where adding log messages in the code prior to critical sequences of steps will provide more context to someone who is familiar with the robot cycle as they scan through the log entries. But it goes beyond that. A person who is unfamiliar to the code base should also be able to follow along by analyzing a well curated log file. This will be very beneficial in collaborating with people outside your organization as well, in order to troubleshoot an issue with the robot quicker than before.
An example below shows the log entries of the execution of a program with user input log messages indicating the approach point, the critical waypoint, the depart point and the drop point. This gives you a snapshot of the robots operation and makes easier to pinpoint the origin of an error.
We can clearly see the robot encounters a protective stop (C15x error code) as it is moving to machine. This narrows down the point at which the error occurs and is very useful information for troubleshooting. Without having the user input log messages, there would be no data around the circumstances leading to the protective stop.
A Better Way to Debug
The native tools provided by UR are great for debugging and this post throws light on how to better utilize these tools to improve your troubleshooting or code development experience.