#include "sensors_reading/mpu6050/mpu6050_c.h"
#include <inttypes.h>
#include <stdbool.h>
Go to the source code of this file.
◆ ACCELERATION_THRESHOLD_FOR_LIFTOFF_DETECTION
#define ACCELERATION_THRESHOLD_FOR_LIFTOFF_DETECTION 2.0 |
◆ ACCELERATION_THRESHOLD_FOR_TOUCHDOWN_DETECTION
#define ACCELERATION_THRESHOLD_FOR_TOUCHDOWN_DETECTION 2.0 |
◆ ALTITUDE_DIFFERENCE_TO_CONSIDER_APOGEE
#define ALTITUDE_DIFFERENCE_TO_CONSIDER_APOGEE 1 |
◆ MAIN_CHUTE_DEPLOYMENT_HEIGHT
#define MAIN_CHUTE_DEPLOYMENT_HEIGHT 150.0 |
◆ MAX_MS_DROGUE_DEPLOYMENT
#define MAX_MS_DROGUE_DEPLOYMENT 1300 |
◆ MAX_MS_MAIN_DEPLOYMENT
#define MAX_MS_MAIN_DEPLOYMENT 35000 |
◆ MIN_MS_DROGUE_DEPLOYMENT
#define MIN_MS_DROGUE_DEPLOYMENT 9500 |
◆ MIN_MS_MAIN_DEPLOYMENT
#define MIN_MS_MAIN_DEPLOYMENT 20000 |
◆ MS_EXECUTING_CHUTE_CHARGES
#define MS_EXECUTING_CHUTE_CHARGES 1000 |
◆ TAG_FLIGHT_CONTROLLER
#define TAG_FLIGHT_CONTROLLER "Flight Controller" |
◆ WINDOW_SIZE_FOR_ALTITUDE_MEAN
#define WINDOW_SIZE_FOR_ALTITUDE_MEAN 10 |
◆ detect_liftoff()
Detect if liftoff has happen. Works by detecting if the currect linear acceleration is higher than the stablish level.
- Parameters
-
rocket_acc | linear acceleration. |
- Returns
- true if liftoff has been detected.
-
false if there is not enough acceleration to consider liftoff.
◆ detect_touchdown()
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_acc | linear acceleration data. |
- Returns
- true if landing has been detected.
-
false if landing has not been detected.
◆ 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.
◆ 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:
- 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.
- 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_mean | current altitude mean value. |
highest_altitude_mean_detected | biggest recorded mean value. |
ms | current milliseconds. |
ms_liftoff | milliseconds 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.
◆ 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:
- 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.
- 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_altitude | current altitude mean value. |
launching_altitude | altitude recorded when liftoff occurred. |
ms | current milliseconds. |
ms_liftoff | millisecconds 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.
◆ 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_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. |
- Returns
- float new mobile mean.