HighwayEnv icon indicating copy to clipboard operation
HighwayEnv copied to clipboard

Collision check implementation

Open m-naumann opened this issue 2 years ago • 1 comments

Hi @eleurent

Following up on https://github.com/eleurent/highway-env/commit/c9a822757356f522af968ec48e06652fb960c555#r69149829:

And I think the assumption of constant velocity is satisfied because I am integrating the dynamics using a simple Euler scheme, which means that the agent actions can only affect the vehicle's velocity at the next time step, but the vehicle's position will be set by integrating the current velocity, which is already determined.

If I'm not mistaken, this is true only for driving straight. However, collisions can also be avoided by steering (presumably not in the intersection scenario that you targeted, but when overtaking, for example). Right?

The idea behind is that we want to detect a collision before the two vehicles overlap, otherwise it looks like one object is passing through the other a little bit. So when we are at time t and observe that in next timestep t+dt the two vehicles are overlapping, it means that the collision actually occurs somewhere between t and t+dt. And we compute the impact displacement which should be added at time t+dt so that the vehicles end up in contact but not overlapping.

Makes sense! How about avoiding the overlap straight in the collision check? So moving

https://github.com/eleurent/highway-env/blob/793c8830ae5be9cbce70f55dfcb33d3c5ed762c3/highway_env/vehicle/kinematics.py#L123-L126

to

https://github.com/eleurent/highway-env/blob/d21a768a9857ca4d04d53e0a7b98fb9840398c3f/highway_env/vehicle/objects.py#L83-L91

(where also by name, collisions are handled).

Would this make sense?

m-naumann avatar Mar 23 '22 08:03 m-naumann

Hey, sorry for the late reply. I think that would make sense yes, I just liked having all the vehicle state updates in one single place so they're easier to keep track of, but I guess here it's actually adding needless complexity.

eleurent avatar Apr 11 '22 07:04 eleurent