Main Content

lidarscanmap

Simultaneous localization and mapping using 2-D lidar scans

Since R2022b

Description

A lidarscanmap object performs simultaneous localization and mapping (SLAM) using the 2-D lidar scans. The lidarscanmap object uses a graph-based SLAM algorithm to create a map of an environment from 2-D lidar scans. First, the algorithm builds a pose graph by linking the input scans using their absolute poses. Then, it uses a scan-matching approach to detect loop closures to minimize any odometry drift.

Using the lidarscanmap object, you can:

  • Store and add lidar scans incrementally.

  • Detect, add, and delete loop closures.

  • Find and update the absolute poses of the scans.

  • Generate and visualize a pose graph.

To further optimize the pose graph, use the optimizePoseGraph (Navigation Toolbox) function.

Creation

Description

scanMapObj = lidarscanmap creates a lidarscanmap object with default property values.

scanMapObj = lidarscanmap(gridResolution) specifies the resolution of the occupancy grid map. gridResolution sets the GridResolution property.

example

scanMapObj = lidarscanmap(gridResolution,maxLidarRange) specifies the resolution of the occupancy grid map and maximum range of the lidar sensor. The gridResolution and maxLidarRange arguments set the GridResolution and the MaxLidarRange properties, respectively.

Properties

expand all

2-D lidar scans and their absolute poses, stored as a table, where each row represents a lidar scan. The table has these columns.

  • ScanID — Unique identifier for the scan, stored as a positive integer.

  • LidarScan — 2-D lidar scan, stored as a lidarScan object.

  • AbsolutePose — Absolute pose of the lidar scan, stored as a three-element vector of the form [x y Θ], where x and y define the position in meters, and Θ defines the orientation of the input scan in radians.

This property is read-only.

Connections between lidar scans, stored as a table, where each row represents a connection. The table has these columns.

  • FromScanIDScanID of the scan at the beginning of the connection, stored as a positive integer.

  • ToScanIDScanID of the scan at the end of the connection, stored as a positive integer.

  • RelativePose — Relative pose of the corresponding scan specified by ToScanID with respect to the connected scan specified by FromScanID, stored as a three-element vector of the form [x y Θ], where x and y define the translational offset in meters, and Θ defines the rotational offset between the scans in radians.

  • InformationMatrix — Uncertainty in the relative pose measurement, stored as a 3-by-3 matrix. This matrix is the inverse of the covariance matrix.

This property is read-only.

Loop closure connections between lidar scans, stored as a table, where each row represents a loop closure. The table has these columns.

  • FromScanIDScanID of the scan at the beginning of the connection, stored as a positive integer.

  • ToScanIDScanID of the scan at the end of the connection, stored as a positive integer.

This property is read-only.

Number of lidar scans in the lidarscanmap object, specified as a positive integer.

This property is read-only.

Data Types: double

Number of connections in the lidarscanmap object, specified as a positive integer.

This property is read-only.

Data Types: double

Number of loop closure connections in the lidarscanmap object, specified as a positive integer.

This property is read-only.

Data Types: double

Resolution of the occupancy grid map, specified as a positive scalar.

To set this property, you must specify it at object creation.

Data Types: double

Maximum range of the lidar sensor, specified as a positive scalar. Units are in meters.

To set this property, you must specify it at object creation.

Data Types: double

Object Functions

addScanAdd 2-D lidar scan to map
detectLoopClosureDetect loop closure in 2-D lidar scan map
addLoopClosureAdd loop closure to the map
deleteLoopClosureDelete loop closure between 2-D lidar scans
poseGraphCreate 2-D pose graph from lidar scan map
findPoseFind absolute pose of 2-D lidar scan in the map
updateScanPosesUpdate absolute poses of 2-D lidar scans
copyCreate a copy of lidarscanmap object
showDisplay 2-D lidar scans and lidar sensor trajectory

Examples

collapse all

Load a MAT file containing 2-D lidar scans and a warehouse map into the workspace.

data = load("wareHouse.mat");
scans = data.wareHouseScans;

Create a lidarscanmap object.

scanMapObj = lidarscanmap;

Add the scans from the input data to the scanMapObj object by using the addScan function.

for currentID = 1:70
    addScan(scanMapObj,scans{currentID});
end

Display the warehouse map.

ax = show(scanMapObj,ShowTrajectory=false);
hold on

Find the absolute pose of the first scan in the map by using the findPose function. Specify the pose estimate of the scan as [0 0] and the search radius as 5 meters.

absPose = findPose(scanMapObj,scans{1},[0 0],SearchRadius=5);

Display the pose of the first scan in the map.

showShape("circle",[absPose(1:2) 0.2],Color="g",Parent=ax)

Iterate the previous two steps to localize the remaining scans in the map and visualize the results.

for n = 2:numel(scans)
    currentScan = scans{n};

    % Use the absolute pose of the previous scan as the pose estimate for
    % the next scan
    poseEstimate = absPose(1:2);
    absPose = findPose(scanMapObj,currentScan,poseEstimate,SearchRadius=5);

    % Display the pose of the current scan in the map
    pose = [absPose(1:2) 0.05];
    showShape("circle",pose,Color="b")
end
hold off

Version History

Introduced in R2022b