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.

For details on implementation, refer below.

How does Waypoint/Path Management Work?

Note that a lot of this information in this section comes from the PicPilot docs, which was last updated on January 6, 2016.

...

Ensure that the radius input is greater than 0 and that the turn direction is either -1 or 1. If the parameters are incorrect, then the get_next_directions() method will return INVALID_PARAMETERS (equal to 4) and will result in the output data not being updated. (NB: Work will be done to handle this case so the plane does not fly aimlessly)

In all cases, to exit the holding pattern, call the start_circling() method and pass in true as the cancelTurning parameter.

...

As for return values, when the goingHome parameter is set to true, the method returns true. If it is set to false, then it returns false. (NB: Work will be done to make this an enum so there is no ambiguity between errors and setting the parameter to false)

When this method is called, the waypointBuffer is cleared and the goingHome parameter is set to true. Afterwards, the state machine should call get_next_directions() as normal.

...

This section basically just gives a “summary” of how the state machine will interact with the waypoint manager.

Public Functions

All public functions and their basic tasks are included below:

  1. WaypointManager() → constructor

  2. _WaypointStatus initialize_flight_path() → initialize flight path (overloaded)

  3. _PathData * initialize_waypoint() → initialize waypoint (overloaded)

  4. _WaypointStatus get_next_directions() → updates _WaypointManager_Data_Out structure with desired heading, altitude, etc.

    • void start_circling() → puts plane in hold pattern

      Can be called to exit hold pattern

    • bool head_home()

      Empties waypointBuffer array and tells manager to take plane to homeBase

      Makes plane return to following waypointBuffer array

  5. _WaypointStatus change_current_index() → changes index of current waypoint

  6. _WaypointStatus update_path_nodes() → called if you want to update the flight path

  7. void clear_path_nodes() → empties waypointBuffer array (DANGER)

  8. _PathData** get_waypoint_buffer() → returns the waypointBuffer array

  9. _WaypointBufferStatus get_status_of_index() → returns the status of an index in the waypointBuffer array (FREE [0] means empty, FULL [1] means not empty)

  10. int get_current_index() → gets currentIndex parameter of WaypointManager class

  11. int get_id_of_current_index() → returns the id of the waypoint that is in waypointBuffer[currentIndex]

  12. _PathData * get_home_base() → returns the homeBase parameter of the WaypointManager class

Initializing WaypointManager Object

Method(s) you care about: 1

What to pass in:

  • Latitude and longitude of point used as origin for cartesian coordinate calculations

    • UWaterloo coordinates:

      • Lat: 43.467998128

      • Long: -80.537331184

Initializing Waypoints

Method(s) you care about: 3

What to pass in: refer above

Initializing Flight Path

Method(s) you care about: 2

What to pass in: refer above

Getting Next Directions

Method(s) you care about: 4

What to pass in: refer above

Modifying Flight Path

Method(s) you care about: 6, 7

What to pass in: refer above

Changing Current Waypoint

Method(s) you care about: 5

What to pass in: refer above

Status Methods

Method(s) you care about: 8, 9, 10, 11, 12

What to pass in: (This is method-dependent)

  • _WaypointBufferStatus get_status_of_index() → pass in index of wayponitBuffer array you care about

Error Codes and What they Mean

Useful resources