Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

...

  • Desired Heading

  • Desired Altitude

  • Distance to next waypoint

...

This is the structure that will be outputted:

Code Block
languagecpp
enum _WaypointStatus {WAYPOINT_SUCCESS = 0, WAYPOINT_NOT_FOUND, WAYPOINT_PARAMETERS_NOT_DEFIND, UNDEFINED_FALIURE};

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;

Steps Executed when Module is Called

There are two different processes that this module executes: calculating desired heading and altitudes, and modifying the waypointBuffer array.

Calculating Desired Heading and Altitude:

Code Block
languagecpp
/*
* Public Function!!
* @param _Gps_Data currentPosition -> contains the current coordinates, altitude, and heading
*/
void get_next_directions(_Gps_Data currentPosition); //Updates the _WaypointManager_Data structure with new values
  1. State machine calls the above method and passes in appropriate parameters.

Modifying waypointBuffer Array:

  1. State machine calls update_path_nodes() and passes in parameters along with specifying the modification type via the _WaypointBufferUpdateType enum.

  2. update_path_nodes() calls the appropriate private function and that function updates the waypointBuffer array.