listClients
List all connected MAVLink clients
Description
lists all active connections for the clientTable = listClients(mavlink)mavlinkio client
connection.
Examples
Create a MAVLink dialect object using the common.xml file.
dialect = mavlinkdialect("common.xml");Create a local MAVLink client object that represents a simulated UAV. Specify these options:
MAVLink message definition —
dialectMAVLink system ID —
1MAVLink component ID —
1MAVLink component type —
MAV_TYPE_QUADROTORMAVLink autopilot type —
MAV_AUTOPILOT_GENERIC
uavClient = mavlinkio(dialect,SystemID=1,ComponentID=1,AutopilotType="MAV_AUTOPILOT_GENERIC",ComponentType="MAV_TYPE_QUADROTOR");
Connect the local simulated UAV to a random open UDP port by using the connect object function.
connect(uavClient,"UDP");List all MAVLink clients that are connected to the simulated UAV by using the listClients object function. The output contains only the simulated UAV, which shows that no other MAVLink client is connected to the simulated UAV.
listClients(uavClient)
ans=1×4 table
SystemID ComponentID ComponentType AutopilotType
________ ___________ ____________________ _______________________
1 1 "MAV_TYPE_QUADROTOR" "MAV_AUTOPILOT_GENERIC"
Launch QGroundControl.

To establish a connection with QGroundControl, first create a blank heartbeat message by using the createmsg object function.
heartbeat = createmsg(dialect,"HEARTBEAT");Assign the component type and autopilot type of the simulated UAV, and the system status, to the heartbeat message fields.
heartbeat.Payload.type(:) = enum2num(dialect,MAV_TYPE=uavClient.LocalClient.ComponentType);
heartbeat.Payload.autopilot(:) = enum2num(dialect,MAV_AUTOPILOT=uavClient.LocalClient.AutopilotType);
heartbeat.Payload.system_status(:) = enum2num(dialect,MAV_STATE="MAV_STATE_STANDBY");Create a timer callback function. Configure the callback function to send the heartbeat message to QGroundControl through a UDP connection using the sendudpmsg object function.
localHost = "127.0.0.1";
qgcPort = 14550;
heartBeatTimerFunction = @(~,~)sendudpmsg(uavClient,heartbeat,localHost,qgcPort);Create a timer object with a fixed rate execution mode, period of 1 second, and the timer callback function.
heartbeatTimer = timer(ExecutionMode="fixedRate",Period=1,TimerFcn=heartBeatTimerFunction);Start the timer object. The local simulated UAV broadcasts the heartbeat message at 1 Hz, and QGroundControl connects to the simulated UAV.
start(heartbeatTimer)

List the MAVLink clients again to verify that QGroundControl is now connected. The output shows that QGroundControl is a connected MAVLink client with a component type of MAV_TYPE_GCS.
listClients(uavClient)

Once you have finished running the example, stop and delete the timer object to end the connection.
stop(heartbeatTimer) delete(heartbeatTimer)
Input Arguments
MAVLink client connection, specified as a mavlinkio
object.
Output Arguments
Active connection info, returned as a table with SystemID,
ComponentID, ConnectionType, and
AutopilotType fields for each active client.
Version History
Introduced in R2019a
See Also
connect | listConnections | listTopics | mavlinkio | mavlinkdialect | mavlinkclient | mavlinksub
External Websites
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)