Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.48k stars 726 forks source link

获取其他车辆位置 #557

Open izvvv opened 5 months ago

izvvv commented 5 months ago

如果我随机放置障碍物,为了防止障碍物与其他车辆重合,我想要用预防碰撞一样方法来解决,则需要获取其他车辆的位置,请问我应该怎么做?

izvvv commented 5 months ago

If I place an obstacle at random, and I want to solve it in the same way as collision prevention in order to prevent the obstacle from colliding with other vehicles, I need to get the position of the other vehicle, what should I do?

I've found a solution, but there's a problem with it. When I run the running code, I get an error like this, but sometimes it works successfully and doesn't seem to be regular. 2024-01-15_23-09-25

eleurent commented 5 months ago

it's because you've found a collision at index i, so you remove obstacle x from the list, but you dont break out of the loop, so at index i+1 you may try to remove the obstacle x from the road objects again when it has been removed already. I think just adding a break statement after the a+=1 would be fine.