Guidance#

Description#

../_images/guidance.png

Guidance is in charge of trajectory generation for the drone and the cameras (front and stereo).

The generation of those trajectories is implemented in guidance::Mode class corresponding to different behaviours. For example the built-in FlightPlan mode will generate the trajectories that the drone will follow. As well as the orientation of the cameras, given the list of waypoints and view modes. Guidance modes are enabled/disabled by the Flight supervisor. Only one can run at a given time.

Each Guidance mode has three major steps:

  1. Trajectory generation for horizontal and vertical translation

  2. Trajectory correction using obstacle avoidance

  3. Trajectory generation for cameras and drone yaw orientation

It is not mandatory to implement all of them. For example, Guidance modes can choose not to implement the trajectory correction. When no trajectory is specified, the drone keeps its previous one.

How to write a Guidance mode#

A Guidance mode can be written either in C++ or Python.

C++ modes are generated as .so files on build, while Python modes are copied from source, the latter format uses the .py extension.

Each Guidance mode implements an object that inherits from the guidance::Mode class.

The following class methods must be implemented:

guidance::Mode::getName()

guidance::Mode::getTriggers()

The following class methods are optional:

guidance::Mode::configure()

guidance::Mode::enter()

guidance::Mode::exit()

guidance::Mode::beginStep()

guidance::Mode::endStep()

guidance::Mode::generateDroneReference()

guidance::Mode::correctDroneReference()

guidance::Mode::generateAttitudeReferences()

Each Guidance mode must fill the output structure containing the drone and camera trajectories, as well as camera axis configuration and drone position and velocity targets: guidance::Output class

Sample#

See Hello Guidance mode.

How to switch between Guidance modes#

To switch from one Guidance mode to another, call set_guidance_mode() function from the class fsup.genstate.State containing a string with the name of the chosen Guidance mode. An event ModeChanged is received once the switch is done.

See Hello Flight supervisor state machine.

Messages#

Guidance handles Commands and sends Events to Flight supervisor.