Terrapin-Rocket-Team / SRAD-Avionics

Code and PCBs for the avionics subteam for the SRAD flight computer and side projects
6 stars 2 forks source link

Update State class and sensor classes to get rid of Arduino String and and C++ STL refrences #54

Closed DrewBrandt closed 9 months ago

DrewBrandt commented 9 months ago

In order to support moving to more portable code, the state class and related sensor classes should give their data in a format that can be used cross platform.

Edited Later:

DrewBrandt commented 9 months ago

Ok I've written it all but it needs to be thoroughly tested. RecordData library should have all of its String references removed as well.

Because of the lack of current testing, I do not want to create a pull request. If you guys have time @varun-un and @jhauerst, can you take a look at it and let me know what you think?

DrewBrandt commented 9 months ago

I've written tests on branch Tests-for-54. The tests also need to be tested, but the idea is to feed it fake data from a past launch and see what it does.

DrewBrandt commented 9 months ago

That other branch is now merged with the one for this issue. It includes a test folder that can be used to test the state class (and kalman filter). To use it, switch your platfomio environment away from "Default" and into env:teensy4.1_TEST_STATE

image

That will cause the compiler to ignore main.cpp and instead load TestState.cpp as the main. From there you can run the code on the teensy, then, when the light turns solid, run the SendData.py script to start sending data to it via serial.

It then listens for a response from the teensy about what state it THINKS its in, before sending more data. It compiles every message the teensy sends it about its state in test_results.csv.


I checked as best as I could for memory leaks, but there do not appear to be any. I would like someone else *cough* @varun-un *cough* to take a look and tell me what they think.

The main idea behind this was to make the code more portable, which I strongly feel has been accomplished. The sensors themselves still need to be addressed, and the test will only run on an Arduino, but it's a first step.


PS. Install Colorama (pip install colorama) to use the python script. The colors make it much easier to compare between sent and received messages.