libsumo 1.23.0__cp313-cp313-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- libsumo/__init__.py +218 -0
- libsumo/_libsumo.pyd +0 -0
- libsumo/libsumo.py +7334 -0
- libsumo-1.23.0.dist-info/METADATA +138 -0
- libsumo-1.23.0.dist-info/RECORD +7 -0
- libsumo-1.23.0.dist-info/WHEEL +5 -0
- libsumo-1.23.0.dist-info/top_level.txt +1 -0
libsumo/__init__.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
|
|
2
|
+
# Copyright (C) 2018-2025 German Aerospace Center (DLR) and others.
|
|
3
|
+
# This program and the accompanying materials are made available under the
|
|
4
|
+
# terms of the Eclipse Public License 2.0 which is available at
|
|
5
|
+
# https://www.eclipse.org/legal/epl-2.0/
|
|
6
|
+
# This Source Code may also be made available under the following Secondary
|
|
7
|
+
# Licenses when the conditions for such availability set forth in the Eclipse
|
|
8
|
+
# Public License 2.0 are satisfied: GNU General Public License, version 2
|
|
9
|
+
# or later which is available at
|
|
10
|
+
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
|
|
11
|
+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
|
|
12
|
+
|
|
13
|
+
# @file __init__.py
|
|
14
|
+
# @author Benjamin Striner
|
|
15
|
+
# @author Michael Behrisch
|
|
16
|
+
# @date 2018-06-05
|
|
17
|
+
|
|
18
|
+
import os
|
|
19
|
+
import warnings
|
|
20
|
+
SUMO_WHEEL_HOME = None
|
|
21
|
+
try:
|
|
22
|
+
import sumo
|
|
23
|
+
SUMO_WHEEL_HOME = sumo.SUMO_HOME
|
|
24
|
+
if "SUMO_HOME" not in os.environ:
|
|
25
|
+
os.environ["SUMO_HOME"] = SUMO_WHEEL_HOME
|
|
26
|
+
except ImportError:
|
|
27
|
+
if "SUMO_HOME" not in os.environ:
|
|
28
|
+
warnings.warn("SUMO_HOME is not set and the eclipse-sumo wheel is not installed!")
|
|
29
|
+
if hasattr(os, "add_dll_directory"):
|
|
30
|
+
# since Python 3.8 the DLL search path has to be set explicitly see https://bugs.python.org/issue43173
|
|
31
|
+
if SUMO_WHEEL_HOME and os.path.exists(os.path.join(SUMO_WHEEL_HOME, "bin", "zlib.dll")):
|
|
32
|
+
os.add_dll_directory(os.path.abspath(os.path.join(SUMO_WHEEL_HOME, "bin")))
|
|
33
|
+
elif "SUMO_HOME" in os.environ and os.path.exists(os.path.join(os.environ["SUMO_HOME"], "bin", "zlib.dll")):
|
|
34
|
+
os.add_dll_directory(os.path.join(os.environ["SUMO_HOME"], "bin"))
|
|
35
|
+
|
|
36
|
+
from traci import connection, constants, exceptions, _vehicle, _person, _trafficlight, _simulation # noqa
|
|
37
|
+
from traci.step import StepManager, StepListener # noqa
|
|
38
|
+
from .libsumo import vehicle, simulation, person, trafficlight, edge # noqa
|
|
39
|
+
from .libsumo import TraCIStage, TraCINextStopData, TraCIReservation, TraCILogic, TraCIPhase, TraCIException # noqa
|
|
40
|
+
from .libsumo import TraCICollision, TraCISignalConstraint # noqa
|
|
41
|
+
from ._libsumo import TraCILogic_phases_get, TraCILogic_phases_set, TraCILogic_swiginit, new_TraCILogic # noqa
|
|
42
|
+
from .libsumo import * # noqa
|
|
43
|
+
|
|
44
|
+
DOMAINS = [
|
|
45
|
+
busstop, # noqa
|
|
46
|
+
calibrator, # noqa
|
|
47
|
+
chargingstation, # noqa
|
|
48
|
+
edge,
|
|
49
|
+
gui, # noqa
|
|
50
|
+
inductionloop, # noqa
|
|
51
|
+
junction, # noqa
|
|
52
|
+
lane, # noqa
|
|
53
|
+
lanearea, # noqa
|
|
54
|
+
meandata, # noqa
|
|
55
|
+
multientryexit, # noqa
|
|
56
|
+
overheadwire, # noqa
|
|
57
|
+
parkingarea, # noqa
|
|
58
|
+
person,
|
|
59
|
+
poi, # noqa
|
|
60
|
+
polygon, # noqa
|
|
61
|
+
rerouter, # noqa
|
|
62
|
+
route, # noqa
|
|
63
|
+
routeprobe, # noqa
|
|
64
|
+
simulation,
|
|
65
|
+
trafficlight,
|
|
66
|
+
variablespeedsign, # noqa
|
|
67
|
+
vehicle,
|
|
68
|
+
vehicletype, # noqa
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
_stepManager = StepManager()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def wrapAsClassMethod(func, module):
|
|
75
|
+
def wrapper(*args, **kwargs):
|
|
76
|
+
return func(module, *args, **kwargs)
|
|
77
|
+
return wrapper
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
TraCIStage.__attr_repr__ = _simulation.Stage.__attr_repr__
|
|
81
|
+
TraCIStage.__repr__ = _simulation.Stage.__repr__
|
|
82
|
+
TraCIStage.toXML = _simulation.Stage.toXML
|
|
83
|
+
TraCICollision.__attr_repr__ = _simulation.Collision.__attr_repr__
|
|
84
|
+
TraCICollision.__repr__ = _simulation.Collision.__repr__
|
|
85
|
+
|
|
86
|
+
TraCINextStopData.__attr_repr__ = _vehicle.StopData.__attr_repr__
|
|
87
|
+
TraCINextStopData.__repr__ = _vehicle.StopData.__repr__
|
|
88
|
+
|
|
89
|
+
TraCIReservation.__attr_repr__ = _person.Reservation.__attr_repr__
|
|
90
|
+
TraCIReservation.__repr__ = _person.Reservation.__repr__
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def set_phases(self, phases):
|
|
94
|
+
new_phases = [TraCIPhase(p.duration, p.state, p.minDur, p.maxDur, p.next, p.name) for p in phases]
|
|
95
|
+
TraCILogic_phases_set(self, new_phases)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def TraCILogic__init__(self, *args, **kwargs):
|
|
99
|
+
# Extract known keyword arguments or set to None if not provided
|
|
100
|
+
programID = kwargs.get('programID', args[0] if len(args) > 0 else None)
|
|
101
|
+
type_ = kwargs.get('type', args[1] if len(args) > 1 else None)
|
|
102
|
+
currentPhaseIndex = kwargs.get('currentPhaseIndex', args[2] if len(args) > 2 else None)
|
|
103
|
+
phases = kwargs.get('phases', args[3] if len(args) > 3 else None)
|
|
104
|
+
# subParameter = kwargs.get('subParameter', args[4] if len(args) > 4 else None)
|
|
105
|
+
|
|
106
|
+
# Update phases if provided
|
|
107
|
+
if phases:
|
|
108
|
+
new_phases = [TraCIPhase(p.duration, p.state, p.minDur, p.maxDur, p.next, p.name) for p in phases]
|
|
109
|
+
phases = new_phases
|
|
110
|
+
|
|
111
|
+
# Rebuild args including the extracted keyword arguments
|
|
112
|
+
args = (programID, type_, currentPhaseIndex, phases)
|
|
113
|
+
|
|
114
|
+
# Initialize with the original function
|
|
115
|
+
TraCILogic_swiginit(self, new_TraCILogic(*args))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# Override methods and properties
|
|
119
|
+
TraCILogic.__init__ = TraCILogic__init__
|
|
120
|
+
TraCILogic.phases = property(TraCILogic_phases_get, set_phases)
|
|
121
|
+
TraCILogic.getPhases = _trafficlight.Logic.getPhases
|
|
122
|
+
TraCILogic.__repr__ = _trafficlight.Logic.__repr__
|
|
123
|
+
TraCIPhase.__repr__ = _trafficlight.Phase.__repr__
|
|
124
|
+
TraCISignalConstraint.__repr__ = _trafficlight.Constraint.__repr__
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
exceptions.TraCIException = TraCIException
|
|
128
|
+
simulation.Stage = TraCIStage
|
|
129
|
+
vehicle.StopData = TraCINextStopData
|
|
130
|
+
person.Reservation = TraCIReservation
|
|
131
|
+
trafficlight.Phase = TraCIPhase
|
|
132
|
+
trafficlight.Logic = TraCILogic
|
|
133
|
+
vehicle.addFull = vehicle.add
|
|
134
|
+
vehicle.addLegacy = wrapAsClassMethod(_vehicle.VehicleDomain.addLegacy, vehicle)
|
|
135
|
+
vehicle.couldChangeLane = wrapAsClassMethod(_vehicle.VehicleDomain.couldChangeLane, vehicle)
|
|
136
|
+
vehicle.wantsAndCouldChangeLane = wrapAsClassMethod(_vehicle.VehicleDomain.wantsAndCouldChangeLane, vehicle)
|
|
137
|
+
vehicle.isStopped = wrapAsClassMethod(_vehicle.VehicleDomain.isStopped, vehicle)
|
|
138
|
+
vehicle.isStoppedParking = wrapAsClassMethod(_vehicle.VehicleDomain.isStoppedParking, vehicle)
|
|
139
|
+
vehicle.isStoppedTriggered = wrapAsClassMethod(_vehicle.VehicleDomain.isStoppedTriggered, vehicle)
|
|
140
|
+
vehicle.isAtBusStop = wrapAsClassMethod(_vehicle.VehicleDomain.isAtBusStop, vehicle)
|
|
141
|
+
vehicle.isAtContainerStop = wrapAsClassMethod(_vehicle.VehicleDomain.isAtContainerStop, vehicle)
|
|
142
|
+
vehicle.setBusStop = wrapAsClassMethod(_vehicle.VehicleDomain.setBusStop, vehicle)
|
|
143
|
+
vehicle.setContainerStop = wrapAsClassMethod(_vehicle.VehicleDomain.setContainerStop, vehicle)
|
|
144
|
+
vehicle.setParkingAreaStop = wrapAsClassMethod(_vehicle.VehicleDomain.setParkingAreaStop, vehicle)
|
|
145
|
+
vehicle.setChargingStationStop = wrapAsClassMethod(_vehicle.VehicleDomain.setChargingStationStop, vehicle)
|
|
146
|
+
vehicle.getRightFollowers = wrapAsClassMethod(_vehicle.VehicleDomain.getRightFollowers, vehicle)
|
|
147
|
+
vehicle.getRightLeaders = wrapAsClassMethod(_vehicle.VehicleDomain.getRightLeaders, vehicle)
|
|
148
|
+
vehicle.getLeftFollowers = wrapAsClassMethod(_vehicle.VehicleDomain.getLeftFollowers, vehicle)
|
|
149
|
+
vehicle.getLeftLeaders = wrapAsClassMethod(_vehicle.VehicleDomain.getLeftLeaders, vehicle)
|
|
150
|
+
vehicle.getLaneChangeStatePretty = wrapAsClassMethod(_vehicle.VehicleDomain.getLaneChangeStatePretty, vehicle)
|
|
151
|
+
vehicle._legacyGetLeader = True
|
|
152
|
+
person.removeStages = wrapAsClassMethod(_person.PersonDomain.removeStages, person)
|
|
153
|
+
_trafficlight.TraCIException = TraCIException
|
|
154
|
+
trafficlight.setLinkState = wrapAsClassMethod(_trafficlight.TrafficLightDomain.setLinkState, trafficlight)
|
|
155
|
+
trafficlight.getNemaPhaseCalls = wrapAsClassMethod(_trafficlight.TrafficLightDomain.getNemaPhaseCalls, trafficlight)
|
|
156
|
+
trafficlight.setNemaSplits = wrapAsClassMethod(_trafficlight.TrafficLightDomain.setNemaSplits, trafficlight)
|
|
157
|
+
trafficlight.setNemaOffset = wrapAsClassMethod(_trafficlight.TrafficLightDomain.setNemaOffset, trafficlight)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def addStepListener(listener):
|
|
161
|
+
return _stepManager.addStepListener(listener)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def removeStepListener(listenerID):
|
|
165
|
+
return _stepManager.removeStepListener(listenerID)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def isLibsumo():
|
|
169
|
+
return True
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def isLibtraci():
|
|
173
|
+
return False
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def init(port):
|
|
177
|
+
print("Warning! To make your code usable with traci and libsumo, please use traci.start instead of traci.init.")
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
hasGUI = simulation.hasGUI
|
|
181
|
+
load = simulation.load
|
|
182
|
+
isLoaded = simulation.isLoaded
|
|
183
|
+
getVersion = simulation.getVersion
|
|
184
|
+
executeMove = simulation.executeMove
|
|
185
|
+
|
|
186
|
+
_libsumo_step = simulation.step
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def simulationStep(time=0.):
|
|
190
|
+
_libsumo_step(time)
|
|
191
|
+
_stepManager.manageStepListeners(time)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
simulation.step = simulationStep
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def close():
|
|
198
|
+
simulation.close()
|
|
199
|
+
_stepManager.close()
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def start(cmd, port=None, numRetries=constants.DEFAULT_NUM_RETRIES, label="default", verbose=False,
|
|
203
|
+
traceFile=None, traceGetters=True, stdout=None, doSwitch=True):
|
|
204
|
+
if port is not None:
|
|
205
|
+
print("Warning! To make your code usable with traci and libsumo, do not set an explicit port.")
|
|
206
|
+
version = simulation.start(cmd)
|
|
207
|
+
if traceFile is not None:
|
|
208
|
+
if _stepManager.startTracing(traceFile, traceGetters, DOMAINS):
|
|
209
|
+
# simulationStep shows up as simulation.step
|
|
210
|
+
global _libsumo_step
|
|
211
|
+
_libsumo_step = _stepManager._addTracing(_libsumo_step, "simulation")
|
|
212
|
+
_stepManager._traceFile.write("import traci\n")
|
|
213
|
+
_stepManager.write("start", repr(cmd))
|
|
214
|
+
return version
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def setLegacyGetLeader(enabled):
|
|
218
|
+
vehicle._legacyGetLeader = enabled
|
libsumo/_libsumo.pyd
ADDED
|
Binary file
|