> ## Documentation Index
> Fetch the complete documentation index at: https://docs.generalrobotics.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# MavlinkDrone

## MavlinkDrone

Inherits from: [`AerialDrone`](/robot-api/reference/base/robot/aerial_drone/AerialDrone)

*No class docstring.*

### Inherited methods

* From [`Robot`](/robot-api/reference/base/robot/robot/Robot): `addSensor`, `getImage`, `cleanup`

### **init**

```python theme={null}
MavlinkDrone.__init__(config_file: Optional[str] = None, ground_control_station_ip: Optional[str] = None, mavlink_port: Optional[str] = None, vehicle_ip: Optional[str] = None, communication_protocol: Optional[str] = None, camera_streams: Optional[Dict[str, Dict[str, Any]]] = None, arm_enable: Optional[bool] = None, dry_run: Optional[bool] = None, offboard_control_mode_int: Optional[int] = None, velocity_limit: float = 1.0, messages_known: Optional[List[str]] = None, messages_required: Optional[List[str]] = None)
```

Instantiates a MavlinkDrone containing a MavlinkClient for sending commands to the real drone.

Additionally sets up a video stream manager for handling RTSP streams from the drone.

If a config file is provided (a JSON file), then any parameters not explicitly provided (i.e. left as None)
will be loaded from the config file (or fallback to the client's own defaults). Otherwise, default values
are used.

<ResponseField name="Arguments">
  <ParamField query="config_file (Optional[str])" type="Optional[str]">
    Path to a JSON config file with parameter overrides.
  </ParamField>

  <ParamField query="ground_control_station_ip (Optional[str])" type="Optional[str]">
    IP address of the ground control station. (default: "192.168.8.10")
  </ParamField>

  <ParamField query="mavlink_port (Optional[str])" type="Optional[str]">
    Port number for the MAVLink connection. (default: "14550")
  </ParamField>

  <ParamField query="vehicle_ip (Optional[str])" type="Optional[str]">
    IP address of the vehicle. (default: "192.168.8.1")
  </ParamField>

  <ParamField query="communication_protocol (Optional[str])" type="Optional[str]">
    Communication protocol, one of ("udp"|"tcp"). (default: "udp")
  </ParamField>

  <ParamField query="camera_streams (Optional[Dict[str, Dict[str, Any]]])" type="Optional[Dict[str, Dict[str, Any]]]">
    Dictionary mapping camera stream names to configuration.
  </ParamField>

  <ParamField query="arm_enable (Optional[bool])" type="Optional[bool]">
    Whether to enable arming the drone. (default: False)
  </ParamField>

  <ParamField query="dry_run (Optional[bool])" type="Optional[bool]">
    Whether to run in dry run mode bypassing arming exceptions. (default: False)
  </ParamField>

  <ParamField query="offboard_control_mode_int (Optional[int])" type="Optional[int]">
    *No description provided.*
  </ParamField>

  <ParamField query="velocity_limit (float)" type="float">
    Maximum velocity limit for the drone in m/s. (default: 1.0)
  </ParamField>

  <ParamField query="messages_known (Optional[List[str]])" type="Optional[List[str]]">
    *No description provided.*
  </ParamField>

  <ParamField query="messages_required (Optional[List[str]])" type="Optional[List[str]]">
    *No description provided.*
  </ParamField>
</ResponseField>

### getPosition

```python theme={null}
MavlinkDrone.getPosition() -> Position
```

Get the current position of the drone with respect to the world coordinate.

<ResponseField name="Returns">
  <ResponseField name="Position" type="Position">
    Position type which internally contains X, Y, Z position in meters with respect to the world coordinate
  </ResponseField>
</ResponseField>

### getVelocity

```python theme={null}
MavlinkDrone.getVelocity() -> Velocity
```

Get the current velocity of the drone with respect to the world coordinate.

<ResponseField name="Returns">
  <ResponseField name="Velocity" type="Velocity">
    Velocity type which internally contains VX, VY, VZ velocity in meters/s
  </ResponseField>
</ResponseField>

### getYaw

```python theme={null}
MavlinkDrone.getYaw() -> float
```

Return the current yaw of the drone in radians. Yaw measures the rotation of the drone around the z axis of the aeronautical frame

(right-handed, X front, Y right, Z down)

<ResponseField name="Returns">
  <ResponseField name="float" type="float">
    yaw of the drone in radians \[-pi, +pi]
  </ResponseField>
</ResponseField>

### getOrientation

```python theme={null}
MavlinkDrone.getOrientation() -> Orientation
```

Return the current Orientation of the drone, these are internally stored as a quaternion (x, y, z, w) where w is the scalar component.

These can be mapped to the euler angles in the aeronautical frame (right-handed, X front, Y right, Z down).

<ResponseField name="Returns">
  <ResponseField name="Orientation" type="Orientation">
    Current orientation of the drone in Orientation type
  </ResponseField>
</ResponseField>

### setYaw

```python theme={null}
MavlinkDrone.setYaw(yaw: float) -> None
```

Set the yaw (in radians) of the drone to the specified position. Yaw measures the

rotation of the drone around the z-axis (downwards). The yaw is wrapped to stay
within \[-pi, pi].

<ResponseField name="Arguments">
  <ParamField query="yaw (float)" type="float" required>
    the target yaw (radians) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### setYawDelta

```python theme={null}
MavlinkDrone.setYawDelta(yaw_delta: float) -> None
```

Set a yaw delta (in radians) for the drone to rotate to. Yaw measures the

rotation of the drone around the z-axis (downwards). The resulting yaw will be
wrapped to stay within \[-pi, pi].

<ResponseField name="Arguments">
  <ParamField query="yaw_delta (float)" type="float" required>
    the change in yaw (radians) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### setYawRate

```python theme={null}
MavlinkDrone.setYawRate(yaw_rate: float) -> None
```

Set the yaw rate of the drone in radians/s. Yaw measures the

rotation of the drone around the z-axis (downwards)

<ResponseField name="Arguments">
  <ParamField query="yaw_rate (float)" type="float" required>
    the target yaw\_rate (radians/s) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### moveToPosition

```python theme={null}
MavlinkDrone.moveToPosition(position: Position, no_sideslip: bool = False) -> None
```

Move the drone to position: (x\_val, y\_val, z\_val) respect to the world coordinates in NED frame (right handed, z down).

If `no_sideslip` is specified drone turns in direction of travel. Velocity is limited to be less than velocity limit value.

<ResponseField name="Arguments">
  <ParamField query="position (Position)" type="Position" required>
    contains x, y, and z position in meters in NED frame
  </ParamField>

  <ParamField query="no_sideslip (bool)" type="bool">
    whether to turn in direction of travel (default: False)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### moveToPositionDelta

```python theme={null}
MavlinkDrone.moveToPositionDelta(position_delta: Position, no_sideslip: bool = False) -> None
```

Move the drone by position\_delta: (x\_val, y\_val, z\_val) relative to the current location with respect to the

world coordinates in NED frame (right handed, z down). If `no_sideslip` is specified drone turns in direction of
travel. Velocity is limited to be less than velocity limit value.

<ResponseField name="Arguments">
  <ParamField query="position_delta (Position)" type="Position" required>
    contains x, y, and z position deltas in meters in NED frame
  </ParamField>

  <ParamField query="no_sideslip (bool)" type="bool">
    whether to turn in direction of travel (default: False)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### moveToGPS

```python theme={null}
MavlinkDrone.moveToGPS(lat: float, lon: float, alt: float, alt_use_msl: bool = False) -> None
```

Move the drone to GPS coordinate: (lat, lon, alt) with respect to world coordinates in WGS84 frame (right handed, z up).

By default altitude is relative to starting point, can be set to absolute MSL using `alt_use_msl`.
Note that NO velocity limiting is applied beyond PX4 limitation; drone moves using internal position tracking.

<ResponseField name="Arguments">
  <ParamField query="lat (float)" type="float" required>
    target latitude in degrees
  </ParamField>

  <ParamField query="lon (float)" type="float" required>
    target longitude in degrees
  </ParamField>

  <ParamField query="alt (float)" type="float" required>
    target altitude in meters
  </ParamField>

  <ParamField query="alt_use_msl (bool)" type="bool">
    flag to use altitude in absolute meters above sea level (MSL) (default: False)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### moveByVelocity

```python theme={null}
MavlinkDrone.moveByVelocity(velocity: Velocity, duration: float = None, no_sideslip: bool = False) -> None
```

Fly the drone with `velocity` in NED frame (right-handed, X north, Y east, Z down) in meters/s.

If an optional `duration` is given, the velocity command is held for the specified number of seconds during which the function is blocking.
After the duration is complete the final position is held.
If no duration is specified (default), the command is held until another position or velocity command is given.
If `no_sideslip` is specified drone turns in direction of travel.
Velocity is limited to be less than velocity limit value.

<ResponseField name="Arguments">
  <ParamField query="velocity (Velocity)" type="Velocity" required>
    contains x velocity (x\_vel), y velocity (y\_vel), z velocity (z\_vel)
  </ParamField>

  <ParamField query="duration (float)" type="float">
    number of seconds that the drone should move before stopping, holds final position
  </ParamField>

  <ParamField query="no_sideslip (bool)" type="bool">
    whether to turn in direction of travel (default: False)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### takeoff

```python theme={null}
MavlinkDrone.takeoff() -> None
```

Takeoff the ModalAI drone. Starts by arming the drone. Holds final position after takeoff.

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### land

```python theme={null}
MavlinkDrone.land() -> None
```

Land the ModalAI drone. Descends at 1m/s until reaching 2m altitude. Final descent is at

0.25m/s until 0.1m altitude, then sets 0.5m/s velocity down for 2s to ensure touchdown
before disarming the drone. NOTE: altitude values are given relative to starting location.

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>

### getState

```python theme={null}
MavlinkDrone.getState()
```

Get the current state of the drone, including position, velocity, and orientation.

### stop

```python theme={null}
MavlinkDrone.stop() -> None
```

Stop the drone. Immediately sets velocity to zero.

<ResponseField name="Returns">
  <ResponseField name="returns" type="None" />
</ResponseField>
