Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traci Variable Speed Signs - how to synchronize adjustment? #5579

Closed
juanwulu opened this issue May 6, 2019 · 5 comments
Closed

Traci Variable Speed Signs - how to synchronize adjustment? #5579

juanwulu opened this issue May 6, 2019 · 5 comments
Labels

Comments

@juanwulu
Copy link

juanwulu commented May 6, 2019

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!

@namdre
Copy link
Contributor

namdre commented May 6, 2019

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.

@namdre namdre closed this as completed May 6, 2019
@namdre namdre added the question label May 6, 2019
@gyq18
Copy link

gyq18 commented Aug 23, 2019

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?

@namdre
Copy link
Contributor

namdre commented Aug 26, 2019

edge.setMaxSpeed is applied to all lanes. The change lanes individually, use traci.lane.setMaxSpeed

@gyq18
Copy link

gyq18 commented Aug 26, 2019

thanks a lot!

@Jinbo0201
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants