Main Content


Disconnect from MAVLink clients



disconnect(mavlink) disconnects from all MAVLink clients connected through the mavlinkio client.

disconnect(mavlink,connection) disconnects from the specific client connection name.


collapse all

Connect to a MAVLink client.

mavlink = mavlinkio("common.xml");

Create the object for storing the client information. Specify the system and component ID.

client = mavlinkclient(mavlink,1,1)
client = 
  mavlinkclient with properties:

         SystemID: 1
      ComponentID: 1
    ComponentType: "Unknown"
    AutopilotType: "Unknown"

Disconnect from client.


This example shows how to connect to MAVLink clients, inspect the list of topics, connections, and clients, and send messages through UDP ports using the MAVLink communication protocol.

Connect to a MAVLink client using the "common.xml" dialect. This local client communicates with any other clients through a UDP port.

dialect = mavlinkdialect("common.xml");
mavlink = mavlinkio(dialect);
ans = 

You can list all the active clients, connections, and topics for the MAVLink connection. Currently, there is only one client connection and no topics have received messages.

ans=1×4 table
    SystemID    ComponentID    ComponentType          AutopilotType     
    ________    ___________    ______________    _______________________

      255            1         "MAV_TYPE_GCS"    "MAV_AUTOPILOT_INVALID"

ans=1×2 table
    ConnectionName      ConnectionInfo   
    ______________    ___________________

    "Connection1"     "UDP@"

ans =

  0x5 empty table

    MessageID    MessageName    SystemID    ComponentID    MessageFrequency
    _________    ___________    ________    ___________    ________________

Create a subscriber for receiving messages on the client. This subscriber listens for the "HEARTBEAT" message topic with ID equal to 0.

sub = mavlinksub(mavlink,0);

Create a "HEARTBEAT" message using the mavlinkdialect object. Specify payload information and send the message over the MAVLink client.

msg = createmsg(dialect,"HEARTBEAT");
msg.Payload.type(:) = enum2num(dialect,'MAV_TYPE','MAV_TYPE_QUADROTOR');

Disconnect from the client.


Input Arguments

collapse all

MAVLink client connection, specified as a mavlinkio object.

Connection name, specified as a string scalar.

Version History

Introduced in R2019a