> ## Documentation Index
> Fetch the complete documentation index at: https://scaledfoundations-rebrand.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Modalai Drone

## ModalaiDrone

Inherits from: [AerialRobot](/robot-api/grid/robot/aerial/aerial_robot#aerialrobot)

Instantiates a ModalaiDrone containing mavlink client for sending commands to real drone.

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

### clip\_velocity

```python
ModalaiDrone.clip_velocity(vel: np.ndarray, velocity_limit: float)
```

Clip the velocity to be less than the velocity limit value.

<ResponseField name="Arguments">
  <ParamField query="vel (np.ndarray)" type="" required>
    velocity vector to be clipped
  </ParamField>

  <ParamField query="velocity_limit (float)" type="" required>
    maximum velocity limit for the drone in m/s
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  clipped velocity vector
</ResponseField>

### getPosition

```python
ModalaiDrone.getPosition()
```

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

### getVelocity

```python
ModalaiDrone.getVelocity()
```

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

### getYaw

```python
ModalaiDrone.getYaw()
```

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)

### getOrientation

```python
ModalaiDrone.getOrientation()
```

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).

### setYaw

```python
ModalaiDrone.setYaw(yaw: float)
```

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="" required>
    the target yaw (radians) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns" />

### setYawDelta

```python
ModalaiDrone.setYawDelta(yaw_delta: float)
```

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="" required>
    the change in yaw (radians) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns" />

### setYawRate

```python
ModalaiDrone.setYawRate(yaw_rate: float)
```

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="" required>
    the target yaw\_rate (radians/s) for the drone
  </ParamField>
</ResponseField>

<ResponseField name="Returns" />

### moveToPosition

```python
ModalaiDrone.moveToPosition(position: Position, no_sideslip: bool)
```

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="" required>
    [Position](/robot-api/grid/utils/types#position)

    contains x, y, and z position in meters in NED frame
  </ParamField>

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

<ResponseField name="Returns" />

### moveToPositionDelta

```python
ModalaiDrone.moveToPositionDelta(position_delta: Position, no_sideslip: bool)
```

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="" required>
    [Position](/robot-api/grid/utils/types#position)

    contains x, y, and z position deltas in meters in NED frame
  </ParamField>

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

<ResponseField name="Returns" />

### moveToGPS

```python
ModalaiDrone.moveToGPS(lat: float, lon: float, alt: float, alt_use_msl: bool)
```

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="" required>
    target latitude in degrees
  </ParamField>

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

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

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

<ResponseField name="Returns" />

### moveByVelocity

```python
ModalaiDrone.moveByVelocity(velocity: Velocity, duration: float, no_sideslip: bool)
```

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="" required>
    [Velocity](/robot-api/grid/utils/types#velocity)

    contains x velocity (x\_vel), y velocity (y\_vel), z velocity (z\_vel)
  </ParamField>

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

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

<ResponseField name="Returns" />

### takeoff

```python
ModalaiDrone.takeoff()
```

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

### land

```python
ModalaiDrone.land()
```

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.

### getImage

```python
ModalaiDrone.getImage(camera_name: str, image_type: str)
```

return the image of camera(camera\_name)

<ResponseField name="Arguments">
  <ParamField query="camera_name (str), optional" type="">
    name of the camera, one of `hires_front_small` or `hires_down_small` (default: `hires_front_small`)
  </ParamField>

  <ParamField query="image_type (str), optional" type="">
    supported image types, {"rgb"} (default: `rgb`)
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  [Image](/robot-api/grid/utils/types#image)

  Image type containing the requested image.
</ResponseField>
