GNC Recruitment Assignment
In this assignment, the goal is to create an algorithm able to detect the apogee of the rocket during a generic flight and command the opening of the parachute.
The file main.m
loads the logs of a previous flight and then simulates said flight:
The first part of the script loads the logs of the sensors of a previous flight which will be then used for the simulation.
The second part replicates how the on-board software interacts with the sensors: at each iteration the script gets new sensor measurements and passes them to the function apogee_detector.m
, which has the job to detect when the apogee is reached and, on the real rocket, command the expulsion of the parachute.
The available sensor measurements come from a barometer, a 6-axis IMU (accelerometer and gyroscope) and a GPS.
The flight phases contained in the log are:
- rocket on the ramp
- ascent phase
- descent phase
The third part of the script is used just to plot the result and display the apogee detection.
Your task is to develop the function apogee_detector.m
:
function [ flag_apogee, data] = apogee_detector( pressure_measurment, IMU_measurment, GPS_measurment, data)
% insert your code here
which uses the data measured in real time during the flight as input and outputs the boolean variable flag_apogee
, which must be:
- 1 during the instants where the rocket is considered to be at the apogee
- 0 otherwise
How to submit your assignment
To submit your assignment, prepare a .zip file named "SURNAME_NAME" containing the apogee_detector.m file and any other file you modified and upload it to the google form written in the email you received. NOTE: You do not need to include the .csv files
How to organize the work
To organize the work, it's suggested to divide it in 2 tasks:
- Define the condition that detects the apogee: the apogee is defined as the highest point of the trajectory, but this definition is not applicable during the flight. Sensors have noise, so, instead of detecting the exact instant of the apogee, it suggested to define a robust condition that, if true, allows to deduce with confidence that that the rocket is reasonably near the apogee. Finding the condition/conditions is part of the assignment. (For example, the function detects the apogee when the altitude is greater than 2700m. This condition define a zone that, in the logged flight, is near the apogee... but what happens if the rocket never reaches 2700m ? Or if at that altitude it is still moving with high vertical speed? This condition might work for this flight, but is not reliable in a general case and it is considered a bad choice. )
-
Implement an algorithm that detects the apogee: starting from the condition found in the previous point, implement an algorithm in
apogee_detector.m
that detects the apogee.
Algorithm requirements
This algorithm is safe critical, because the detection of the apogee commands the expulsion of the parachute. The algorithm that you will develop should be resilient and work even in off nominal conditions where:
- the apogee altitude might change from the one contained in the logs, depending on the flight conditions. The motor might under-perform or over-perform with respect to the nominal condition, so it not possible to define a priori the exact altitude of the apogee. In addition, the target apogee height could also change from flight to flight.
- the trajectory of the rocket may change from the one contained in the logs. Wind or other external phenomenons will slightly change the trajectory. Also, launches with different target apogee altitudes (a.e 3 Km vs 9 Km) will have different trajectories.
- sensors measurements are not perfect. As said before, sensors are subjected to noise and delays which alter the measurements. This phenomenon is also visible from the logs.
To take into account these factors, the function that you will submit will be tested with the logs of a different flight.
Input variables
data: it is a support variable that you can use if and however you want, for example it could store previous sensors measurements or counters. It is declared inside main.m
; if you want to use it you have to declare it there, otherwise you can just leave it as it is.
timestamp: the timestamp present in each log is expressed in microseconds (us)
pressure_measurement: the barometer is used to measure the atmospheric pressure during the flight
pressure |
---|
Pa |
IMU_measurement: the reference axis are the body-axis of the rocket (shown in the picture below).
acceleration_X | acceleration_Y | acceleration_Z | angular_speed_X | angular_speed_Y | angular_speed_Z |
---|---|---|---|---|---|
m/s^2 | m/s^2 | m/s^2 | rad/s | rad/s | rad/s |
GPS_measurement:
latitude | longitude | altitude (from sea level) |
---|---|---|
decimal degrees | decimal degrees | meters |