IZAR Flight Controller 1.0.0
IZAR Flight Controller running with an ESP32.
flight_controller.h
Go to the documentation of this file.
1#ifndef FLIGHT_CONTROLLER_H
2#define FLIGHT_CONTROLLER_H
3
5
6#include <inttypes.h> // For int64_t
7#include <stdbool.h> // For bool
8
9// Set acceleration threshold to detect liftoff (in g-forces).
10#define ACCELERATION_THRESHOLD_FOR_LIFTOFF_DETECTION 2.0
11
12// Set window size to calculate the altitude mean.
13#define WINDOW_SIZE_FOR_ALTITUDE_MEAN 10
14
15// Altitude threshold (in meters) from the highest recorded altitude to consider
16// it the apogee.
17#define ALTITUDE_DIFFERENCE_TO_CONSIDER_APOGEE 1
18
19// Configure height for deploying main chute (in meters).
20#define MAIN_CHUTE_DEPLOYMENT_HEIGHT 150.0
21
22// Configure deployment times. This opens windows for chutes deployment.
23#define MIN_MS_DROGUE_DEPLOYMENT 9500
24#define MAX_MS_DROGUE_DEPLOYMENT 1300
25#define MIN_MS_MAIN_DEPLOYMENT 20000
26#define MAX_MS_MAIN_DEPLOYMENT 35000
27
28// Number of milliseconds that the chute deployment charges will be ignited.
29#define MS_EXECUTING_CHUTE_CHARGES 1000
30
31// Set acceleration threshold to detect touchdown (in g-forces).
32#define ACCELERATION_THRESHOLD_FOR_TOUCHDOWN_DETECTION 2.0
33
34#define TAG_FLIGHT_CONTROLLER "Flight Controller"
35
43
53
64 float *altitude_mean_array,
65 int *oldest_element_pointer);
66
86bool should_drogue_chute_be_deployed(float altitude_mean,
87 float highest_altitude_mean_detected,
88 uint64_t ms, uint64_t ms_liftoff);
89
109bool should_main_chute_be_deployed(float mean_altitude,
110 float launching_altitude, uint64_t ms,
111 uint64_t ms_liftoff);
112
125
126#endif // FLIGHT_CONTROLLER_H
void flight_controller()
Main FreeRTOS task function for the flight controller.
Definition flight_controller.c:109
float update_rocket_altitude_mean(float rocket_altitude, float *altitude_mean_array, int *oldest_element_pointer)
Create a mobile mean to filter rocket altitude.
Definition flight_controller.c:27
bool should_main_chute_be_deployed(float mean_altitude, float launching_altitude, uint64_t ms, uint64_t ms_liftoff)
Check if the main chute should be deployed.
Definition flight_controller.c:72
bool should_drogue_chute_be_deployed(float altitude_mean, float highest_altitude_mean_detected, uint64_t ms, uint64_t ms_liftoff)
Check if the drogue chute should be deployed.
Definition flight_controller.c:49
bool detect_liftoff(mpu6050_acceleration_t rocket_acc)
Detect if liftoff has happen. Works by detecting if the currect linear acceleration is higher than th...
Definition flight_controller.c:14
bool detect_touchdown(mpu6050_acceleration_t rocket_acc)
Detect if the rocket has landed.
Definition flight_controller.c:96
float rocket_altitude
Definition sensors_reading.c:27
Definition mpu6050.h:84