mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 03:26:30 +00:00
Added images folder for wiki
This commit is contained in:
parent
2ab280b94e
commit
ab551cc429
@ -28,6 +28,7 @@ def init_grid(simulation_bounds, areas_number):
|
||||
traci.polygon.add(area.name, ar_bounds, (0, 255, 0))
|
||||
return grid
|
||||
|
||||
|
||||
def get_all_lanes() -> List[Lane]:
|
||||
lanes = []
|
||||
for lane_id in traci.lane.getIDList():
|
||||
@ -36,6 +37,7 @@ def get_all_lanes() -> List[Lane]:
|
||||
lanes.append(Lane(lane_id, polygon_lane, initial_max_speed))
|
||||
return lanes
|
||||
|
||||
|
||||
def parse_phase(phase_repr):
|
||||
duration = search('duration: {:f}', phase_repr)
|
||||
minDuration = search('minDuration: {:f}', phase_repr)
|
||||
@ -47,6 +49,7 @@ def parse_phase(phase_repr):
|
||||
|
||||
return Phase(duration[0], minDuration[0], maxDuration[0], phaseDef)
|
||||
|
||||
|
||||
def add_data_to_areas(areas: List[Area]):
|
||||
lanes = get_all_lanes()
|
||||
for area in areas:
|
||||
@ -63,6 +66,7 @@ def add_data_to_areas(areas: List[Area]):
|
||||
logics.append(Logic(l, phases))
|
||||
area.add_tl(TrafficLight(tl_id, logics))
|
||||
|
||||
|
||||
def compute_vehicle_emissions(veh_id):
|
||||
return (traci.vehicle.getCOEmission(veh_id)
|
||||
+traci.vehicle.getNOxEmission(veh_id)
|
||||
@ -80,6 +84,7 @@ def get_all_vehicles() -> List[Vehicle]:
|
||||
vehicles.append(vehicle)
|
||||
return vehicles
|
||||
|
||||
|
||||
def get_emissions(grid: List[Area], vehicles: List[Vehicle], current_step, config, logger):
|
||||
for area in grid:
|
||||
vehicle_emissions = 0
|
||||
@ -165,7 +170,7 @@ def main(args):
|
||||
# > py ./emissions.py -f configs/config1.json -save
|
||||
# will load the configuration file "config1.json" and save logs into the logs directory
|
||||
|
||||
# > py ./emissions.py -f configs/config1.json -save & py ./emissions.py -f configs/config1.json -save -ref
|
||||
# > py ./emissions.py -f configs/config1.json -save -ref & py ./emissions.py -f configs/config1.json -save
|
||||
# same as above but also launches a reference simulation by using -ref option
|
||||
|
||||
config = Config()
|
||||
@ -180,5 +185,6 @@ def main(args):
|
||||
|
||||
run(config, logger)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
||||
|
Loading…
Reference in New Issue
Block a user