Received messages from MAVLink subscriber
returns the latest received messages for the
msgs = latestmsgs(
object. The messages are in a structure array in reverse-chronological order with the most
recent being first. If
count is larger than the number of stored
messages, the structure array contains only the number of stored messages.
This function requires you to install the UAV Library for Robotics System
Toolbox™. To install add-ons, use
roboticsAddons and select the desired add-on.
NOTE: This example requires you to install the UAV Library for Robotics System Toolbox®. Call
roboticsAddons to open the Add-ons Explorer and install the library.
Connect to a MAVLink client.
mavlink = mavlinkio("common.xml")
mavlink = mavlinkio with properties: Dialect: [1x1 mavlinkdialect] LocalClient: [1x1 struct]
ans = "Connection1"
Get the client information.
client = mavlinkclient(mavlink,1,1);
Subscribe to the
heartbeat = mavlinksub(mavlink,client,'HEARTBEAT');
Get the latest message. You must wait for a message to be received. Currently, no heartbeat message has been received on the
ans = 1x0 empty struct array with fields: MsgID SystemID ComponentID Payload Seq
Disconnect from client.
count— Number of messages
Number of messages, specified as a positive integer. If
is larger than the number of stored messages, the structure array is padded with empty
msgs— Recently received messages
Recently received messages, returned as a structure array. Each structure has the fields:
Payload is a structure defined by the message definition for
the MAVLink dialect.
count is larger than the number of stored messages, the
structure array contains only the number of stored messages..