msg = receive(sub) waits
for MATLAB® to receive a topic message from the specified subscriber, sub,
and returns it as msg.
msg = receive(sub,timeout)
specifies in timeout the number of seconds to
wait for a message. If a message is not received within the timeout
limit, the software produces an error.
Connect to a ROS network. Set up a sample ROS network. The '/scan' topic is being published on the network.
rosinit
Launching ROS Core...
................Done in 1.1402 seconds.
Initializing ROS master on http://192.168.0.10:58531.
Initializing global node /matlab_global_node_91925 with NodeURI http://bat6315glnxa64:43597/
exampleHelperROSCreateSampleNetwork
Create a subscriber for the '/scan' topic. Wait for the subscriber to register with the master.
sub = rossubscriber('/scan');
pause(1);
Receive data from the subscriber as a ROS message. Specify a 10-second timeout.
msg2 = receive(sub,10)
msg2 =
ROS LaserScan message with properties:
MessageType: 'sensor_msgs/LaserScan'
Header: [1x1 Header]
AngleMin: -0.5216
AngleMax: 0.5243
AngleIncrement: 0.0016
TimeIncrement: 0
ScanTime: 0.0330
RangeMin: 0.4500
RangeMax: 10
Ranges: [640x1 single]
Intensities: [0x1 single]
Use showdetails to show the contents of the message
Shutdown the timers used by sample network.
exampleHelperROSShutDownSampleNetwork
Shut down ROS network.
rosshutdown
Shutting down global node /matlab_global_node_91925 with NodeURI http://bat6315glnxa64:43597/
Shutting down ROS master on http://192.168.0.10:58531.
.....