Trying to run the SUMO simulation using TraCI protocol:
import os, sys
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'")
sumoBinary = "C:/Users/User/Desktop/Thesis_task/Trial_task/trial.sumocfg"
sumoCmd = [sumoBinary, "-c", "trial.sumocfg", '--log', 'logfile.txt']
import traci
traci.start(sumoCmd)
step = 0
while step < 1000:
traci.simulationStep()
if traci.inductionloop.getLastStepVehicleNumber("0") > 0:
traci.trafficlight.setRedYellowGreenState("0", "GrGr")
step += 1
traci.close()
I am trying to connect the TraCI, but it is throwing this error:
OSError: [WinError 193] %1 is not a valid Win32 application
I have installed all the dependencies correctly, and also have the supporting Python version running on my machine. I followed a few older StackOverflow solutions, but none of them worked in my case.
Per the TraCI documentation:
First you compose the command line to start either
sumo
orsumo-gui
(leaving out the option which was needed before 0.28.0):sumoBinary = "/path/to/sumo-gui" sumoCmd = [sumoBinary, "-c", "yourConfiguration.sumocfg"]
However, your sumoBinary
variable does not point to either of those two programs, instead it points to your trial.sumocfg
file:
sumoBinary = "C:/Users/User/Desktop/Thesis_task/Trial_task/trial.sumocfg"
Which is clearly not an executable program, hence the error.