It appends the file every 10ms with our current values taken from our odometry code. This is probably a very bad way to do this, but let’s ignore that for now
I noticed the playback wasn’t working as I intended, so I wrote a simple debug script in Java (a language I’m much more familiar with) which is below.
However, this program spits out some interesting results. I uploaded the results of a recording where the robot sat, doing nothing, to a hastebin located here.
The program appears to be fine, until around the end, when it starts to record junk/random values to the file. How can I fix this? Thanks!!
You are writing out to the SD card every 10ms in the recordDrive() function. What you want to do instead is define a structure that can hold all of those values and in the recordDrive function write to the structure. Then, when your recording is done read structure and loop through each element and write it out to the file in the SD card.
Just do a 2d array, then save it at the end. Saving every 10 ms could cause huge inconsistencies with your code if you’re running it back based on time (I have to redo a bunch of my code now because of intrinsic inconsistencies). I’m doing something similar to what you’re doing here, and yeah that’s the only realistic way.
You probably shouldn’t append it anyways. Instead you should have different files.