matlab cost,Get cost value of cells in vehicle costmap

Create a 5-by-10 meter vehicle costmap. Cells have side length 1, in the world units of meters. Set the inflation radius to 1. Plot the costmap, and get the default cost matrix.

costmap = vehicleCostmap(5,10);

costmap.CollisionChecker.InflationRadius = 1;

plot(costmap)

title('Default Costmap')

f5ddaec2569c75375c7c270523f4436e.png

getCosts(costmap)

ans = 10×5

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

0.4250 0.4250 0.4250 0.4250 0.4250

Mark an obstacle at the (x,y) coordinate (3,4) by increasing the cost of that cell.

setCosts(costmap,[3,4],0.8);

plot(costmap)

title('Costmap with Obstacle at (3,4)')

13cd4684bfe7664de0f292d8d67e0eb7.png

Get the cost of three cells: the cell with the obstacle, a cell adjacent to the obstacle, and a cell outside the inflation radius of the obstacle.

costVal = getCosts(costmap,[3 4;2 4;4 7])

costVal = 3×1

0.8000

0.4250

0.4250

Although the plot of the costmap displays the cell with the obstacle and its adjacent cells in shades of red, only the cell with the obstacle has a higher cost value of 0.8. The other cells still have the default cost value of 0.425.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值