Initialize Occupancy Grid with Default Value?

조회 수: 1 (최근 30일)
Andres Morales
Andres Morales 2023년 8월 1일
편집: Praveen Reddy 2023년 8월 25일
Right now, this is what I have:
width = 50;
height = 50;
resolution = 1;
default = 0.25;
map = occupancyMap(width,height,resolution);
map.DefaultValue = default;
setOccupancy(map,default*(ones(map.GridSize)));
I initially expected Line 6 to change the default value, but I guess since the grid has already been initialized with the "default default value", this performs no change. Therefore, I need to force this change on Line 7.
Is there a way to set the default initially and saving that computation time?
What is the effect of Line 6 then? Since it is not reflected on the occupancy grid?

채택된 답변

Praveen Reddy
Praveen Reddy 2023년 8월 21일
Hi Andres,
I understand that you want to know how to initialize occupancy grid with default value without using “setOccupancy()” method. I suggest you to pass the default value matrix as input to occupancyMap()” method as shown below
width = 500;
height = 500;
res = 1;
default = 0.25;
occupiedMatrix = true(height*res,width*res);
map = occupancyMap(occupiedMatrix, Resolution=res);
Please note that DefaultValue” property of map object is used for unspecified map locations including areas outside the map.
To know more about occupancyMap usage, please refer to the following MATLAB documentation.
  댓글 수: 2
Andres Morales
Andres Morales 2023년 8월 24일
Hello Praveen,
On Line 5, do you mean:
occupiedMatrix = default*true(height*res,width*res);
?
Praveen Reddy
Praveen Reddy 2023년 8월 25일
편집: Praveen Reddy 2023년 8월 25일
Hi Andres,
You can construct the matrix as per your requirements. I tried to make minimal changes to your code. However I did not intend to use the default variable declared.

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

추가 답변 (0개)

카테고리

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