TraCI/TraaS

generated on 2019-05-24 00:19:29.154046 from the wiki page for TraCI/TraaS for SUMO git

TraaS

TraaS is a java library for working with TraCI. The name TraaS stands for TraCI as a Service. It was developed by Mario Krumnow and uses code from the now discontinued TraCI4J project by Enrico Gueli. Since version 1.0, TraaS is maintained within the SUMO repository at <SUMO_HOME>/tools/contributed/traas.

TraaS provides three things which are explained below.

  • A java traci client that can be used to write TraCI scripts directly
  • A web service that can be used to connect multiple webservice clients to a running TraCI instance in a language-agnostic way.
  • A web service client

In constrast to the native TraCI multi-client support, TraaS does not require the number of clients to be known beforehand. It also cannot impose any ordering on client command execution which leaves client synchronization to be managed on the user side.

Java Client

The client provides functions using with the same name and signature as the python client. A major difference is, that the method return values must be casted in the calling code:

 double timeSeconds = (double)conn.do_job_get(Simulation.getTime());

Examples

The examples must becomplied using

 javac -cp sumo/tools/contributed/traas/examples/java_library:sumo/bin/TraaS.jar ExampleName.java

after compiling they can be run using

 java -cp sumo/tools/contributed/traas/examples/java_library:sumo/bin/TraaS.jar ExampleName

Insert Vehicles and Access Induction Loop Data

<SUMO_HOME>/tools/contributed/traas/examples/java_library/Main.java

Connect Multiple clients

<SUMO_HOME>/tools/contributed/traas/examples/java_library/MultiClient1.java
<SUMO_HOME>/tools/contributed/traas/examples/java_library/MultiClient2.java

Subscribe to Variables

<SUMO_HOME>/tools/contributed/traas/examples/java_library/Subscription.java

Generate screenshots during simulation runtime

Change the TLS-program

Get CO2 Emissions

Webservice

Webservice Client

Documentation

JavaDoc for TraaS can be found at https://sumo.dlr.de/javadoc/traas/

Building TraaS

The file <SUMO_HOME> /bin/TraaS.jar is inclued in every SUMO release. To build TraaS locally, ant is required. To build, simply call ant within the traas folder:

 sumo/tools/contributed/traas$ ant