How can I convert a surface plot to an Occupancy map 3D?

조회 수: 44 (최근 30일)
Shubham Kalpande
Shubham Kalpande 2021년 6월 8일
답변: Sandip Kumar 2021년 6월 9일
I want to simulate flight of an UAV on a terrain and I plan to use the UAV toolbox for path planning. But it requires the terrain information in form of an Occupancy map. I am not sure how to create it given a surface plot. I have tried one logical implementation but I am having trouble in getting a more better representation. Is there any way I can set the occupancy of the entire ground plane to 1? I want to represent the hilly terrain. I have managed to mark out only the top layer.

답변 (2개)

darova
darova 2021년 6월 8일
What about isosurface?
[x,y,z] = peaks(20);
z = (z-min(z(:)))/(max(z(:))-min(z(:)))*19; % scale values inbetween [1 .. 19]
z = round(z)+1; % round (to get indices)
A = zeros(20,20,20);
for i = 1:20
for j = 1:20
k = z(i,j);
A(i,j,k) = 1;
end
end
isosurface(A,0.01)
  댓글 수: 2
darova
darova 2021년 6월 8일
looks like cubes
[x,y,z] = peaks(20);
z = (z-min(z(:)))/(max(z(:))-min(z(:)))*19; % scale values inbetween [1 .. 19]
z = round(z)+1; % round (to get indices)
A = zeros(40,40,40);
ii = [-1 0];
for i = 1:20
for j = 1:20
k = z(i,j);
A(2*i+ii,2*j+ii,2*k+ii) = 1;
end
end
isosurface(A,0.1)
Shubham Kalpande
Shubham Kalpande 2021년 6월 8일
I dont think this will work. The path planner of UAV toolbox accepts only occupancy map as the input for plannning a path in the terrain

댓글을 달려면 로그인하십시오.


Sandip Kumar
Sandip Kumar 2021년 6월 9일
Hi Subham
Using the code from Surface plots and using it in occupancyMap3D can be done in this fashion.
Define some surface plot data
delta = 0.1;
[X,Y] = meshgrid(1:delta:10,1:delta:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)
Use the data to populate your occpancyMap3D
pts3d = [X(:) Y(:) Z(:)];
% Create an empty occupancy map in 3d with the same resolution
map = occupancyMap3D(1/delta);
% Set the corresponding 3d points to represent occupancy
setOccupancy(map, pts3d, ones(size(pts3d,1), 1));
% See the map now
show(map)

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by