Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Unable to run simulation in loop

Hi,
does the code work if you omit the loop?

Best regards,
Michael

Am 03.06.21 um 01:42 schrieb Shah Sultan:
> Hello to all
> 
> My basic simulation code is written below. While I am running the same code
> without restarting the Kernel, the following error message pops up.
> 
> *Could not connect to TraCI server at localhost:57376 [WinError 10061] No
> connection could be made because the target machine actively refused it*
> 
> What I understand from this error, there should be some way of closing the
> port which is in my code. And due to this error, I am unable to run the code
> in the loop. I also
> checked for the firewall. There is nothing except "Windows Defender" which I
> do not want to close. Is there any mistake in the code that I can rectify?
> 
> 
> import os, sys
> if 'SUMO_HOME' in os.environ:
>     tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
>     sys.path.append(tools)
>     shapes = os.path.join(os.environ['SUMO_HOME'], 'tools','sumolib',
> 'shapes')
>     sys.path.append(shapes)
> else:
>      sys.exit("please declare environment variable 'SUMO_HOME'")
> 
> import time
> import random
> 
> start_time=time.time()
> sumoBinary = "C:\Program Files (x86)/Eclipse/Sumo/bin/sumo-gui"
> sumoCmd = [sumoBinary, "-c", "roundabout-1.sumocfg", "--start"]
> 
> for i in range (5):
>    
>     random.seed()
> 
>    
>     import traci
>     traci.start(sumoCmd)
>     print("Starting SUMO")
>     traci.gui.setSchema("View #0", "real world")
>     traci.gui.setZoom("View #0", 190)
>     vehID = traci.vehicle.getIDList();
>     lights=traci.trafficlight.getIDList();
>     junctionID=traci.junction.getIDList();
>         
>     South_Light='1886728151'
>     North_Light='2273469505'
>     West_Light='268032054'
>     East_Light='454336319'
>    
>     print ("Simulation has been started")
>    
>     traci.trafficlight.setProgram(East_Light,1)
>     for step in range(5400):
>         traci.simulationStep()
>                
>     traci.close(sumoCmd)
>    
> print ("finish",'\n')
> 
> 
> 
> --
> Sent from: http://sumo-user-mailing-list.90755.n8.nabble.com/
> _______________________________________________
> sumo-user mailing list
> sumo-user@xxxxxxxxxxx
> To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/sumo-user
> 



Back to the top