Modifying Preplanned Trajectory

Overview

For users that need more flexibility than editing the .plan file, the preplanned trajectory runner has several places where sample code has been inserted in the code to show the Experimenters how to safely modify the code to achieve their desired outcome.

The finite state machine for the preplanned trajectory runner has the structure shown in the figure to the right. To clearly delineate and expose the hooks for the Experimenter code, the runner has a special command line argument --ping that activates the sample ping code in several states.

Changing the code

The runner starts two independent processes, namely the foreground process that starts with the takeoff state, and the background process that executes continuously in the background, independent of what is happening in the foreground. By default the background state periodically dumps the status of the drone in a .csv log file. The takeoff sets the default speed for the drone and the rover, and if the vehicle is a drone, it will initiate a take-off at the altitude specified in the .plan file.

After the takeoff is complete, the runner reads sequentially each waypoint in the .plan file and takes the vehicle to the next waypoint, while exposing two intermediate states before looping back to the next_waypoint:

  • in_transit is a state that is active while the vehicle is moving from the previous waypoint to the next waypoint. Sample code for activities to be performed while in_transit is provided (including parsing the results of the said activities).

  • at_waypoint state is entered once the the vehicle reached the next_waypoint. Once again, sample code for activities to be performed while at_waypoint is provided. By default, the vehicle waits at_waypoint the duration specified in the .plan file. After the time elapses, and the activities complete, the system transitions back to reading the next_waypoint.

After the last waypoint in the .plan file, or upon encountering an RTL (return to launch) command, the system transitions in the last state, called rtl in the code. Note that the code executing in this state does not change the mode of the vehicle to RTL, but rather performs a guided return to the home position, followed by a LAND command.