# Local Navigation

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

The local navigation interface allows you to send measurements of your drone's local position to the FMU.

## Instantiation

You can instantiate a local navigation interface by instantiating an object of type `auterion::LocalNavigationInterface`:

```cpp
auterion::LocalNavigationInterface nav_interface(sdk);
```

The interface provides an `update` method which expects a `LocalPositionMeasurement` object as an argument, and which sends your position measurements to the state estimator of the FMU.

## Local Position Measurements

To send local position measurements, you must first build a `LocalPositionMeasurement` object and fill in the fields you want to send updates for. A `LocalPositionMeasurement` object holds the following fields:

* The timestamp of your measurement sample
* A 3D position (in meters, ENU frame)
* The position error variance (in m²)
* A 3D velocity (in meters, ENU frame)
* The velocity error variance (in m²)
* An attitude quaternion (Hamiltonian convention)
* The attitude error variance (in rad²)

To instantiate a local position measurement, you need to provide the time at which the measurement was captured:

```cpp
rclcpp::Time measurement_time = ...
auterion::LocalPositionMeasurement my_measurement(measurement_time);

// Optionally the measurement time can be left empty
// which will default the measurement time to the current time
auterion::LocalPositionMeasurement my_other_measurement();
```

The `LocalPositionMeasurement` class then provides builder methods to populate your measurement instance with the data that you have collected. You can choose which builder methods to call depending on which states you have measured:

{% code fullWidth="false" %}

```cpp
// Collected measurement fields
Eigen::Vector3f position = Eigen::Vector3f {0.2F, 0.1F, 3.0F};
Eigen::Vector3f position_variance = Eigen::Vector3f {0.05F, 0.08F, 0.1F};
Eigen::Vector3f velocity = Eigen::Vector3f {0.8F, 0.7F, 0.1F};
Eigen::Vector3f velocity_variance = Eigen::Vector3f {0.07F, 0.06F, 0.03F};
Eigen::Quaternionf attitude = Eigen::Quaternionf {0.1F, -0.2F, 0.3F, 0.25F};
Eigen::Vector3f attitude_variance = Eigen::Vector3f {0.02F, 0.02F, 0.02F};

// Populate measurement with measured fields
my_measurement = my_measurement.withPosition(position, position_variance)
                               .withVelocity(velocity, velocity_variance)
                               .withAttitude(attitude, attitude_variance);

// Populate measurement with only a position
my_pos_measurement = my_pos_measurement.withPosition(position, position_variance);

// Alternatively, for local position you may specify just
// the horizontal or vertical components
my_pos_hor_measurement = my_pos_hor_measurement.withPositionHorizontal(
                               position.head<2>(), position_variance.head<2>());
my_pos_ver_measurement = my_pos_ver_measurement.withPositionVertical(
                               position.z(), position_variance.z());

// Populate measurement with only a velocity
my_vel_measurement = my_vel_measurement.withVelocity(velocity, velocity_variance);

// Populate measurement with only an attitude
my_att_measurement = my_att_measurement.withAttitude(attitude, attitude_variance);

// Optionally the variance field can be left empty if unknown
my_imprecise_measurement = my_imprecise_measurement.withPosition(position)
                                                   .withVelocity(velocity)
                                                   .withAttitude(attitude); 
```

{% endcode %}

## Sending Measurements

You can now send your local position measurement by simply calling the interface's `update` method:

```cpp
nav_interface.update(my_measurement);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.auterion.com/app-development/auterion-sdk/navigation-input-api/local-navigation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
