Way to save data from the RoboRio to a file (.txt or .json) on the driver station laptop?

The roborio needs to save data to a log on the computer so that I can use it to improve the code.
This data includes things like encoder data, vision processing information, and other things. I need it to be stored on the laptop so that I can copy/paste the numbers into the code to improve autonomous stuff. How to do this?

You can store it as a file on the robot and then transfer it to any laptop using FTP or a similar protocol.

2 Likes

Would creating a json variable and logging it to smartdashboard as a string work?

Okay so, there are a few ways to deal with this problem.

You can write errors and warnings in your code to your Driver Station logs using the DriverStation.reportWarning/reportError functions, and / or by printing to console (ie System.out.println() in Java). Both should end up in your Driver Station logs to be parsed later.

You could also write the file to a txt on the roboRIO like @Amicus1 said, as seen in this post.

And like you suggested, you could potentially log it to your Dashboard.

You have a multitude of options to collect the data you want to use. That said, it entirely depends on your workflow and use case. Best wishes!

We use a USB stick on the roborio and use a logger class we created to write the data. Pulling it into Excell made a huge difference in our testing capabilities. Feel free to check out our code at https://github.com/HoyaRobotics/InfiniteRecharge2020/blob/master/src/main/java/frc/robot/util/Logger.java

2 Likes

Lots of good answers here already. I think the issue is less of a technical gap, and rather picking something that fits your real requirements. Specifically:

From a technical perspective, probably yes. From a “meet your requirements”, maybe.

To illustrate, here’s what 1736 does : We create a new, unique CSV file every teleop or autonomous enable. The files have one row of data per loop of software execution. The files are saved onto a removable USB drive on the RIO, but we usually use a small python script to “snag” the files over FTP and clean the hard drive. We then can view the files after matches to review performance.

Here’s the reasoning:

  1. CSV: Many tools (including excel) can easily import it and display it meaningfully. The format is simple: First row is variable titles, second row is units, third and subsequent rows are the data. A customized text format or JSON would require a custom tool to display, which is undesirable for us.
  2. Saved on the Robot: We don’t want network interruptions or glitches (or someone forgetting to start something on the driver station) to cause data loss
  3. Saved on a USB Drive: We want to minimize chewing up hard drive space on the RIO itself. Historically, it’s been fast enough to read and write that we’ve been ok with the mechanism. It also allows the drive to be pulled out of the RIO and put into a laptop to quickly extract recording csv’s.
  4. FTP Script: Even though you could manually extract the USB drive, it’s not the best: You have to power cycle the robot each time, you might forget to put it back in, you wear down the contacts and make the RIO less reliable. While each of these could be solved in other ways, we found it easiest to just do a small script to automate the log file retrieval process.

Of note: The primary usage of these logs is after-the-fact triage. If we’re tuning a PID, we still want to see the data roll into the driver station in real-time, which pushes us to use shuffleboard or something equivalent to it.

So, while I won’t say our solution is universal, the key is that its components were built up from concrete requirements we accumulated over the years. And it might change in the future as those requirements change.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.