Hi! I'm working on a traffic simulation with SUMO for my master degree's thesis.
I have to simulate the impact of the insertion of a VMP on an intersection; my idea is to use TraCI, commanding that at a given time the lane of an edge will be disallowed for all vehicles type (until the end of a certain time period).
My main problem is that i don't know how to program, and to use TraCI you need to know the Python language.
I submit the code i wrote:
import os
import sys
import optparse
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' ")
from sumolib import checkBinary
import traci
def get_options():
opt_parser = optparse.OptionParser()
opt_parser.add_option("--nogui", action=""> default=False, help="run the commandline version of sumo")
options, args = opt_parser.parse_args()
return options
import traci
traci.start(sumoCmd)
step=0
while step < 1000:
traci.simulationStep()
if traci.inductionloop.getLastStepVehicleNumber("0") > 0:
traci.setDisallowed(self,1105,all)
step += 1
traci.close(False)
if _name_ ** "_main_":
options = get_options()
if options.nogui:
sumoBinary = checkBinary('sumo')
else:
sumoBinary = checkBinary('sumo-gui')
traci.start([sumoBinary, "-c", "Configuration_file.sumo.cfg",
"--tripinfo-output", "Prova_Piombino.trips.xml"])
run()
Anyone can help me? Did i wrote it correctly? I collected the informations here and there on internet.
Thank you!
Regards
Alessio Amadei