Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
flight_control.h
Go to the documentation of this file.
1
14#ifndef FLIGHTCONTROL_H
15#define FLIGHTCONTROL_H
16
17#ifndef __MAIN_H
18#include "main.h"
19#endif
20
21#include "utilities.h"
22#include <stdio.h>
23#include <stdbool.h>
25#include "cmsis_os2.h"
26
27// --- Type Definitions ---
28
33typedef enum {
43
48typedef struct {
49 float_t accX;
50 float_t accY;
51 float_t accZ;
53
58typedef struct {
59 float_t height;
60 float_t velocity;
61 float_t acceleration;
63
70typedef struct {
74 uint32_t clock_memory;
75 uint32_t memory[3];
76 uint32_t memory_bis[3];
80
81// --- State Handler Functions ---
82
91
98void check_Liftoff_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData);
99
106void check_Burning_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData);
107
116
123void check_Drogue_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData);
124
131void check_Main_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData);
132
142
143
144// --- Core FSM Functions ---
145
156void check_flight_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData, linear_acceleration_t acc_data);
157
167void change_state_to(flight_fsm_t *fsm_state, flight_phase_t new_state);
168
169#endif /* FLIGHTCONTROL_H */
Defines mission-critical constants and tunable parameters for the flight software.
void check_Main_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData)
Handler for the MAIN state (descent under main parachute).
void check_Drogue_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData)
Handler for the DROGUE state (descent under drogue parachute).
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_AbcsDeployed_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData)
Handler for the ABCSDEPLOYED state (apogee control).
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 check_Liftoff_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData)
Handler for the LIFTOFF state.
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_Burning_phase(flight_fsm_t *fsm_state, estimation_output_t MotionData)
Handler for the BURNING state (powered ascent).
void change_state_to(flight_fsm_t *fsm_state, flight_phase_t new_state)
Handles the mechanics of a state transition.
flight_phase_t
Enumeration of all possible flight phases (states) in the FSM.
@ CALIBRATING
On the launchpad, calibrating sensors.
@ MAIN
Main parachute has been deployed.
@ LIFTOFF
Rocket has cleared the launch rail.
@ ABCSDEPLOYED
Airbrakes are deployed for apogee control.
@ DROGUE
Drogue parachute has been deployed.
@ BURNING
Engine is burning; under powered ascent.
@ INVALID
An undefined or error state.
@ TOUCHDOWN
Rocket has landed.
: Header for main.c file. This file contains the common defines of the application.
Holds the primary outputs of the state estimation filter (e.g., Kalman filter).
float_t velocity
Vertical velocity in meters per second (m/s).
float_t height
Vertical altitude above ground level in meters (m).
float_t acceleration
Vertical acceleration in meters per second squared (m/s^2).
Main data structure for the Flight State Machine.
uint32_t thrust_trigger_time
Timestamp when initial thrust was detected.
linear_acceleration_t old_acc_data
Raw acceleration data from the previous cycle.
uint32_t clock_memory
Timestamp of the last state transition.
flight_phase_t flight_state
The current state of the FSM.
bool state_changed
Flag set to true for one cycle after a state change.
linear_acceleration_t old_gyro_data
Raw gyroscope data from the previous cycle.
Represents a 3-axis linear acceleration vector from an IMU.
float_t accZ
Acceleration along the Z-axis in m/s^2.
float_t accX
Acceleration along the X-axis in m/s^2.
float_t accY
Acceleration along the Y-axis in m/s^2.
Provides low-level hardware drivers, sensor initialization routines, and various utility functions fo...