Main Content

rosReadCartesian

Read laser scan ranges in Cartesian coordinates

Description

cart = rosReadCartesian(scan) converts the polar measurements of the laser scan structure, scan, into Cartesian coordinates, cart. This function uses the metadata in the message, such as angular resolution and opening angle of the laser scanner, to perform the conversion. Invalid range readings, usually represented as NaN, are ignored in this conversion.

cart = rosReadCartesian(___,Name,Value) provides additional options specified by one or more Name,Value pair arguments. You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

[cart,angles] = rosReadCartesian(___) returns the scan angles, angles, that are associated with each Cartesian coordinate. Angles are measured counterclockwise around the positive z-axis, with the zero angle along the x-axis. The angles is returned in radians and wrapped to the [ –pi, pi] interval.

Input Arguments

collapse all

'sensor_msgs/LaserScan' ROS message, specified as a LaserScan structure.

Name-Value Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'RangeLimits',[0.05 2] sets the range limits for the scan in meters

Minimum and maximum range for a scan in meters, specified as a 2-element [min max] vector. All ranges smaller than min or larger than max are ignored during the conversion to Cartesian coordinates.

Output Arguments

collapse all

Cartesian coordinates of laser scan, returned as an n-by-2 matrix in meters.

Scan angles for laser scan data, returned as an n-by-1 matrix in radians. Angles are measured counterclockwise around the positive z-axis, with the zero angle along the x-axis. The angles is returned in radians and wrapped to the [ –pi, pi] interval.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2021a