-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This is a TraSMAPI specialisation for SUMO simulator.
TraSMAPI is a generic API used as bridge for microscopic traffic simulators (what is a microscopic simulator?) that allows real-time communication between agents in the urban traffic context (such as vehicles, traffic lights and pedestrians) and the environment created by various simulators. This tool was developed at LIACC (Artificial Intelligence and Computer Science Laboratory), University of Porto.
SUMO is an open-source program (licenced under GPL) for microscopic traffic simulation. It is mainly developed by Institute of Transportation Systems, located at German Aerospace Center.
TraSMAPI is written in Java. To use this extension you first need to include TraSMAPI into your project. That can simply be done by creating a trasmapi package and by cloning the genApi folder into there. Then, you have to include in that same trasmapi package the sumo folder that is in this repository.
As TraSMAPI was developed with object oriented design at its core, both the simulation objects and the simulator itself are objects of the language.
Any system developed based on this tool will have an instance of the class TraSMAPI. Inside the application, it represents the simulator and any communication with the simulator in general will be made through this instance. A typical setup of the system would be the following code (utility class SumoConfig can be seen here):
TraSMAPI api = new TraSMAPI("guisim");
List<String> params = new ArrayList<String>();
params.add("-c=TlMap/map.sumo.cfg");
try
{
SumoConfig conf = SumoConfig.load("TlMap/map.sumo.cfg");
sumo.addParameters(params);
sumo.addConnections("localhost", conf.getLocalPort());
} catch (Exception e)
{
e.printStackTrace();
}
// TraSMAPI initialization.
final TraSMAPI api = new TraSMAPI();
api.addSimulator(sumo);
api.launch();
api.connect();
api.start();
In this example, TraSMAPI was setup to work with the graphical version of the SUMO simulator. Subsequently, the simulator is executed with parameters corresponding to a given road network. The parameters in particular change from simulator to simulator and won't be analysed in this tutorial. After being executed, we request TraSMAPI to connect via sockets to the simulator using the method connect.
The basic operation in simulation control is the request to execute a new simulation step. That is achieved though the simulationStep method. A typical execution cycle would look like this:
while(true)
{
int currentStep = SumoCom.getCurrentSimStep();
if(!api.simulationStep(0))
break;
}
api.close();
The close method is called with the objective of closing the connection to the simulator. If the simulator was launched though the framework, then it will also be closed.
The majority of the simulation elements can be manipulated by associating them with objects of the language. Please look into the documentation of each supported simulator in order to understand how to achieve this. The majority of the simulation elements can be manipulated by associating them with objects of the language. Examples include induction loops, traffic lights and vehicles. In the rest of the section, we will use a traffic light to illustrate this interaction.
Relating an object with a simulation element is a simple task, as long as the programmer knows the associated identifier.
TrafficLight tl = new SumoTrafficLight("tl0");
This shows how to associate an object, tl, a TrafficLight, with a Sumo traffic light whose identifier is tl0. Some simulators offer the possibility of listing the elements of given type. Whenever that is possible, static methods have been implemented in the corresponding classes. This methods are considered an extra to the basic functionality and should be avoided as they compromise portability. For reference, this would be the aspect of an invocation of this kind:
String[] tlIdList = SumoTrafficLight.getTrafficLightsIDList();
Modifying the state of a traffic light implies the definition of its colour for each of its lanes. The instantiation of the class Lane is made similarly to that of other objects, and will not be detailed.
The TrafficLight object has a method dedicated to change its colour for a given set of lanes. This method receives a vector of the lanes and the corresponding colour, for example:
Lane[] horLanes = {new SumoLane("1i_0"),new SumoLane("2i_0")};
tl.changeTrafficLightLanes(horLanes, 'G');
We appreciate any help you could give by improving our code, documention, or by simpling creating an issue. If you wish you can contact us at [email protected]
- Fork it.
- Create a branch (
git checkout -b my_trasmapi
) - Commit your changes (
git commit -am "Added message type"
) - Push to the branch (
git push origin my_trasmapi
) - Open a Pull Request
- Enjoy a refreshing Diet Coke and wait
- Timóteo, Ivo JPM, et al. "TraSMAPI: An API oriented towards Multi-Agent Systems real-time interaction with multiple Traffic Simulators." Intelligent Transportation Systems (ITSC), 2010 13th International IEEE Conference on. IEEE, 2010.
- Timóteo, Ivo JPM, et al. "Using TraSMAPI for Developing Multi-Agent Intelligent Traffic Management Solutions." Advances on Practical Applications of Agents and Multiagent Systems. Springer Berlin Heidelberg, 2011. 119-128.
- Timóteo, Ivo JPM, et al. "Using TraSMAPI for the assessment of multi-agent traffic management solutions." Progress in Artificial Intelligence 1.2 (2012): 157-164.
- Soares, Guilherme, et al. "An integrated framework for multi-agent traffic simulation using SUMO and JADE." SUMO2013, The first SUMO user conference. 2013.
- Azevedo, Tiago, et al. "JADE, TraSMAPI and SUMO: a tool-chain for simulating traffic light control." Autonomous Agents and Multiagent Systems (AAMAS), 2014 8th International Workshop on Agents in Traffic and Transportation, ATT'14, held at the Thirteenth International Joint Conference on. 2014
Copyright 2016 STEMS-group
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.