Skip to content

Logging usage

Chris Gerth edited this page Feb 3, 2017 · 1 revision

Background

Having the proper diagnostic information is crucial for determining root cause of issues seen. Especially during competitions, hard-to-reproduce problems can still be solvable if detailed information exists on what was occurring when the problem happened.

Driver observation and mechanical intuition are big parts of this. However, the robot's software is also particularity well-positioned to gather the necessary data.

Robot Casserole has developed a logging system for keeping track of robot behavior during each enabled cycle (teleop & autonomous). Specific data channels are logged into .csv files, which are stored on an external usb thumb drive.

These .csv files can be retrieved manually, or fetched via FTP while connected to the robot. Once grabbed from the robot, they can be viewed with a variety of tools.

The hope is that when failures occur on the field, the root cause may be identified with help from the logged data.

Robot Software

Casserole utilizes a custom designed library for creating its log files. At robot initialization, each piece of data to be logged is registered with the logger. The registration must include a name for the signal, the signal's units, and a reference to the getter method for the signal.

At the start of every teleop or autonomous loop, the init method is called. This opens a new log file with the present date/system time in the name.

Once per periodic loop, the log_data method should be called. This causes the logging library to call every registered getter method to acquire the present values of the data, and write them to file. The writes go through java's BufferedWriter interface to minimize lost time due to disk interactions.

At the start of every disabled period, the close method is called. This ensures the log file is closed and fully written to disk, so it is ready for retrieval.

File Transfer Process

Once the robot is off the field, the pit crew and software team can extract the logged data to analyze for any potential issues. This can be done by one of two methods:

  1. Pull out the USB drive from the robot, copy the files to a laptop, and replace the USB drive.
  2. Use the file snagger scripts to FTP into the roboRIO and move the files in an automated way.

Note using the scripts assumes Git is installed (as it uses git's FTP tooling). It also needs python 3.x to run.

Analyzing the logs

Viewing the logged data can be done with a tool of your choice. The format is simply one row of signal names, one row of units, and then all remaining rows are single samples of data (per-loop). The first column should always be the time (measured from getFPGATimestamp()) and may be used by a plotting tool if needed. Excel is a decent way to look through the data.

We did find we weren't satisfied with the data viewing capabilities of any of the pre-built open-source plotting tools, so we decided to make our own. For maximum portability, we built it using javascript and html, with a pure-javascript plugin from Highcharts to do the heavy lifting for plotting. We're quite happy with the results (especially the touchscreen integration). Eventually we may incorporate this into the robot's hosted webpages to negate the need to download all logs first.

To run the log file viewer, simply open the top-level html file in any modern browser. Select the top button to pick your log file, and it should be displayed below.

Note there are a few buttons with hard-coded combinations of channels we found useful. You may wish to tweak these to your own taste if you adapt the code for yourself.