Convert to occupancyMap3D
20 views (last 30 days)
Show older comments
First now, I convert stl file(from CATIA) to .mat file (class: pde.DiscreteGeometry).
And I want to convert this .mat file to 3D occupancy Map.
How can I solve this problem?
My goal is that I want to build real map on 3D occupancy Map.
And I'm trying this example RRT code which is loaded on MathWorks.
mapData = load("uavMapCityBlock.mat","omap");
omap = mapData.omap;
% Consider unknown spaces to be unoccupied
omap.FreeThreshold = omap.OccupiedThreshold;
inflate(omap,1)
figure("Name","CityBlock")
show(omap)
At first line, "uavMapCityBlock.mat" is a occupancyMap3D class. And I want to change that .mat file to my converted file which I'm asking you guys.
pls understanding my short english skill. thanks :)
Answers (1)
Aditya Patil
on 30 Mar 2021
There is currently no direct function to convert stl to occupancy matrix/grid.
As a workaround, if you create the stl file using large number of points, you should be able to pass to points to insertPointCloud function, as follows
gm = importGeometry('ForearmLink.stl');
points = gm.Vertices;
omap = occupancyMap3D;
pose = [0 0 0 1 0 0 0];
maxrange = 100;
insertPointCloud(omap, pose, points, maxrange);
show(omap);
However, this won't work very well for stl files with low number of vertices. So instead, you can create an alphashape with points, and then check for occupancy. The accuracy of method below will depend upon how well the alphaShape is created. Try different values from alphaShape parameters to get a better result.
gm = importGeometry('ForearmLink.stl');
points = gm.Vertices;
shp = alphaShape(points, 23);
plot(shp);
[X,Y,Z]= meshgrid(-150:150, -150:150, -150:150);
insideMat = inShape(shp, X, Y, Z);
insideId = find(insideMat);
[Xoc, Yoc, Zoc] = ind2sub(size(X), insideId);
pcshow([Xoc, Yoc, Zoc])
1 Comment
David Meira Pliego
on 12 Apr 2021
Do you know any other way to convert a ptCloud map into a Occupancy map?. Thanks
See Also
Categories
Find more on Mapping in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!