Dux02 / AM2050

Project am2050a
0 stars 0 forks source link

Rubberbanding lane mergers #5

Closed Blasylf closed 11 months ago

Blasylf commented 11 months ago

Cars will rubberband on lane mergers. I've tried to fix this by being very uppity with when cars merger. Take for example In Car.py, we attempt a merger when: (Line 62 in latest commit)

s < 1.5 * self.s0 and self.vel < self.desiredvel and self.desiredvel > infront.vel

Then, when checking for merging abilities in Simulation.py:

if (car.overtaking == -1 and othercar.x > car.x and 
    othercar.x - CAR_LENGTH - car.x < 2*max(car.desiredDist(othercar),0)*PIXEL_PER_M):

We see if the car gets into the lane, its s0 would be the desiredDist we compute, so the factor 2 being bigger than 1.5. I thought this would've killed rubberbanding, but no. Rubberbanding across multiple lanes still occurs quite often (for which I cannot do a simple fix like this) and restricting the lanes to 2 still seemed to cause rubberbanding, but I haven't checked after fixing (?) issue #2