![]() |
Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
|
Defines the states, events, and data structures for the rocket's main Flight State Machine (FSM). More...
#include "main.h"

Go to the source code of this file.
Data Structures | |
| struct | linear_acceleration_t |
| Represents a 3-axis linear acceleration vector from an IMU. More... | |
| struct | estimation_output_t |
| Holds the primary outputs of the state estimation filter (e.g., Kalman filter). More... | |
| struct | flight_fsm_t |
| Main data structure for the Flight State Machine. More... | |
Enumerations | |
| enum | flight_phase_t { INVALID , CALIBRATING , LIFTOFF , BURNING , ABCSDEPLOYED , DROGUE , MAIN , TOUCHDOWN } |
| Enumeration of all possible flight phases (states) in the FSM. More... | |
Functions | |
| void | check_Calibrating_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData, linear_acceleration_t acc_data) |
| Handler for the CALIBRATING state. | |
| void | check_Liftoff_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData) |
| Handler for the LIFTOFF state. | |
| void | check_Burning_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData) |
| Handler for the BURNING state (powered ascent). | |
| void | check_AbcsDeployed_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData) |
| Handler for the ABCSDEPLOYED state (apogee control). | |
| void | check_Drogue_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData) |
| Handler for the DROGUE state (descent under drogue parachute). | |
| void | check_Main_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData) |
| Handler for the MAIN state (descent under main parachute). | |
| void | check_Touchdown_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData, linear_acceleration_t acc_data) |
| Handler for the TOUCHDOWN state. | |
| void | check_flight_phase (flight_fsm_t *fsm_state, estimation_output_t MotionData, linear_acceleration_t acc_data) |
| Main FSM router function that delegates to the current state's handler. | |
| void | change_state_to (flight_fsm_t *fsm_state, flight_phase_t new_state) |
| Handles the mechanics of a state transition. | |
Defines the states, events, and data structures for the rocket's main Flight State Machine (FSM).
This header file contains all the definitions necessary for the flight control logic. The FSM is responsible for managing the mission sequence, transitioning the rocket through its various flight phases from pre-launch calibration to post-landing touchdown.
Definition in file flight_control.h.
| void change_state_to | ( | flight_fsm_t * | fsm_state, |
| flight_phase_t | new_state | ||
| ) |
Handles the mechanics of a state transition.
This utility function updates the FSM's state to the new phase, sets the state_changed flag, and records the transition timestamp. It ensures state changes are handled consistently.
| [in,out] | fsm_state | Pointer to the FSM state object to be updated. |
| [in] | new_state | The new flight_phase_t to transition into. |
Definition at line 229 of file flight_control.c.
References clear_fsm_memory(), and flight_fsm_t::flight_state.
Referenced by check_AbcsDeployed_phase(), check_Burning_phase(), check_Calibrating_phase(), check_Drogue_phase(), check_Liftoff_phase(), and check_Main_phase().


| void check_AbcsDeployed_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData | ||
| ) |
Handler for the ABCSDEPLOYED state (apogee control).
Monitors for apogee detection (velocity changing from positive to negative) to trigger drogue parachute deployment.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
Definition at line 162 of file flight_control.c.
References ABCSDEPLOYED, APOGEE_SAFETY_COUNTER, change_state_to(), DROGUE, drogue, flag_attitude, flag_MPC, flight_fsm_t::flight_state, estimation_output_t::height, flight_fsm_t::memory, and previous_altitude.
Referenced by check_flight_phase().


| void check_Burning_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData | ||
| ) |
Handler for the BURNING state (powered ascent).
Monitors for motor burnout and transitions to the coasting/apogee control phase.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
Definition at line 126 of file flight_control.c.
References ABCSDEPLOYED, APOGEE_SAFETY_COUNTER, BURNING, change_state_to(), COASTING_SAFETY_COUNTER, DROGUE, drogue, flag_attitude, flag_MPC, flight_fsm_t::flight_state, estimation_output_t::height, flight_fsm_t::memory, flight_fsm_t::memory_bis, and previous_altitude.
Referenced by check_flight_phase().


