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.58k stars 1.44k forks source link

SUMO-GUI one step ahead of TRACI? #15752

Closed Ahmad1441 closed 5 days ago

Ahmad1441 commented 5 days ago

Hello Sumo Team,

Does Traci perform always one step before simulation time (SUMO/SUMO-Gui time)?

In my example, simulation step is 1 second, and I Spwaned two cars at simulation time 0.1 second.

When simulation time is second 1, two cars are already there in SUMO GUI, But Traci print no cars in simulation. In fact, Traci print the status of simulation for one step back. Is this understanding correct?

image

Thanks

namdre commented 5 days ago

Yes. See https://sumo.dlr.de/docs/Developer/Implementation_Notes/Simulation_Loop.html TraCI is active at the start of simulation step (before vehicles have moved and where they still have the positions from the prior step) and the GUI shows the state at the end of the step (after vehicles have moved).

namdre commented 5 days ago

Note, you can call traci.simulation.executeMoveme to perform further queries/manipulations after vehicles have moved but before the step is "done" and shown in the GUI.