IZAR Flight Controller 1.0.0
IZAR Flight Controller running with an ESP32.
|
#include "flight_controller/flight_controller.h"
#include "sd/sd_c.h"
#include "sensors_reading/mpu6050/mpu6050_c.h"
#include "sensors_reading/sensors_reading.h"
#include <driver/gpio.h>
#include <esp_log.h>
#include <esp_timer.h>
Functions | |
bool | detect_liftoff (mpu6050_acceleration_t rocket_acc) |
Detect if liftoff has happen. Works by detecting if the currect linear acceleration is higher than the stablish level. | |
float | update_rocket_altitude_mean (float rocket_altitude, float *altitude_mean_array, int *oldest_element_pointer) |
Create a mobile mean to filter rocket altitude. | |
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. | |
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. | |
bool | detect_touchdown (mpu6050_acceleration_t rocket_acc) |
Detect if the rocket has landed. | |
void | flight_controller () |
Main FreeRTOS task function for the flight controller. |
Variables | |
QueueHandle_t | xSensorQueue |
QueueHandle_t | xUpdatedStatusFromFlightController |
bool detect_liftoff | ( | mpu6050_acceleration_t | rocket_acc | ) |
Detect if liftoff has happen. Works by detecting if the currect linear acceleration is higher than the stablish level.
rocket_acc | linear acceleration. |
bool detect_touchdown | ( | mpu6050_acceleration_t | rocket_acc | ) |
Detect if the rocket has landed.
Touchdown is detected when any of the axes linear acceleration data detects an acceleration grater than what is set in ACCELERATION_THRESHOLD_FOR_TOUCHDOWN_DETECTION.
rocket_acc | linear acceleration data. |
void flight_controller | ( | ) |
Main FreeRTOS task function for the flight controller.
Evaluates rocket status and determines when to deploy the drogue chute and the main chute based on the data available from the rocket sensors.
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.
It takes into acount:
altitude_mean | current altitude mean value. |
highest_altitude_mean_detected | biggest recorded mean value. |
ms | current milliseconds. |
ms_liftoff | milliseconds when liftoff happened. |
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.
It takes into acount:
mean_altitude | current altitude mean value. |
launching_altitude | altitude recorded when liftoff occurred. |
ms | current milliseconds. |
ms_liftoff | millisecconds when liftoff occurred. |
float update_rocket_altitude_mean | ( | float | rocket_altitude, |
float * | altitude_mean_array, | ||
int * | oldest_element_pointer ) |
Create a mobile mean to filter rocket altitude.
rocket_altitude | calculated rocket altitude. |
altitude_mean_array | pointer to where all the values for the mean mobile are being stored. |
oldest_element_pointer | pointer to the oldest altitude reading. |
|
extern |
|
extern |