# Go-To in Local Frame

{% hint style="info" %}
Related C++ Header in the Auterion SDK:`<auterion_sdk/control/control.hpp>`
{% endhint %}

Local Frame Goto Mode allows you to control a multicopter by continuously supplying a target position value where you want the vehicle to go to. The multicopter automatically does a smooth acceleration and deceleration trajectory to arrive at the specified target, or will change course to keep following a moving target.

## Set up mode

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

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

## Create setpoints

`LocalFrameGotoSetpoint` setpoints take either a 3D position, or a 2D position + altitude as well as desired heading value. The vehicle then does a smooth trajectory towards the specified position.

Additionally, `LocalFrameGotoSetpoint` setpoints may take speed limits for horizontal, vertical, and heading rate. These specifications determine the maximum allowable speeds when moving towards the setpoint.

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

```cpp
auto setpoint = auterion::multicopter::LocalFrameGotoSetpoint{}
    .withPosition({x, y})  // possible overload: withPosition({x, y, z})
    .withAltitude(z)
    .withHeading(h)
    .withMaxHorizontalSpeed(max_xy)
    .withMaxVerticalSpeed(max_z)
    .withMaxHeadingRate(max_h);
```

Also any subset of these values is permitted. In order to make the drone follow your setpoints, return these setpoints in the `onUpdateSetpoint` callback method of your mode.

### Setting default speed limits

While you can specify the speed limit for each setpoint, you can also specify **default limits** to be respected by every goto setpoint defined in your mode. You can still provide a speed limit for specific setpoints, which will overwrite the corresponding default speed limit.

To achieve this, you need to supply a `auterion::multicopter::GotoControlLimits` to your goto setpoint configurator like so:

<pre class="language-cpp"><code class="lang-cpp">auto goto_limits = auterion::multicopter::GotoControlLimits{}
    .withMaxHorizontalSpeed(max_xy)
    .withMaxVerticalSpeed(max_z)
    .withMaxHeadingRate(max_h);

// Instantiate your mode to control goto setpoints
// configured with the default speed limits above  
auterion::Mode my_mode(sdk, "My Mode", {
<strong>    auterion::multicopter::LocalFrameGotoSetpoint::Config{goto_limits}
</strong>});
</code></pre>
