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

TraaS: Simulation.getDeltaT() fails #7121

Closed jangrimm84 closed 4 years ago

jangrimm84 commented 4 years ago

Hi there,

I am using a Java Client connecting to SUMO (1.6.0 on Windows, 64 bit) by means of the TraaS Library. I noticed an issue while querying the simulation step on startup - an exception is thrown, declaring my inquiry command as invalid. Maybe there is some glitch in TraaS? This issue occurred with SUMO 1.4.0, too.

I created a minimum test scenario with a simple Java client demonstrating the issue (see attached zip file).

TraciTestApplication.zip

The following actions will lead to the exception:

1) Started SUMO/TraCI-Server by executing startSumo.bat

2) Started Java client by executing startClient.bat in a different terminal window

After that, I get the following on the client terminal window:

Starting Traci Server Connecting to SUMO Exception occurred during simulation startup or step! it.polito.appeal.traci.TraCIException$UnexpectedData: Unexpected : expected 9, got 11 at de.tudresden.sumo.util.Query.verify(Query.java:274) at de.tudresden.sumo.util.CommandProcessor.do_job_get(CommandProcessor.java:382) at it.polito.appeal.traci.SumoTraciConnection.do_job_get(SumoTraciConnection.java:390) at info.highway_history.test.TraciTestApplication.connectToSUMO(TraciTestApplication.java:66) at info.highway_history.test.TraciTestApplication.main(TraciTestApplication.java:25)

The following command in my Java code fails:

deltaT = Math.round(1000.0 * ((double)sumoConnection.do_job_get(Simulation.getDeltaT()))); // should give me the simulation step in milliseconds

Obviously, Simulation.getDeltaT() returns a faulty SumoCommand object. If I assemble the SumoCommand "by hand", it works, i.e. If I replace the above line with the one below, my sample program works.

deltaT = Math.round(1000.0 * ((double)sumoConnection.do_job_get(new SumoCommand(171, 123, "", 187, 11))));

The zip file also contains the source java file (subfolder "TraciTestApplication/src"). Please search for "FIXME" to find the code that fails.

Is this indeed a TraaS Bug, or am I just doing something wrong?

Thank you very much!

namdre commented 4 years ago

Thanks for reporting.