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.55k stars 1.43k forks source link

How to get one vehicle' delay at a intersection oniline by traci? #8679

Closed thinker310 closed 3 years ago

thinker310 commented 3 years ago

Hello, recently, I am researching the traffic signal control and I want to obtain the vehicle's real-time delay by traci, and I do not want to use the output.xml file or tripinfo.xml because it is offline. Could any body help me? Thank you very much!

namdre commented 3 years ago

You can either upgrade to the latest development version or you can compute the vehicle timeLoss based on current vehicle speed and maximum allowed vehicle speed. One way to find all applicable vehicles is to retrieve all vehicles in a radius around the intersection (subscribeContext) and filter those that are still ahead of the intersection by calling getNextTLS on all vehicles. Alternatively, you can define detectors (E2 or E3) to collect the vehicles queued at the intersection or even simplier, collect all vehicles on a pre-defined list of lanes.