LaserScan

Create laser scan message

Description

The LaserScan object is an implementation of the sensor_msgs/LaserScan message type in ROS. The object contains meta-information about the message and the laser scan data. You can extract the ranges and angles using the Ranges property and the readScanAngles function. To access points in Cartesian coordinates, use readCartesian.

You can also convert this object to a lidarScan (Navigation Toolbox) object to use with other robotics algorithms such as matchScans (Navigation Toolbox), controllerVFH (Navigation Toolbox), or monteCarloLocalization (Navigation Toolbox).

Creation

Description

example

scan = rosmessage('sensor_msgs/LaserScan') creates an empty LaserScan object. You can specify scan info and data using the properties, or you can get these messages off a ROS network using rossubscriber.

Properties

expand all

This property is read-only.

Message type of ROS message, returned as a character vector.

Data Types: char

This property is read-only.

ROS Header message, returned as a Header object. This header message contains the MessageType, sequence (Seq), timestamp (Stamp), and FrameId. Timestamp relates to the acquisition time of the first ray in the scan.

Minimum angle of range data, specified as a scalar in radians. Positive angles are measured from the forward direction of the robot.

Maximum angle of range data, specified as a scalar in radians. Positive angles are measured from the forward direction of the robot.

Angle increment of range data, specified as a scalar in radians.

Time between individual range data points in seconds, specified as a scalar.

Time to complete a full scan in seconds, specified as a scalar.

Minimum valid range value, specified as a scalar.

Maximum valid range value, specified as a scalar.

Range readings from laser scan, specified as a vector. To get the corresponding angles, use readScanAngles.

Intensity values from range readings, specified as a vector. If no valid intensity readings are found, this property is empty.

Object Functions

lidarScan (Navigation Toolbox)Create object for storing 2-D lidar scan
plotDisplay laser or lidar scan readings
readCartesianRead laser scan ranges in Cartesian coordinates
readScanAnglesReturn scan angles for laser scan range readings

Examples

collapse all

Load, inspect, and display a sample laser scan message.

Create sample messages and inspect the laser scan message data.The scan object is a sample ROS LaserScan message object.

exampleHelperROSLoadMessages
scan
scan = 
  ROS LaserScan message with properties:

       MessageType: 'sensor_msgs/LaserScan'
            Header: [1x1 Header]
          AngleMin: -0.5467
          AngleMax: 0.5467
    AngleIncrement: 0.0017
     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

Get ranges and angles from the object properties. Check that the ranges and angles are the same size.

ranges = scan.Ranges;
angles = scan.readScanAngles;
size(ranges)
ans = 1×2

   640     1

size(angles)
ans = 1×2

   640     1

plot(scan)

scan = rosmessage('sensor_msgs/LaserScan')
scan = 
  ROS LaserScan message with properties:

       MessageType: 'sensor_msgs/LaserScan'
            Header: [1x1 Header]
          AngleMin: 0
          AngleMax: 0
    AngleIncrement: 0
     TimeIncrement: 0
          ScanTime: 0
          RangeMin: 0
          RangeMax: 0
            Ranges: [0x1 single]
       Intensities: [0x1 single]

  Use showdetails to show the contents of the message

Introduced in R2019b