| void check_Calibrating_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData, | ||
| linear_acceleration_t | acc_data | ||
| ) |
Handler for the CALIBRATING state.
Monitors for a sustained high vertical acceleration that indicates liftoff.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
| [in] | acc_data | Raw linear acceleration data from the IMU. |
Definition at line 56 of file flight_control.c.
References linear_acceleration_t::accX, AIRBRAKES_SAFETY_COUNTER, CALIBRATING, change_state_to(), flag_attitude, flag_flash, flight_fsm_t::flight_state, estimation_output_t::height, LIFTOFF, LIFTOFF_SAFETY_COUNTER, LIFTOFF_TRESHOLD_ACC, flight_fsm_t::memory, flight_fsm_t::memory_bis, and QFlash_Write().
Referenced by check_flight_phase().


| void check_Drogue_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData | ||
| ) |
Handler for the DROGUE state (descent under drogue parachute).
Monitors altitude to trigger main parachute deployment at a predefined height.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
Definition at line 181 of file flight_control.c.
References change_state_to(), DROGUE, flight_fsm_t::flight_state, estimation_output_t::height, MAIN, MAIN_DEPLOY_HEIGHT, MAIN_SAFETY_COUNTER, mainp, and flight_fsm_t::memory.
Referenced by check_flight_phase().


| void check_flight_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData, | ||
| linear_acceleration_t | acc_data | ||
| ) |
Main FSM router function that delegates to the current state's handler.
This function acts as a switchboard. Based on the flight_state member of the FSM object, it calls the appropriate handler function for the current phase (e.g., check_Calibrating_phase, check_Liftoff_phase, etc.).
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | The latest output from the state estimation filter. |
| [in] | acc_data | The latest raw linear acceleration data. |
Definition at line 17 of file flight_control.c.
References ABCSDEPLOYED, BURNING, CALIBRATING, check_AbcsDeployed_phase(), check_Burning_phase(), check_Calibrating_phase(), check_Drogue_phase(), check_Liftoff_phase(), check_Main_phase(), DROGUE, flight_fsm_t::flight_state, INVALID, LIFTOFF, MAIN, flight_fsm_t::state_changed, and TOUCHDOWN.
Referenced by StartFSM().


| void check_Liftoff_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData | ||
| ) |
Handler for the LIFTOFF state.
Monitors for the end of the motor burn phase based on acceleration drop.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
Definition at line 93 of file flight_control.c.
References APOGEE_SAFETY_COUNTER, BURNING, change_state_to(), COASTING_SAFETY_COUNTER, DROGUE, drogue, flag_attitude, flag_kf, flag_MPC, flight_fsm_t::flight_state, estimation_output_t::height, LIFTOFF, flight_fsm_t::memory, flight_fsm_t::memory_bis, and previous_altitude.
Referenced by check_flight_phase().


| void check_Main_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData | ||
| ) |
Handler for the MAIN state (descent under main parachute).
Monitors for a stable, low altitude and a spike in acceleration to detect landing.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
Definition at line 197 of file flight_control.c.
References change_state_to(), flag_flash, flight_fsm_t::flight_state, MAIN, flight_fsm_t::memory, TOUCHDOWN, TOUCHDOWN_SAFETY_COUNTER, estimation_output_t::velocity, and VELOCITY_BOUND_TOUCHDOWN.
Referenced by check_flight_phase().


| void check_Touchdown_phase | ( | flight_fsm_t * | fsm_state, |
| estimation_output_t | MotionData, | ||
| linear_acceleration_t | acc_data | ||
| ) |
Handler for the TOUCHDOWN state.
This is a terminal state. The function performs any necessary post-landing actions, such as disabling pyros or saving final data.
| [in,out] | fsm_state | Pointer to the FSM state object. |
| [in] | MotionData | Filtered estimation data (altitude, velocity). |
| [in] | acc_data | Raw linear acceleration data from the IMU. |