Insert ray from laser scan observation
inserts one or more lidar scan sensor observations in the occupancy grid,
map, using the input
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.
are ignored. This behavior correlates to the inverse sensor model.
rays with updated probabilities given in the two-element vector,
that corresponds to obstacle-free and occupied observations. Use any
of the previous syntaxes to input the rays.
map— Map representation
Map representation, specified as a
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.
pose— Position and orientation of robot
[x y theta]vector
Position and orientation of robot, specified as an
theta] vector. The robot pose is an x and
y position with angular orientation (in radians)
measured from the x-axis.
ranges— Range values from scan data
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
angles— Angle values from scan data
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
maxrange— Maximum range of sensor
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
startpt— Start point for rays
Start point for rays, specified as a two-element vector,
y], in the world coordinate frame. All rays are line segments
that originate at this point.
invModel— Inverse sensor model values
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
NaN range values are ignored. Range
values greater than
maxrange are not updated. See Inverse Sensor Model.
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.
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.
ans = 0.8448
The inverse sensor model determines how
values are set along a ray from a range sensor reading to the obstacles
in the map. You can customize this model by specifying different probabilities
for free and occupied locations in the
values are ignored. Range values greater than
Grid locations that contain range readings are updated with the occupied probability. Locations before the reading are updated with the free probability. All locations after the reading are not updated.