eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.36k stars 1.37k forks source link

Collision avoidance while using sumo #14969

Closed prasuka4 closed 1 month ago

prasuka4 commented 1 month ago

Hi, I have tried to use traci to control the speed of the vehicle with traci.vehicle.setspeed. Due to this vehicle is getting collided with other vehicles. Is there any way where vehicle can avoid collision by detecting the vehicle ahead and make necessary lane changes or apply brake. please do let me know any possible solution

SUMO-version: SUMO - V 1-19 operating system: Windows 11

namdre commented 1 month ago

if you don't call setSpeedMode, safety features should remain in affect by default: https://sumo.dlr.de/docs/TraCI/Change_Vehicle_State.html#speed_mode_0xb3

prasuka4 commented 1 month ago

Hi I have not used setspeedmode earlier.

I have also tested speed modes now but none of them were not giving expected output. Vehicle is getting collided with other. Below snap is configuration for your reference. Please do let me know if any other information required.

Untitled

namdre commented 1 month ago

please provide all input files for reproducing your problem (attach them as a zip archive here)

prasuka4 commented 1 month ago

Hi, Please do have a look at the sample files that are being shared for your reference DLR_Sample.zip

namdre commented 1 month ago

The problem comes from

        if step > 100:
            traci.vehicle.moveToXY("Car", edgeID='E0', lane=0, x=260, y=-1.6)

The vehicle 'Car' is moved (to the same spot) in every step after stop 100. While the other cars expect it to drive at a speed of 25m/s (and this is what it would naturally do), it is practically "beamed" backwards to the same spot. each step.

If you want the car to keep staying in place, then issuing a setSpeed('Car', 0) fixes the problem (calling setStop would be even better). Otherwise reconsider the condition for calling moveToXY.

prasuka4 commented 3 weeks ago

Thank you for your response, but if we have list of position that need to be updated at regular interval of time then, moveToXY need to be used. In that case the remaining vehicles will collide and pass over each other. Is it possible with any other means to avoid the collision or is there any alternate method. Please do let me know Thanks in Advance

namdre commented 3 weeks ago

The problem occurs only if you use setSpeed (25m/s) with a value that doesn't match the speeds implicit in the moveToXY command (0m/s). Don't use setSpeed or use better values and you'll be fine.