Main Content

pcviewset

Manage data for point cloud based visual odometry and SLAM

Description

Thepcviewsetobject stores point cloud odometry and simultaneous localization and mapping (SLAM) data as a set of views and pairwise connections between views.

Creation

Description

example

vSet= pcviewsetcreates a pcviewset object with default property names. Use object functions to perform actions such as adding, modifying, or removing views or connections.

Properties

expand all

This property is read-only.

View attributes, specified as a three-column table. The table contains columns as described in this table.

Column Description
ViewID View identifier, specified as an integer. View identifiers are unique to a specific view.
AbsolutePose Absolute pose of the view, specified as arigid3dobject.
PointCloud Point cloud, specified as apointCloudobject.

This property is read-only.

Pairwise connections between views, specified as a four-column table. The table contains columns as described in this table. Each row corresponds to one connection.

Column Description
ViewID1 View identifier for the first view, specified as a unique integer.
ViewID2 View identifier for the second view, specified as a unique integer.
RelativePose Relative pose of the second view with respect to the first view, specified as arigid3dobject.
InformationMatrix Information matrix, specified as a 6-by-6 matrix. The information matrix represents the uncertainty of the measurement error and is the inverse of the covariance matrix.

This property is read-only.

Number of views, specified as a nonnegative integer.

This property is read-only.

Number of connections, specified as a nonnegative integer.

Object Functions

addView Add views to view set
updateView Update view in view set
deleteView Delete view from view set
hasView Check if view is in view set
addConnection Add connection between views in view set
updateConnection Update connection between views in a view set
deleteConnection Delete a connection between views in view set
hasConnection Check if connection between two views is in view set
findView Find views associated with view identifiers
findConnection Find connections associated with view identifiers
connectedViews Connected views in view set
poses Absolute poses associated with views in view set
createPoseGraph Create pose graph
optimizePoses Optimize absolute poses using relative pose constraints
plot Plot view set views and connections

Examples

collapse all

Create a view set to hold odometry.

vSet = pcviewset;

Create a Velodyne reader to read point clouds.

veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E'); ptCloud = readFrame(veloReader);

Preprocess one frame to remove the ground plane and to downsample point cloud.

elevationDelta = 25; gridStep = 0.2; groundPtsIdx = segmentGroundFromLidarData(ptCloud,...'ElevationAngleDelta',elevationDelta); ptCloud = select(ptCloud,~groundPtsIdx,'Output','full'); ptCloud = pcdownsample(ptCloud,'gridAverage',gridStep);

Initialize attributes for the first view.

absPose = rigid3d; relPose = rigid3d;

Add the first view to the point cloud view set.

vSet = addView(vSet,1,absPose,'PointCloud', ptCloud);

Initialize a point cloud map using the first view.

ptCloudMap = copy(ptCloud); skipFrames = 5; prevViewId = 1; prevPtCloud = ptCloud;

Loop over frames to update odometry and the point cloud map.

forviewId = 6:skipFrames:40% Read point cloud.ptCloud = readFrame(veloReader,viewId);%Preprocess the frame.groundPtsIdx = segmentGroundFromLidarData(ptCloud,...'ElevationAngleDelta',elevationDelta); ptCloud = select(ptCloud,~groundPtsIdx,'Output','full'); ptCloud = pcdownsample(ptCloud,'gridAverage',gridStep);% Register new point cloud against the previous one.regGridStep = 5; relPose = pcregisterndt(ptCloud,prevPtCloud,regGridStep,...“InitialTransform”,relPose);% Update the absolute transform.absPose = rigid3d(relPose.T*absPose.T);% Add new view and connection to the previous view.vSet = addView(vSet,viewId,absPose,'PointCloud', ptCloud);vSet = addConnection (vSet,prevViewId,viewId,relPose); prevPtCloud = ptCloud; prevViewId = viewId;end

Display the view set in a default 2-D view.

plot(vSet,'ShowViewIds','on') view(2)

Figure contains an axes object. The axes object contains an object of type graphplot.

Extended Capabilities

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

Version History

Introduced in R2020a