Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/tests/complex/traci/bugs/ticket3522/runner.py
169708 views
1
#!/usr/bin/env python
2
# Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
# Copyright (C) 2008-2025 German Aerospace Center (DLR) and others.
4
# This program and the accompanying materials are made available under the
5
# terms of the Eclipse Public License 2.0 which is available at
6
# https://www.eclipse.org/legal/epl-2.0/
7
# This Source Code may also be made available under the following Secondary
8
# Licenses when the conditions for such availability set forth in the Eclipse
9
# Public License 2.0 are satisfied: GNU General Public License, version 2
10
# or later which is available at
11
# https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
14
# @file runner.py
15
# @author Michael Behrisch
16
# @author Jakob Erdmann
17
# @date 2009-11-04
18
19
from __future__ import absolute_import
20
from __future__ import print_function
21
22
import os
23
import sys
24
25
if "SUMO_HOME" in os.environ:
26
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
27
import sumolib # noqa
28
import traci # noqa
29
30
ix = sys.argv.index(":")
31
saveParams = sys.argv[1:ix]
32
loadParams = sys.argv[ix + 1:]
33
34
if '--mesosim' in loadParams:
35
saveParams.append('--mesosim')
36
37
# SAVE
38
sumoBinary = sumolib.checkBinary('sumo')
39
traci.start([sumoBinary] + saveParams)
40
tend = 55.
41
traci.simulationStep()
42
traci.vehicletype.setImperfection("DEFAULT_VEHTYPE", 1.0)
43
traci.vehicletype.setImperfection("t1", 1.0)
44
traci.vehicletype.setDecel("t1", 2.0)
45
traci.vehicletype.setAccel("t1", 3.0)
46
traci.vehicletype.setApparentDecel("t1", 6.0)
47
traci.vehicletype.setEmergencyDecel("t1", 7.0)
48
# traci.vehicletype.setEmissionClass("t1", ??)
49
traci.vehicletype.setTau("t1", 1.3)
50
while traci.simulation.getTime() < tend - 10.:
51
traci.simulationStep()
52
53
traci.vehicle.setImperfection("veh2", 1.0)
54
traci.vehicle.setDecel("veh2", 2.0)
55
traci.vehicle.setAccel("veh2", 3.0)
56
traci.vehicle.setApparentDecel("veh2", 6.0)
57
traci.vehicle.setEmergencyDecel("veh2", 7.0)
58
# traci.vehicle.setEmissionClass("veh2", ??)
59
traci.vehicle.setTau("veh2", 1.3)
60
61
print("Get before save....")
62
63
print("vtype")
64
print(traci.vehicletype.getImperfection("DEFAULT_VEHTYPE"), "== 1.0 (imperfection)")
65
print(traci.vehicletype.getImperfection("t1"), "== 1.0 (imperfection)")
66
print(traci.vehicletype.getDecel("t1"), "== 2.0 (decel)")
67
print(traci.vehicletype.getAccel("t1"), "== 3.0 (accel)")
68
print(traci.vehicletype.getApparentDecel("t1"), "== 6.0 (apparentDecel)")
69
print(traci.vehicletype.getEmergencyDecel("t1"), "== 7.0 (emergencyDecel)")
70
# print(traci.vehicletype.getEmissionClass("t1") , " == ?? (emissionClass)")
71
print(traci.vehicletype.getTau("t1"), "== 1.3 (tau)")
72
73
print("vehicle")
74
print(traci.vehicle.getImperfection("veh0"), "== 1.0 (imperfection)")
75
print(traci.vehicle.getImperfection("veh2"), "== 1.0 (imperfection)")
76
print(traci.vehicle.getDecel("veh2"), "== 2.0 (decel)")
77
print(traci.vehicle.getAccel("veh2"), "== 3.0 (accel)")
78
print(traci.vehicle.getApparentDecel("veh2"), "== 6.0 (apparentDecel)")
79
print(traci.vehicle.getEmergencyDecel("veh2"), "== 7.0 (emergencyDecel)")
80
# print(traci.vehicle.getEmissionClass("veh2") , " == ?? (emissionClass)")
81
print(traci.vehicle.getTau("veh2"), "== 1.3 (tau)")
82
83
while traci.simulation.getTime() < tend:
84
traci.simulationStep()
85
traci.close()
86
87
88
# LOAD
89
90
traci.start([sumoBinary] + loadParams)
91
tend = 300.
92
93
print("Get after load....")
94
print("vtype")
95
print(traci.vehicletype.getImperfection("DEFAULT_VEHTYPE"), "== 1.0")
96
print(traci.vehicletype.getImperfection("t1"), "== 1.0")
97
print(traci.vehicletype.getDecel("t1"), "== 2.0")
98
print(traci.vehicletype.getAccel("t1"), "== 3.0")
99
print(traci.vehicletype.getApparentDecel("t1"), "== 6.0")
100
print(traci.vehicletype.getEmergencyDecel("t1"), "== 7.0")
101
# print(traci.vehicletype.getEmissionClass("t1") , " == ??")
102
print(traci.vehicletype.getTau("t1"), "== 1.3")
103
104
print("vehicle")
105
print(traci.vehicle.getImperfection("veh0"), "== 1.0")
106
print(traci.vehicle.getImperfection("veh2"), "== 1.0")
107
print(traci.vehicle.getDecel("veh2"), "== 2.0")
108
print(traci.vehicle.getAccel("veh2"), "== 3.0")
109
print(traci.vehicle.getApparentDecel("veh2"), "== 6.0")
110
print(traci.vehicle.getEmergencyDecel("veh2"), "== 7.0")
111
# print(traci.vehicle.getEmissionClass("veh2") , " == ??")
112
print(traci.vehicle.getTau("veh2"), "== 1.3")
113
114
while traci.simulation.getTime() < tend:
115
traci.simulationStep()
116
traci.close()
117
118