![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1047880/image.png)
How to open 3D occupancy map
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Cameron Stabile
le 27 Juin 2022
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1047880/image.png)
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
0 commentaires
Voir également
Catégories
En savoir plus sur Mapping dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!