Hello, I am trying to figure out ways to map our robot’s position periodically from our drivetrain subsystem and put the current Pose2d object with a timestamp to a tree object. I have written code for a bound and unbound way of doing this by deleting the first position when the limit is reached. I was wondering if anyone had any idea how many Pose2d objects I could log before running into a memory exception or overflow and also if any other teams used a similar method and know what was a good number of positions to log. The RoboRIO has 512MB of ram.
Java memory management is going to mean these numbers are an upper bound, but -
Pose2d consists of a Translation2d and Rotation2d.
Translation2d consists of 2 doubles for x and y, and Rotation2d consists of 3 doubles - one for the actual angle, and one each for sine and cosine. Doubles are 8 bytes in size, so each Pose2d is at a minimum 40 bytes. 1 MB is 2^20 bytes, so a most it can contain ~26 thousand poses.
Robots usually run code at 50hz, so if you were to insert one pose every loop, it would take you 524 seconds at most to fill 1MB. Even if we assume an additional overhead of 40 bytes, that’s 262 seconds to fill just 1 MB.
Whatever you’re trying to do with the RIO, just don’t leave it on overnight.
On memory usage and memory leaks:
I would just recommend logging to an external USB flash drive. It saves the hassle of SSHing in to the RIO and also gives you the option to put get a lot more storage for other logging, if you so choose. We’re currently using these mini USB drives, but any flash drive should work.
EDIT: I’ll also note that we’re using AdvantageKit from 6328, but WPILib also has their own logging framework.
Also see On-Robot Telemetry Recording Into Data Logs — FIRST Robotics Competition documentation
It automatically logs to a usb drive if one is plugged in, otherwise logs to the onboard storage (and the datalogtool can be used to easily download the logs via ssh).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.