This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

insertRay

Class: robotics.OccupancyGrid
Package: robotics

Insert ray from laser scan observation

Syntax

insertRay(map,pose,scan,maxrange)
insertRay(map,pose,ranges,angles,maxrange)
insertRay(map,startpt,endpoints)
insertRay(___,invModel)

Description

insertRay(map,pose,scan,maxrange) inserts one or more lidar scan sensor observations in the occupancy grid, map, using the input lidarScan object, scan, to get ray endpoints. The ray endpoints are considered free space if the input scan ranges are below maxrange. Cells observed as occupied are updated with an observation of 0.7. All other points along the ray are treated as obstacle free and updated with an observation of 0.4. Endpoints above maxrange are not updated. NaN values are ignored. This behavior correlates to the inverse sensor model.

example

insertRay(map,pose,ranges,angles,maxrange) specifies the range readings as vectors, ranges and angles.

insertRay(map,startpt,endpoints) inserts observations between the line segments from the start point to the end points. The endpoints are updated with a probability observation of 0.7. Cells along the line segments are updated with an observation of 0.4.

insertRay(___,invModel) inserts rays with updated probabilities given in the two-element vector, invModel, that corresponds to obstacle-free and occupied observations. Use any of the previous syntaxes to input the rays.

Input Arguments

expand all

Map representation, specified as a robotics.OccupancyGrid object. This object represents the environment of the robot. The object contains a matrix grid with values representing the probability of the occupancy of that cell. Values close to 1 represent a high certainty that the cell contains an obstacle. Values close to 0 represent certainty that the cell is not occupied and obstacle free.

Position and orientation of robot, specified as an [x y theta] vector. The robot pose is an x and y position with angular orientation (in radians) measured from the x-axis.

Lidar scan readings, specified as a lidarScan object.

Range values from scan data, specified as a vector of scalars in meters. These range values are distances from a sensor at given angles. The vector must be the same length as the corresponding angles vector.

Angle values from scan data, specified as a vector of scalars in radians. These angle values are the specific angles of the given ranges. The vector must be the same length as the corresponding ranges vector.

Maximum range of laser range sensor, specified as a scalar. Range values greater than or equal to maxrange are considered free along the whole length of the ray, up to maxrange.

Start point for rays, specified as a two-element vector, [x y], in the world coordinate frame. All rays are line segments that originate at this point.

Endpoints for rays, specified as an n-by-2 matrix, [x y], in the world coordinate frame, where n is the length of ranges or angles. All rays are line segments that originate at startpt.

Inverse sensor model values, specified as a two-element vector corresponding to obstacle-free and occupied probabilities. Points along the ray are updated according to the inverse sensor model and the specified range readings. NaN range values are ignored. Range values greater than maxrange are not updated. See Inverse Sensor Model.

Examples

expand all

Take range and angle readings from a laser scan and insert these readings into an occupancy grid.

Create an empty occupancy grid map.

map = robotics.OccupancyGrid(10,10,20);

Insert a laser scan into the occupancy grid. Specify the pose of the robot ranges and angles and the max range of the laser scan.

pose = [5,5,0];
ranges = 3*ones(100, 1);
angles = linspace(-pi/2, pi/2, 100);
maxrange = 20;
        
insertRay(map,pose,ranges,angles,maxrange);

Show the map to see the results of inserting the laser scan. Check the occupancy of the spot directly in front of the robot.

show(map)

getOccupancy(map,[8 5])
ans = 0.7000

Add a second reading and view the update to the occupancy values. The additional reading increases the confidence in the readings. The free and occupied values become more distinct.

insertRay(map,pose,ranges,angles,maxrange);
show(map)

getOccupancy(map,[8 5])
ans = 0.8448

More About

expand all

Introduced in R2016b