udpdriver

Crazyflie UDP driver.

This driver communicates with a Crazyflie (or simulator) over UDP using the CRTP protocol. It enables connecting to software-in-the-loop (SITL) simulations. Scanning feature assumes a crazyflie server is running on port 19850-19859 that will respond to a null CRTP packet with a valid CRTP packet.

Wire Protocol

The UDP driver uses a simple wire protocol where each UDP datagram contains exactly one CRTP packet. The packet format is:

Byte 0:    CRTP header (port, channel, and reserved bits)
Bytes 1-N: CRTP payload data (0 to 30 bytes) set by CRTP_MAX_DATA_SIZE in firmware

Total packet size: 1 to 31 bytes per UDP datagram

The payload follows standard CRTP format as defined in the Crazyflie protocol specification. No additional framing, checksums, or encapsulation is added by the UDP driver.

Scan Behavior

The scan_interface() method discovers available Crazyflie devices by probing UDP ports in sequence:

Port Range: 19850 to 19859 (10 ports total, BASE_PORT + 0 through 9) Scan Address: Configurable via SCAN_ADDRESS environment variable (default: 127.0.0.1) Probe Packet: Single 0xFF byte (null CRTP packet) Timeout: 0.1 seconds per port

Scan Procedure: 1. For each port in range: - Send 0xFF probe packet to SCAN_ADDRESS:port - Wait up to 0.1 seconds for response - If any response received, device is present - Add URI “udp://SCAN_ADDRESS:port” to results

Environment Variables

SCAN_ADDRESS: IP address to scan for Crazyflie devices Default: 127.0.0.1 Example: export SCAN_ADDRESS=192.168.1.100

          This is useful when the Crazyflie server and client run on different
          hosts. The client will scan the specified address instead of localhost.

Connection URI Format

udp://:

Examples: udp://127.0.0.1:19850 - Local simulator on port 19850 udp://192.168.1.5:19850 - Remote device at 192.168.1.5


Classes

UdpDriver

UdpDriver()

Crazyflie UDP link driver

Create the link driver


Ancestors (in MRO)

Methods

def close(self)

Close the link.


def connect(self, uri, radio_link_statistics_callback, link_error_callback)

Connect the link driver to a specified URI of the format: udp://:

The callback for radio link statistics is not used by the UDP driver. The callback from link_error_callback will be called when an error occurs with an error message.


def pause(self)

def receive_packet(self, wait=0)

Receive a packet though the link. This call is blocking but will timeout and return None if a timeout is supplied.


def restart(self)

def scan_interface(self, address=None)

Scan interface for Crazyflies


def send_packet(self, pk)

Send the packet pk though the link