Main Content

raycast

Compute cell indices along a ray

Description

[endpoints,midpoints] = raycast(map,pose,range,angle)returns cell indices of the specifiedmapfor all cells traversed by a ray originating from the specifiedposeat the specifiedangleandrangevalues.endpointscontains all indices touched by the end of the ray, with all other points included inmidpoints.

[endpoints,midpoints] = raycast(map,p1,p2)returns the cell indices of the line segment between the two specified points.

Input Arguments

collapse all

Map representation, specified as abinaryOccupancyMapobject. This object represents the environment of the robot. The object contains a matrix grid with binary values indicating obstacles astrue(1) and free locations asfalse(0).

Position and orientation of sensor, specified as an[xytheta]vector. The sensor pose is anxandyposition with angular orientationtheta(in radians) measured from thex-axis.

Range of ray, specified as a scalar in meters.

Angle of ray, specified as a scalar in radians. The angle value is for the correspondingrange.

Starting point of ray, specified as an[xy]two-element vector. Points are defined with respect to the world-frame.

Endpoint of ray, specified as an[xy]two-element vector. Points are defined with respect to the world-frame.

Output Arguments

collapse all

Endpoint indices, returned as ann-by-2 matrix of[ij]pairs, wherenis the number of grid indices. The endpoints are where therangevalue hits at the specifiedangle. Multiple indices are returned when the endpoint lies on the boundary of multiple cells.

Midpoint indices, returned as ann-by-2 matrix of[ij]pairs, wherenis the number of grid indices. This argument includes all grid indices the ray intersects, excluding the endpoint.

Extended Capabilities

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

See Also

||(Navigation Toolbox)

Introduced in R2019b