Autonomous flight#

There are three ways of implementing autonomous flight:

  1. Reuse built-in Guidance modes: Move To / Relative move / FlightPlan

  2. Write a semi-custom Guidance mode inheriting from generic trajectory (TrajectoryFcamMode, TrajectoryStcamMode)

  3. Write a full-custom Guidance mode

1. Reuse built-in Guidance modes#

You can use the following autonomous Guidance modes:

Move To: Give the drone a GPS destination coordinates and a target heading orientation.

Relative Move: Give the drone a distance to travel from current position and a yaw angle to reach from current yaw attitude.

FlightPlan: Give the drone a list of waypoints to reach. The waypoint list can be modified dynamically (How to update a FlightPlan dynamically).

Note

Waypoints can not be updated more than once per second. If a new waypoint update request is received faster than this, it will be delayed.

These three modes can be selected by using the set_guidance_mode() command. It includes trajectory correction by using built-in obstacle avoidance algorithms, which can be disabled if needed (using oa_manager).

2. Write a semi-custom Guidance mode inheriting from generic trajectory#

TrajectoryFcamMode from guidance::TrajectoryFcamMode class: Create a trajectory from drone 3D position and front camera 3D orientation inputs. Drone yaw angle and stereo camera orientation are automatically generated from the created trajectories. Obstacle avoidance can be activated to correct the generated trajectory.

TrajectoryStcamMode from guidance::TrajectoryStcamMode class: Create a trajectory from drone 3D position and stereo camera 3D orientation inputs. Drone yaw angle and front camera orientation are automatically generated from the created trajectories. Obstacle avoidance can’t be activated in this mode.

Trajectory points can be generated at a frequency up to 33 Hz in both modes.

It is required to call TrajectoryFcamMode or TrajectoryStcamMode base function at the beginning of each overridden method:

GdncModeExample::GdncModeExample(guidance::Guidance *guidance)
    : TrajectoryFcamMode(guidance, "com.company.missions.mymission.mymode"){}

void GdncModeExample::enter()
{
    TrajectoryFcamMode::enter();
    ...
}

void GdncModeExample::beginStep()
{
    TrajectoryFcamMode::beginStep();
    ...
}

void GdncModeExample::endStep()
{
    TrajectoryFcamMode::endStep();
    ...
}

void GdncModeExample::exit()
{
    TrajectoryFcamMode::exit();
    ...
}

Important

These mode templates limit the horizontal and vertical speed when the obstacle avoidance is enabled. Some methods are available to know the maximum horizontal, descent and ascent speeds:

TrajectoryFcamMode
TrajectoryStcamMode

3. Write a full-custom Guidance mode#

The drone 3D position, the front camera and the stereo camera 3D orientation trajectories are fully implemented by the developer (How to write a Guidance mode). Built-in obstacle avoidance can’t be used if you choose to write a full-custom guidance mode. However, occupancy grid and depthmap values can be used to implement your obstacle avoidance algorithm.