You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello everyone. I'm new to SUMO community and recently while working on one of my project, I've been trying to change variable speed signs randomly with a fixed step size. here are the test_codes:
from future import print_function
import numpy as np
import sys, os, time
import traci
from sumolib import checkBinary
import xml.etree.ElementTree as ET
from xml.dom import minidom
if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'],'tools')
sys.path.append(tools)
else:
sys.exit("please declare environment variable 'SUMO_HOME'")
def vsl(time,speed):
tree =ET.parse(projectFile+'vsl.def.xml')
root = tree.getroot()
for element in root.findall('step'):
element.set('speed',str(speed))
element.set('time', str(time))
tree.write(projectFile+'vsl.def.xml')
return
for i in range(9300):
if i % 100 == 0:
step = traci.simulation.getTime()
vsl(int(step)+1, 8.33 + np.random.rand()*(11.11-8.33))
traci.simulationStep()
scenario.close()
However, the signs won't change although the vsl.def.xml has already changed. How can i fix this problem? Thx!
The text was updated successfully, but these errors were encountered:
variableSpeedSigns (and all other things from an additional-file) are loaded once at the start of the simulation so updating them afterwards has no effect.
However, you can simply call traci.edge.setMaxSpeed (or traci.lane.setMaxSpeed) to modify speed limits dynamically.
Does "traci.edge.setMaxSpeed" set a new maximum speed (in m/s) for all lanes of the edge? If I want to set two lanes of an edge with different speed limit, how can I achive this?
Hello everyone. I'm new to SUMO community and recently while working on one of my project, I've been trying to change variable speed signs randomly with a fixed step size. here are the test_codes:
from future import print_function
import numpy as np
import sys, os, time
import traci
from sumolib import checkBinary
import xml.etree.ElementTree as ET
from xml.dom import minidom
if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'],'tools')
sys.path.append(tools)
else:
sys.exit("please declare environment variable 'SUMO_HOME'")
projectFile = './Project/'
sumoBinary = "sumo-gui"
seeds = 20190505
traci.start([sumoBinary, '-c', projectFile + 'ramp.sumo.cfg','--start','--seed',
str(seeds), '--emergencydecel.warning-threshold', '1.1', '--quit-on-end'], label='training')
scenario = traci.getConnection('training')
def vsl(time,speed):
tree =ET.parse(projectFile+'vsl.def.xml')
root = tree.getroot()
for element in root.findall('step'):
element.set('speed',str(speed))
element.set('time', str(time))
tree.write(projectFile+'vsl.def.xml')
return
for i in range(9300):
if i % 100 == 0:
step = traci.simulation.getTime()
vsl(int(step)+1, 8.33 + np.random.rand()*(11.11-8.33))
traci.simulationStep()
scenario.close()
However, the signs won't change although the vsl.def.xml has already changed. How can i fix this problem? Thx!
The text was updated successfully, but these errors were encountered: