traci.main
index
/home/delphi/gcc/sumo/tools/traci/main.py

# -*- coding: utf-8 -*-
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
# Copyright (C) 2008-2024 German Aerospace Center (DLR) and others.
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the Eclipse
# Public License 2.0 are satisfied: GNU General Public License, version 2
# or later which is available at
https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later

 
Modules
       
traci._busstop
traci._calibrator
traci._chargingstation
traci._edge
traci._gui
traci._inductionloop
traci._junction
traci._lane
traci._lanearea
traci._meandata
traci._multientryexit
traci._overheadwire
traci._parkingarea
traci._person
traci._poi
traci._polygon
traci._rerouter
traci._route
traci._routeprobe
traci._simulation
traci._trafficlight
traci._variablespeedsign
traci._vehicle
traci._vehicletype
traci.connection
os
socket
subprocess
sys
traci.constants
time
warnings

 
Functions
       
addStepListener(listener)
addStepListener(traci.StepListener) -> int
 
Append the step listener (its step function is called at the end of every call to traci.simulationStep())
to the current connection.
Returns the ID assigned to the listener if it was added successfully, None otherwise.
close(wait=True)
Tells TraCI to close the connection.
connect(port=8813, numRetries=60, host='localhost', proc=None, waitBetweenRetries=1, traceFile=None, traceGetters=True, label=None)
Establish a connection to a TraCI-Server and return the
connection object. If label is not set, the connection is not saved in the pool and not
accessible via traci.switch. It should be safe to use different
connections established by this method in different threads.
executeMove()
executeMove() -> None
Make "half" a simulation step.
getConnection(label='default')
Return the connection associated with the given label.
Throws a TraCIException if no such connection exists.
getLabel()
Return the label of the current connection.
Throws a FatalTraCIError if no connection exists.
getVersion()
getVersion() -> tuple
 
Returns a tuple containing the TraCI API version number (integer)
and a string identifying the SUMO version running on the TraCI server in human-readable form.
hasGUI()
Return whether a GUI and the corresponding GUI commands are available for the current connection.
init(port=8813, numRetries=60, host='localhost', label='default', proc=None, doSwitch=True, traceFile=None, traceGetters=True)
Establish a connection to a TraCI-Server and store it under the given
label. This method is not thread-safe. It accesses the connection
pool concurrently.
isLibsumo()
isLibtraci()
isLoaded()
Returns whether there is an active connection.
load(args)
load([optionOrParam, ...])
Let sumo load a simulation using the given command line like options
Example:
  load(['-c', 'run.sumocfg'])
  load(['-n', 'net.net.xml', '-r', 'routes.rou.xml'])
removeStepListener(listenerID)
removeStepListener(traci.StepListener) -> bool
 
Remove the step listener from the current connection's step listener container.
Returns True if the listener was removed successfully, False if it wasn't registered.
setConnectHook(hookFunc)
Set a function which is called whenever a new connection has been established.
The function should take a single parameter which is the connection object.
setLegacyGetLeader(enabled)
setOrder(order)
Tells TraCI to give the current client the given position in the
execution order. It is mandatory to send this as the first command after
connecting to the TraCI server when using multiple clients. Each client
must be assigned a unique integer but there are not further restrictions
on numbering.
simulationStep(step=0)
simulationStep(float) -> None
Make a simulation step and simulate up to the given second in sim time.
If the given value is 0 or absent, exactly one step is performed.
Values smaller than or equal to the current sim time result in no action.
simulationStepLegacy(step=0)
simulationStep(float) -> list
Make a simulation step and simulate up to the given second in sim time.
If the given value is 0 or absent, exactly one step is performed.
Values smaller than or equal to the current sim time result in no action.
This is a legacy function which returns the subscription results for the
current step in a list.
start(cmd, port=None, numRetries=60, label='default', verbose=False, traceFile=None, traceGetters=True, stdout=None, doSwitch=True)
Start a sumo server using cmd, establish a connection to it and
store it under the given label. This method is not thread-safe.
 
- cmd (list): uses the Popen syntax. i.e. ['sumo', '-c', 'run.sumocfg']. The remote
  port option will be added automatically
- numRetries (int): retries on failing to connect to sumo (more retries are needed
  if a big .net.xml file must be loaded)
- label (string) : distinguish multiple traci connections used in the same script
- verbose (bool): print complete cmd
- traceFile (string): write all traci commands to FILE for debugging
- traceGetters (bool): whether to include get-commands in traceFile
- stdout (iostream): where to pipe sumo process stdout
switch(label)
Switch the current connection to the one given by the label.
Throws a TraCIException if no such connection exists.

 
Data
        DOMAINS = [<traci._busstop.BusStopDomain object>, <traci._calibrator.CalibratorDomain object>, <traci._chargingstation.ChargingStationDomain object>, <traci._edge.EdgeDomain object>, <traci._gui.GuiDomain object>, <traci._inductionloop.InductionLoopDomain object>, <traci._junction.JunctionDomain object>, <traci._lane.LaneDomain object>, <traci._lanearea.LaneAreaDomain object>, <traci._meandata.MeanDataDomain object>, <traci._multientryexit.MultiEntryExitDomain object>, <traci._overheadwire.OverheadWireDomain object>, <traci._parkingarea.ParkingAreaDomain object>, <traci._person.PersonDomain object>, <traci._poi.PoiDomain object>, <traci._polygon.PolygonDomain object>, <traci._rerouter.RerouterDomain object>, <traci._route.RouteDomain object>, <traci._routeprobe.RouteProbeDomain object>, <traci._simulation.SimulationDomain object>, ...]
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0), 262144)
busstop = <traci._busstop.BusStopDomain object>
calibrator = <traci._calibrator.CalibratorDomain object>
chargingstation = <traci._chargingstation.ChargingStationDomain object>
edge = <traci._edge.EdgeDomain object>
gui = <traci._gui.GuiDomain object>
inductionloop = <traci._inductionloop.InductionLoopDomain object>
junction = <traci._junction.JunctionDomain object>
lane = <traci._lane.LaneDomain object>
lanearea = <traci._lanearea.LaneAreaDomain object>
meandata = <traci._meandata.MeanDataDomain object>
multientryexit = <traci._multientryexit.MultiEntryExitDomain object>
overheadwire = <traci._overheadwire.OverheadWireDomain object>
parkingarea = <traci._parkingarea.ParkingAreaDomain object>
person = <traci._person.PersonDomain object>
poi = <traci._poi.PoiDomain object>
polygon = <traci._polygon.PolygonDomain object>
print_function = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 1048576)
rerouter = <traci._rerouter.RerouterDomain object>
route = <traci._route.RouteDomain object>
routeprobe = <traci._routeprobe.RouteProbeDomain object>
simulation = <traci._simulation.SimulationDomain object>
trafficlight = <traci._trafficlight.TrafficLightDomain object>
variablespeedsign = <traci._variablespeedsign.VariableSpeedSignDomain object>
vehicle = <traci._vehicle.VehicleDomain object>
vehicletype = <traci._vehicletype.VehicleTypeDomain object>