mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 03:26:30 +00:00
Change absolute to relative path using SUMO_HOME
This commit is contained in:
parent
3db7647d0b
commit
2811ad7c22
@ -5,28 +5,18 @@ Created on 11 oct. 2018
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
import traci
|
|
||||||
from traci import polygon
|
|
||||||
|
|
||||||
'''Launch traci'''
|
'''Launch traci'''
|
||||||
if 'SUMO_HOME' in os.environ:
|
if 'SUMO_HOME' in os.environ:
|
||||||
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
|
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
|
||||||
sys.path.append(tools)
|
sys.path.append(os.path.join(os.environ['SUMO_HOME'], tools))
|
||||||
|
sumoBinary = os.path.join(os.environ['SUMO_HOME'], 'bin', 'sumo-gui')
|
||||||
|
sumoCmd = [sumoBinary, "-c", "mulhouse_simulation/osm.sumocfg"]
|
||||||
else:
|
else:
|
||||||
sys.exit("please declare environment variable 'SUMO_HOME'")
|
sys.exit("please declare environment variable 'SUMO_HOME'")
|
||||||
|
|
||||||
sumoBinary = "C:\\Users\\Admin\\AppData\\Roaming\\Microsoft\\Installer\\{A63B306E-2B15-11E1-88C8-028037EC0200}\\sumogui.exe"
|
import traci
|
||||||
sumoCmd = [sumoBinary, "-c", "mulhouse_simulation\\osm.sumocfg"]
|
from traci import polygon
|
||||||
traci.start(sumoCmd)
|
|
||||||
|
|
||||||
'''Variables and constants declaration'''
|
|
||||||
cells_step = 10
|
|
||||||
boundary = traci.simulation.getNetBoundary()
|
|
||||||
areas = [[0] * cells_step for _ in range(cells_step)]
|
|
||||||
emissionsArea = [[0] * cells_step for _ in range(cells_step)]
|
|
||||||
width = boundary[1][0] / cells_step # width/step
|
|
||||||
height = boundary[1][1] / cells_step # height/step
|
|
||||||
CO2_threshold = 500000
|
|
||||||
|
|
||||||
|
|
||||||
'''creating multiple zones of equal sizes'''
|
'''creating multiple zones of equal sizes'''
|
||||||
@ -77,10 +67,23 @@ def showEmissions():
|
|||||||
+ " = " , str(emissionsArea[i][j]) + " mg" )
|
+ " = " , str(emissionsArea[i][j]) + " mg" )
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
'''Simulation launch'''
|
'''Simulation launch'''
|
||||||
|
traci.start(sumoCmd)
|
||||||
|
|
||||||
|
'''Variables and constants declaration'''
|
||||||
|
cells_step = 10
|
||||||
|
boundary = traci.simulation.getNetBoundary()
|
||||||
|
areas = [[0] * cells_step for _ in range(cells_step)]
|
||||||
|
emissionsArea = [[0] * cells_step for _ in range(cells_step)]
|
||||||
|
width = boundary[1][0] / cells_step # width/step
|
||||||
|
height = boundary[1][1] / cells_step # height/step
|
||||||
|
CO2_threshold = 500000
|
||||||
|
|
||||||
step = 0
|
step = 0
|
||||||
init_grid()
|
init_grid()
|
||||||
while step < 100: # while traci.simulation.getMinExpectedNumber() > 0:
|
while traci.simulation.getMinExpectedNumber() > 0:
|
||||||
|
print("Vehicle count :", traci.vehicle.getIDCount())
|
||||||
traci.simulationStep()
|
traci.simulationStep()
|
||||||
getAllEmissions()
|
getAllEmissions()
|
||||||
step += 1
|
step += 1
|
||||||
@ -89,4 +92,3 @@ while step < 100: # while traci.simulation.getMinExpectedNumber() > 0:
|
|||||||
showEmissions()
|
showEmissions()
|
||||||
traci.close()
|
traci.close()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user