-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Currently, the way that MIDAS handles FSM-triggered code is by setting a flag in the commands struct, and then consuming these flags in a context that is more convenient to work in.
This isn't great for code readability and being able to extend our infrastructure. For instance, the flag listed above is triggered when a high acceleration is detected (which usually indicates launch but can be a false positive) to set camera feeds. If we wanted MIDAS to perform other actions when detecting launch, we would have to either
-
- Use the same block, and thus put unrelated code into a block that has to do with
command_flags.FSM_should_set_cam_feed_cam1
- Use the same block, and thus put unrelated code into a block that has to do with
-
- Create a new command and set it in the same place as the flag above, which is wasteful.
The likely best approach here is to make this system more robust and allow for certain events to be triggered at arbitrary times and dispatch functions which make working with the data more streamlined.
Your task: Make a system that is simple to use and expand that allows you and other teams (mainly GNC) to write code that triggers when certain FSM conditions are met.
This is an open-ended problem:
There is likely not one "best solution", but the general flow of this system should be something like the following pseudo code:
void launch_detect_dispatch(RocketSystems* arg) {
arg->b2b.camera.camera_off(SIDE_CAMERA);
}
struct midas_event_triggers {
MidasEvent launch_detect = MidasEvent(launch_detect_dispatch);
}Then, in a file like fsm.cpp
...
events.launch_detect.dispatch();
...
Which will automatically call launch_detect_dispatch. This can be done by making MidasEvent have an internal flag and checking it in systems.cpp or whatever method you come up with! It should be straightforward to add new events and triggers for them.