# GNC Recruitment Assigment

In this assigment, the goal is to create a function to detect the apogee of the rocket during the flight and comand the opening of the parachute.

The file `main.m` load the logs of a previous flight and then simulates the flight of the rocket. The first part of the script logs 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 measurments and pass them to the function `apogee_detector.m`, which detects the apogee and, on the real rocket, commands the explultion of the parachute. The avaliable sensor measurments are a barometer, a 6-axis IMU (accelerometer and gyroscope) and a GPS.

The third part is used just to plot the result and display the apogee detection.

Your task is to develop the function `apogee_detector.m` :

```matlab
function [ flag_apogee, data] = apogee_detector( pressure_measurment, IMU_measurment, GPS_measurment, data)

% insert your code here
```

which uses the datas measured during the flight as input and outputs the boolean variable `flag_apogee`, which must be:

* 1  if the function detecs the apogee
* 0 otherwise

**data:** it is a support variable that you can use if and however you want. 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.

**pressure_measurment:** the barometer is used to measure the atmosferic pressure during the flight

| pressure |
| :------: |
|    Pa    |

**IMU_measurment:** the reference axis are the body-axis of the rocket. 

| 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_measurment:** 

|    latitude    | longitude       | altitude (from sea level) |
| :-------------: | --------------- | :-----------------------: |
| decimal degrees | decimal degrees |          meters          |