egueli / TraCI4J

A high-level Java library to communicate with SUMO (Simulation of Urban MObility) through its TraCI protocol.
GNU General Public License v3.0
41 stars 27 forks source link

Starting simulation time #8

Closed ma-al closed 10 years ago

ma-al commented 10 years ago

Hi,

Currently, when starting a SUMO instance, the starting time reported by the API does not match the one specified in the sumo.cfg file. Instead, it always starts at zero.

For example, you tell SUMO (via TraCI4J) to start with example.sumo.cfg that specifies:

<time>
   <begin value="50000"></begin>
   <end value="56000"/>
</time>

However, doing conn.getCurrentSimStep() returns time 0. Incrementing using conn.nextSimStep(); only advances strictly by 1.

For now, I'm externally finding the begin-time and brute-force incrementing the simulation time to the desired value. Just wondering if I've missed something obvious, or a more elegant way to "fast-forward" the simulation time.

Any advice would be much appreciated.

Many thanks for allowing the use of TraCI4J.

egueli commented 10 years ago

Hi, indeed, the value returned by getCurrentSimStep() comes from an internal counter, not from Sumo. And it always starts from zero. A possible fix would be in SumoTraciConnection.postConnect(), where currentSimStep is set to zero.

egueli commented 10 years ago

Hi mar-di, would you mind to checkout the "fix-begin-simtime" and check if that works for you?

egueli commented 10 years ago

Did a JUnit test by myself. Fixed in master too.

ma-al commented 10 years ago

Hi egueli,

We tested the new code and it works. Starting simulation time is now set to whatever was specified in the sumo.cfg file.

Thanks for the replies and your efforts. Again, many thanks for allowing the use of TraCI4J.