IZAR Flight Controller 1.0.0
IZAR Flight Controller running with an ESP32.
flight_controller.c File Reference
#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>
Include dependency graph for flight_controller.c:

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

Function Documentation

◆ detect_liftoff()

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.

Parameters
rocket_acclinear acceleration.
Returns
true if liftoff has been detected.
false if there is not enough acceleration to consider liftoff.
Here is the caller graph for this function:

◆ detect_touchdown()

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.

Parameters
rocket_acclinear acceleration data.
Returns
true if landing has been detected.
false if landing has not been detected.
Here is the caller graph for this function:

◆ flight_controller()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ should_drogue_chute_be_deployed()

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:

  1. The flight time must be between the stablish window for drogue chute deployment. The chute will be deployed if time exceeds the maximum time set in MAX_MS_DROGUE_DEPLOYMENT.
  2. The difference between the biggest recorded mean altitude value (apogee) and the current mean altitude value should be of at least what defined in ALTITUDE_DIFFERENCE_TO_CONSIDER_APOGEE.
Parameters
altitude_meancurrent altitude mean value.
highest_altitude_mean_detectedbiggest recorded mean value.
mscurrent milliseconds.
ms_liftoffmilliseconds when liftoff happened.
Returns
true if sweet spot for drogue chute deployment has occurred now or in the past.
false if sweet spot for drogue chute deployment has not occurred yet.
Here is the caller graph for this function:

◆ should_main_chute_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.

It takes into acount:

  1. The flight time must be between the stablish window for main chute deployment. The chute will be deployed if time exceeds the maximum time set in MAX_MS_MAIN_DEPLOYMENT.
  2. The difference between the current mean altitude and the launching altitude value should be less than what is defined in MAIN_CHUTE_DEPLOYMENT_HEIGHT.
Parameters
mean_altitudecurrent altitude mean value.
launching_altitudealtitude recorded when liftoff occurred.
mscurrent milliseconds.
ms_liftoffmillisecconds when liftoff occurred.
Returns
true if sweet spot for main chute deployment has occurred now or in the past.
false if sweet spot for main chute deployment has not occurred yet.
Here is the caller graph for this function:

◆ update_rocket_altitude_mean()

float update_rocket_altitude_mean ( float rocket_altitude,
float * altitude_mean_array,
int * oldest_element_pointer )

Create a mobile mean to filter rocket altitude.

Parameters
rocket_altitudecalculated rocket altitude.
altitude_mean_arraypointer to where all the values for the mean mobile are being stored.
oldest_element_pointerpointer to the oldest altitude reading.
Returns
float new mobile mean.
Here is the caller graph for this function:

Variable Documentation

◆ xSensorQueue

QueueHandle_t xSensorQueue
extern

◆ xUpdatedStatusFromFlightController

QueueHandle_t xUpdatedStatusFromFlightController
extern