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:
...
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.
Useful resources
http://www.movable-type.co.uk/scripts/latlong.html#destPoint
This link came in clutch to understand the calculations that go behind some of the stuff.
PICpilot waypoint manager