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

# MavlinkClient

## MavlinkClient

Inherits from: `object`

*No class docstring.*

### **init**

```python theme={null}
MavlinkClient.__init__(ground_control_station_ip: str, mavlink_port: str, vehicle_ip: str, communication_protocol: str, arm_enable: bool, dry_run: bool, checks_poststart: Optional[List[callable]] = None, checks_preflight: Optional[List[callable]] = None, checks_postarm: Optional[List[callable]] = None, messages_known: Optional[List[str]] = None, messages_required: Optional[List[str]] = None, offboard_control_mode_int: int = None)
```

Instantiates a Mavlink client for message passing and command sending with a drone,

including optional preflight/poststart checks.

<ResponseField name="Arguments">
  <ParamField query="ground_control_station_ip (str)" type="str" required>
    IP address of the ground control station
  </ParamField>

  <ParamField query="mavlink_port (str)" type="str" required>
    Port number for MAVLink connection
  </ParamField>

  <ParamField query="vehicle_ip (str)" type="str" required>
    IP address of the drone/vehicle
  </ParamField>

  <ParamField query="communication_protocol (str)" type="str" required>
    Communication protocol, e.g., 'udp' or 'tcp'
  </ParamField>

  <ParamField query="arm_enable (bool)" type="bool" required>
    Whether arming is enabled
  </ParamField>

  <ParamField query="dry_run (bool)" type="bool" required>
    If True, bypasses arming exceptions
  </ParamField>

  <ParamField query="checks_poststart (Optional[List[callable]])" type="Optional[List[callable]]">
    A list of functions to run after the client has started.
  </ParamField>

  <ParamField query="checks_preflight (Optional[List[callable]])" type="Optional[List[callable]]">
    A list of functions to run before flight to validate system state.
  </ParamField>

  <ParamField query="checks_postarm (Optional[List[callable]])" type="Optional[List[callable]]">
    A list of functions to run immediately after arming to validate system state.
  </ParamField>

  <ParamField query="messages_known (Optional[List[str]])" type="Optional[List[str]]">
    List of MAVLink message types expected (default: None)
  </ParamField>

  <ParamField query="messages_required (Optional[List[str]])" type="Optional[List[str]]">
    List of MAVLink message types required before proceeding (default: None)
  </ParamField>

  <ParamField query="offboard_control_mode_int (int)" type="int">
    Custom offboard control mode value. (default: 6)
  </ParamField>
</ResponseField>

### run\_checks

```python theme={null}
MavlinkClient.run_checks(checks: List[callable])
```

Runs a list of check functions.

<ResponseField name="Arguments">
  <ParamField query="checks (List[callable])" type="List[callable]" required>
    A list of functions that accept the client instance and return a boolean.
  </ParamField>
</ResponseField>

### get\_msg

```python theme={null}
MavlinkClient.get_msg(msg_type: str)
```

Thread-safe retrieval of a message from the internal dictionary.

<ResponseField name="Arguments">
  <ParamField query="msg_type (str)" type="str" required>
    The name of the message type to retrieve.
  </ParamField>
</ResponseField>

### update\_setpoint

```python theme={null}
MavlinkClient.update_setpoint(controls, **kwargs)
```

Updates the current setpoint and control parameters.

<ResponseField name="Arguments">
  <ParamField query="controls (List[str])" type="List[str]" required>
    List of control fields to update.
  </ParamField>

  <ParamField query="kwargs" type="">
    Values for parameters (e.g., lat, lon, alt, vx, vy, yaw, etc.)
  </ParamField>
</ResponseField>

### attempt\_command

```python theme={null}
MavlinkClient.attempt_command(command_name: str, command_id: int, params: List[Any], confirmation: int = 0, max_attempts: int = 3, retry_delay: float = 1.0) -> bool
```

Attempts to execute a command with retry logic.

<ResponseField name="Arguments">
  <ParamField query="command_name (str)" type="str" required>
    Command description for logging.
  </ParamField>

  <ParamField query="command_id (int)" type="int" required>
    MAVLink command ID.
  </ParamField>

  <ParamField query="params (List[Any])" type="List[Any]" required>
    List of 7 parameters for the command.
  </ParamField>

  <ParamField query="confirmation (int)" type="int">
    0 for initial transmission, 1-255 for confirmations.
  </ParamField>

  <ParamField query="max_attempts (int)" type="int">
    Maximum retry attempts.
  </ParamField>

  <ParamField query="retry_delay (float)" type="float">
    Delay between attempts.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="bool">
    True if the command is acknowledged successfully; False otherwise.
  </ResponseField>
</ResponseField>

### set\_custom\_msg\_rates

```python theme={null}
MavlinkClient.set_custom_msg_rates(msg_id: int, interval_us: int)
```

Sets custom message publishing rates for a given MAVLink message.

<ResponseField name="Arguments">
  <ParamField query="msg_id (int)" type="int" required>
    The MAVLink message ID.
  </ParamField>

  <ParamField query="interval_us (int)" type="int" required>
    The interval in microseconds between messages.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if successful, False otherwise.
  </ResponseField>
</ResponseField>

### request\_msg

```python theme={null}
MavlinkClient.request_msg(msg_id: int)
```

Requests a specific MAVLink message from the drone.

<ResponseField name="Arguments">
  <ParamField query="msg_id (int)" type="int" required>
    The MAVLink message ID.
  </ParamField>
</ResponseField>

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the request was successful, False otherwise.
  </ResponseField>
</ResponseField>

### reset\_ned\_origin

```python theme={null}
MavlinkClient.reset_ned_origin() -> bool
```

Resets the MAVLink NED origin using the current position.

<ResponseField name="Returns">
  <ResponseField name="bool" type="bool">
    True if the origin was reset successfully, False otherwise.
  </ResponseField>
</ResponseField>

### arm

```python theme={null}
MavlinkClient.arm()
```

Arms the drone (if permitted).

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if the drone was successfully armed, False otherwise.
  </ResponseField>
</ResponseField>

### disarm

```python theme={null}
MavlinkClient.disarm()
```

Disarms the drone.

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if disarm was successful, False otherwise.
  </ResponseField>
</ResponseField>

### set\_offboard\_control

```python theme={null}
MavlinkClient.set_offboard_control()
```

Sets the drone's control mode to OFFBOARD, enabling external setpoint control.

<ResponseField name="Returns">
  <ResponseField name="bool" type="">
    True if offboard control was successfully set, False otherwise.
  </ResponseField>
</ResponseField>

### start

```python theme={null}
MavlinkClient.start()
```

Starts the drone client by resetting NED origin, arming, and setting offboard control.

### terminate

```python theme={null}
MavlinkClient.terminate()
```

Terminates the client and shuts down all threads.
