receive
Wait for new ROS message
Description
waits for MATLAB® to receive a topic message from the specified
subscriber, msg
= receive(sub
)sub
, and returns it as
msg
. Alternatively, for the most more
reliable way to receive messages continuously as they are published
on the ROS network, consider using a callback function with the
rossubscriber
object.
[
returns a msg
,status
,statustext
] = receive(___)status
indicating whether a message has
been received successfully, and a statustext
that
captures additional information about the status
,
using any of the arguments from the previous syntaxes. If an error
condition occurs, such as no message received within the specified
timeout, the status
will be
false
, and this function will not display
an error.
Examples
Input Arguments
Output Arguments
Tips
For code generation:
Use the
status
output argument when you callreceive
in the entry-point function. This will avoid runtime errors and instead, outputs the status of message reception, which can be reacted to in the calling code.
Extended Capabilities
Version History
Introduced in R2019bSee Also
send
| rosmessage
| rostopic
| rossubscriber
| rospublisher