How to open 3D occupancy map

조회 수: 11 (최근 30일)
Agung Pratama Pujayasa
Agung Pratama Pujayasa 2022년 6월 23일
답변: Cameron Stabile 2022년 6월 27일
i want to open a 3d occupancy map to use in other project about UAV,from most guide i always see this line:
mapData = load("uavMapCityBlock.mat");
omap = mapData.omap;
the guide:https://www.mathworks.com/help/uav/ug/plan-minimum-snap-trajectory-for-quadrotor.html
i try to make my own 3D occupancy map and use it in the same way like this
mapData = load("randomap.mat);
omap = mapData.omap;
but i get this error instead:
Unrecognized field name "omap".
Error in gabunganutama (line 8)
omap = mapData.omap;
but when i use the devault uavmapcity it always work,whats more the guide never show the script for the uavmapcity map and the info about 3D occupancy map and the script for it is pretty scarce too,i use this script for my randomap:
map3D = occupancyMap3D;
[xGround,yGround,zGround] = meshgrid(0:100,0:100,0);
xyzGround = [xGround(:) yGround(:) zGround(:)];
occval = 0;
setOccupancy(map3D,xyzGround,occval)
[xBuilding1,yBuilding1,zBuilding1] = meshgrid(0:200,0:200,0:2);
xyzBuildings = [xBuilding1(:) yBuilding1(:) zBuilding1(:)];
obs = 0.65;
updateOccupancy(map3D,xyzBuildings,obs)
show(map3D)
it's just a plain for test

답변 (1개)

Cameron Stabile
Cameron Stabile 2022년 6월 27일
Hi Agung,
The reason these examples have that line
omap = mapData.omap;
has to do with the behavior of the load command, which packs all saved variables into a struct, with each field in the struct corresponding to a variable that was saved to the MAT-file. In the examples you've seen, we happened to save an occupancyMap variable whose variable name was omap, for you that name might be different.
The easiest way to figure out what's stored in your struct is to run the load command without the semi-colon, e.g:
Guessing from your map-generation script, the map in your randomap.mat file is most likely named map3D, so you'll likely want the following:
% Load data into struct
mapData = load("randomap.mat");
% Extract map into your local variable
myMapVariable = mapData.map3D;
Hope this helps,
Cameron

카테고리

Help CenterFile Exchange에서 Mapping에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by