flow icon indicating copy to clipboard operation
flow copied to clipboard

COLLISIONS: retrieve the IDs of colliding vehicles and the number of collisions

Open Tabbi7 opened this issue 5 years ago • 2 comments

Dear all, how can I retrieve the number of collisions at each step while running the training on the ring env? I saw in the base.py file

crash encodes whether the simulator experienced a collision

crash = self.k.simulation.check_collision()

crash is a Boolean variable that is true when there is a crash. I want to retrieve the number of collisions and the IDs of the colliding vehicles. How? Can you please help me?

Tabbi7 avatar May 24 '20 10:05 Tabbi7

self.k.simulation.check_collision() uses one of the two functions you need: the number of collisions. The other one you can find here: http://sumo.sourceforge.net/pydoc/traci._simulation.html you need to reference the kernel api to use them in your enviroment.

AlexKou96 avatar May 25 '20 22:05 AlexKou96

Thank you, @alexkou ! It worked. But I still have a problem: how to increase the probability of collisions in my env? I intentionally want to cause road accidents (collisions) in the ring.py env.

I just set

car_following_params=SumoCarFollowingParams( min_gap=0, speed_mode="aggressive", decel=1, accel=100, initial_speed=121 ),

and also "speed_limit": 150 in net=NetParams(additional_params={, but that's not enough.

What else can I do to let vehicles collide?

Tabbi7 avatar May 27 '20 18:05 Tabbi7