Overview
This module determines the desired heading and altitude of the aircraft and manages the waypoints (also called “path nodes”) of the plane’s flight path. The module takes in GPS coordinates and altitude measurements and calculates the heading and altitude the plane needs to stay on course. Additionally, the module takes instructions from the state machine to modify the waypoints in the plane’s flight path.
...
Figuring out where the tangent will touch requires some basic trigonometry. [WILL TOUCH ON LATER]. The coordinates at which this occurs can be calculated using:
...
These functions are executed by calling the following function. Note that not all parameters will be used for each modification to the waypointBuffer array. The goal of this function is to call the appropriate function listed above and pass in the required data.
Code Block | ||
---|---|---|
| ||
enum _WaypointBufferUpdateType {ADD_WAYPOINT = 0, UPDATE_WAYPOINT, INSERT_WAYPOINT, DELETE_WAYPOINT}; /** * Adds, inserts, updates, or deletes a single waypoint in the waypointBuffer array * * @param[in] _PathData* waypoint -> In the instance that we need to update, insert, or append a new waypoint, this will be used * @param[in] _WaypointBufferUpdateType updateType -> the type of modification to the waypointBuffer array (look above) * @param[in] numWaypoints -> number of waypoints that are in the waypoint array (will be 1 for insertion, updating, and deleting). May be greater than 1 for appending * @param[in] int waypointId -> the ID of the waypoint that will be updated or deleted. Set to 0 by default, so does not need to be passed (not needed for appending or insertion) * @param[in] int previousId -> stores the ID of the waypoint that will come before the inserted waypoint. Set to 0 by default, so does not need to be passed (only needed for insertion) * @param[in] int nextId -> stores the ID of the waypoint that will come after the inserted waypoint. Set to 0 by default, so does not need to be passed (only needed for insertion) */ void update_path_nodes(_PathData* waypoint, _WaypointBufferUpdateType updateType, int numWaypoints, int previousId = 0, int nextId = 0, int waypointId = 0);The ID System |
The Waypoint ID System
The waypoint management module is not responsible for creating new waypoints. Instead, the state machine will send waypoints to the waypoint management system and the module will initialize/update the waypointBuffer array accordingly.
...
Code Block | ||
---|---|---|
| ||
enum _WaypointStatus {WAYPOINT_SUCCESS = 0, WAYPOINT_NOT_FOUND, WAYPOINT_PARAMETERS_NOT_DEFIND, UNDEFINED_FALIURE}; /** * Structure contains the data that will be returned to the Path Manager state manager. * This data will be used by the PID and coordinated turn engine to determine the commands to be sent to the Attitude Manager. */ typedef struct { uint16_t desiredHeading; // Desired heading to stay on path int desiredAltitude; // Desired altitude at next waypoint long double distanceToNextWaypoint; // Distance to the next waypoint (helps with airspeed PID) _WaypointStatus errorCode; // Contains error codes bool isDataNew; // Notifies PID modules if the data in this structure is new uint32_t timeOfData; // The time that the data in this structure was collected } _WaypointManager_Data_Out; |
...
State machine calls the
get_next_directions()
and passes in appropriate parameters (GPS data and pointer to the output data structure).Algorithm stuff [ADD LATER]
Waypoint manager updates the parameters in the
_WaypointManager_Data_Out
structure that was passed intoget_next_directions()
.
...