> For the complete documentation index, see [llms.txt](https://docs.auterion.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.auterion.com/app-development/auterion-sdk/flight-mode-api/fixed-wing-modes/guidance-control.md).

# Guidance Control

{% hint style="info" %}
Requires APX4 3.4 or newer. If using APX 3.3, these inputs are part of the DynamicsSetpoint
{% endhint %}

Fixed Wing Guidance Mode allows you to control a Fixed Wing by supplying altitude and course setpoints to the controller in the world frame.

{% hint style="info" %}
For a detailed explanation of the implementation of this setpoint in PX4, see the [upstream documentation](https://docs.px4.io/main/en/ros2/px4_ros2_control_interface.html#fixed-wing-lateral-and-longitudinal-setpoint-fwlaterallongitudinalsetpointtype).
{% endhint %}

## Set up mode

In order to prepare your flight mode to accept `GuidanceSetpoint`, you need to supply the `auterion::fixedwing::GuidanceSetpoint::Config` object to your mode constructor like so:

```cpp
auterion::Mode my_mode(sdk, "My Mode", {
    auterion::fixedwing::GuidanceSetpoint::Config{}
});
```

## Create setpoints

`GuidanceSetpoint` setpoints can take altitude (amsl), height rate, equivalent airspeed, course and lateral acceleration as arguments.

To control the vehicle, at least one lateral **and** one longitudinal setpoint must be provided:

1. Of the longitudinal inputs: either altitude or height\_rate must be set to control vertical motion.\
   If both are finite, the **altitude setpoint is ignored.**
2. Of the lateral inputs: you must set a course setpoint. Additionally, you can supply a feedforward acceleration.

The equivalent airspeed setpoint will only be used when the vehicle is equipped with an airspeed sensor.

To create a setpoint, you can use the builder pattern like so:

```cpp
auto setpoint = auterion::fixedwing::DynamicsSetpoint{}
    .withAltitude(amsl)
    .withEquivalentAirspeed(equivalent_airspeed)
    .withCourse(course, lat_acc_ff) // course in rad
```

To ensure the drone follows your setpoints, return these setpoints in the `onUpdateSetpoint` callback method of your mode.
