So I can’t even begin to figure this out, but despite writing less data and (supposedly) using less CPU, the binary format appears to use more power than the plaintext one. On the plus side, I didn’t get that far into it, but on the far more significant minus side, I’m probably not doing any more work on the tag in the near future. All the sensors have been accounted for in code, and any further optimization is low-priority.
Now, on one hand, that’s great. The tag is “done”, in some sense or another. On the other hand, the work to come after that is in A) getting rid of gravity and rotating the accelerometer data into the shark’s inertial reference frame, and B) machine learning. B) could be interesting, but right now I’m saddled with A), and since I don’t know that much physics, it comes down to copying other peoples’ solutions and hoping that they were right.
In any case, as I understand it, my job is to guess the pitch and roll of the shark… wait, hold on a second.
Anyway, I have to guess the pitch and roll of the shark from the accelerometer (with a bit of trig) and the gyroscope (with a bit of integration). The reason why I do both is because each sensor has a certain amount of error that, no matter how small, can accumulate to massive drift very quickly. I can use a Kalman filter, which takes the estimated drift and predicted pitch/roll into account, to get a more accurate measurement than either would alone. After that, I can figure out how the shark was oriented at a particular time and take out the gravity.
Hopefully. I’m probably missing something.