A*探路者障碍物碰撞问题

发布于 2024-09-06 19:01:40 字数 1552 浏览 3 评论 0原文

我正在开发一个机器人项目,该机器人必须找到到达物体的路径,并在到达必须拾取的物体时避开一些障碍物。

问题在于机器人和机器人需要拾取的物体在探路器中都是一像素宽。事实上它们要大得多。通常,A* 探路器会选择沿着障碍物的边缘放置路线,有时会使其与障碍物发生碰撞,但我们不希望这样做。

我尝试在障碍物中添加更多不可步行的区域,但效果并不总是很好。它仍然会与障碍物发生碰撞,并且增加了太多不允许它行走的点,导致它没有可以运行的路径。

您对如何解决这个问题有什么建议吗?

编辑:

所以我按照 Justin L 的建议做了,在障碍周围增加了大量成本,结果如​​下: 没有路径的网格 http://sogaard.us/uploades/1_grid_no_path.png

在这里您可以查看障碍物周围的成本,最初中间的两个障碍物应该看起来就像角落里的障碍物一样,但是在运行我们的探路器之后,成本似乎被覆盖了:

带有路径 http://sogaard.us/uploades/1_map_grid.png

显示在图片上找到的东西的图片 http://sogaard.us/uploades/2_complete_map.png

上图显示了在图片上找到的东西。

找到的路径 http://sogaard.us/uploades/3_path.png

这是找到的路径正如我们之前的问题一样,这就是拥抱障碍。

之前的网格,路径位于 http://sogaard.us/uploades/4_mg_path.png

另一张带有成本图且路径已开启的图片。

所以我觉得奇怪的是为什么 A* 探路者会忽略这些非常高的现场成本。

是不是当它使用当前字段评估打开列表内的节点以查看当前字段路径是否比打开列表内的节点短时?

这是我用于探路者的代码:

Pathfinder.cs: http://pastebin.org/343774

Field.cs 和 Grid.cs:http://pastebin.org/343775

I am working on a project with a robot that has to find its way to an object and avoid some obstacles when going to that object it has to pick up.

The problem lies in that the robot and the object the robot needs to pick up are both one pixel wide in the pathfinder. In reality they are a lot bigger. Often the A* pathfinder chooses to place the route along the edges of the obstacles, sometimes making it collide with them, which we do not wish to have to do.

I have tried to add some more non-walkable fields to the obstacles, but it does not always work out very well. It still collides with the obstacles, also adding too many points where it is not allowed to walk, results in that there is no path it can run on.

Do you have any suggestions on what to do about this problem?

Edit:

So I did as Justin L suggested by adding a lot of cost around the obstacles which results in the folling:
Grid with no path http://sogaard.us/uploades/1_grid_no_path.png

Here you can see the cost around the obstacles, initially the middle two obstacles should look just like the ones in the corners, but after running our pathfinder it seems like the costs are overridden:

Grid with path http://sogaard.us/uploades/1_map_grid.png

Picture that shows things found on the picture http://sogaard.us/uploades/2_complete_map.png

Picture above shows what things are found on the picture.

Path found http://sogaard.us/uploades/3_path.png

This is the path found which as our problem also was before is hugging the obstacle.

The grid from before with the path on http://sogaard.us/uploades/4_mg_path.png

And another picture with the cost map with the path on.

So what I find strange is why the A* pathfinder is overriding these field costs, which are VERY high.

Would it be when it evaluates the nodes inside the open list with the current field to see whether the current fields path is shorter than the one inside the open list?

And here is the code I am using for the pathfinder:

Pathfinder.cs: http://pastebin.org/343774

Field.cs and Grid.cs: http://pastebin.org/343775

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稀香 2024-09-13 19:01:40

您是否考虑过向物体附近的像素添加梯度成本?

也许就像线性梯度一样简单:

C = -mx + b

其中 x 是到最近物体的距离,b 是边界外的成本,m 是成本消失的速率。当然,如果 C 为负,则应将其设置为 0。

也许是一个简单的双曲线衰减

C = b/x

,其中 b 再次是边界之外的所需成本。一旦达到某个低点,就将其截止为 0。

或者,您可以使用指数衰减,

C = k e^(-hx)

其中 k 是缩放常数,h 是衰减率。再说一遍,有一个截止点是明智的。


第二个建议

我从未将 A* 应用于像素映射地图;几乎总是,瓷砖。

您可以尝试大幅降低瓷砖的“分辨率”吗?也许每 10×10 或 20×20 像素组有一个图块;图块的成本是图块中像素的最高成本。

另外,您可以尝试降低用于 A* 的最短距离启发式的值。

Have you considered adding a gradient cost to pixels near objects?

Perhaps one as simple as a linear gradient:

C = -mx + b

Where x is the distance to the nearest object, b is the cost right outside the boundary, and m is the rate at which the cost dies off. Of course, if C is negative, it should be set to 0.

Perhaps a simple hyperbolic decay

C = b/x

where b is the desired cost right outside the boundary, again. Have a cut-off to 0 once it reaches a certain low point.

Alternatively, you could use exponential decay

C = k e^(-hx)

Where k is a scaling constant, and h is the rate of decay. Again, having a cut-off is smart.


Second suggestion

I've never applied A* to a pixel-mapped map; nearly always, tiles.

You could try massively decreasing the "resolution" of your tiles? Maybe one tile per ten-by-ten or twenty-by-twenty set of pixels; the tile's cost being the highest cost of a pixel in the tile.

Also, you could try de-valuing the shortest-distance heuristic you are using for A*.

夜吻♂芭芘 2024-09-13 19:01:40

考虑到机器人的尺寸,您可以尝试扩大障碍物。您可以绕过障碍物的拐角来解决阻塞问题。那么所填充的间隙就太小了,机器人无论如何也无法挤过去。

You might try to enlarge the obstacles taking size of the robot into account. You could round the corners of the obstacles to address the blocking problem. Then the gaps that are filled are too small for the robot to squeeze through anyway.

温暖的光 2024-09-13 19:01:40

我曾经做过一个这样的实体机器人。我的解决方案是每当需要左转和右转时就向后退一步。

替代文本

红线是我对你问题的理解。黑线是我为解决问题所做的。机器人可以向后直线移动一步,然后向右转。

I've done one such physical robot. My solution was to move one step backward whenever there is a left and right turn to do.

alt text

The red line is as I understand your problem. The Black line is what I did to resolve the issue. The robot can move straight backward for a step then turn right.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文