State - Terrapin-Rocket-Team/SRAD-Avionics GitHub Wiki
Home/Documentation/State
The State Class (State.h
)
Note: This class is expected to be heavily rewritten for the 24/25 year. If this notice is still here, then the information here may be out of date.
The State
class is designed to hold information about the position, velocity, acceleration, orientation, stage, and time of the rocket. This is collectively referred to as the "state" of the rocket. The class is updated by main.cpp
at 10hz, which causes it to query various sensors, fuse the data together as necessary, and update internal variables. It then updates a string with all the data we wish to record, and uses the RecordData
library to save it.
The flow of the class is as follows:
-
The class is instantiated during the
setup()
function ofmain.cpp
.- It is told whether it will record its own data (rather than relying on
main
to do it) and whether it will use a Kalman Filter or not.
- It is told whether it will record its own data (rather than relying on
-
Also in
setup()
, the class is given pointers to the sensors it will use.- It's designed to easily give it different sensors without reworking the class as a whole
-
State.init()
is called insetup()
to initialize the class.- This causes it to try and begin each of the sensors, and returns false if any of them fail.
- It initializes the Kalman Filter if it's being used.
- It readies a CSV header based on which sensors successfully initialized.
-
State.updateState()
is called inmain.cpp
at 10hz in theloop()
function.- This function queries the sensors for data, fuses it together or runs it through the Kalman Filter, and updates the internal variables.
- It determines which stage of flight it's in using various parameters that mark a new stage being entered.
- It then updates the string with all the data we wish to record.
- If it's set to record its own data, it does so here.
-
Every half a second,
State.transmit()
is called bymain
to transmit a string of telemetry data to the ground station.-
main
takes care of transmitting a second time if the string of data is too long for a single radio packet.
-
-
The class is designed to be easily extensible. It's easy to add new sensors or new data to the class.
-
Both the Kalman filter and stage detection have been pain points throughout the 23/24 year. Improvements will need to be made to them to help Avionics meet their goals for the 24/25 year. (Charge Deployment, etc.)
-
The MMFS repo is being actively worked on, and much of the responsibility of this class will move to a more abstract "Base" State class for the 24/25 year.
- This includes the Kalman Filter.