mirror of
https://github.com/Ahp06/SUMO_Emissions.git
synced 2024-11-22 03:26:30 +00:00
Add sumoconfig template
This commit is contained in:
parent
dc4444a24e
commit
39428c2f93
@ -45,6 +45,7 @@ def load_sumoconfig_template(simulation_name):
|
|||||||
def generate_scenario(osm_file, out_path, scenario_name):
|
def generate_scenario(osm_file, out_path, scenario_name):
|
||||||
net_template = load_netconvert_template(osm_file, scenario_name)
|
net_template = load_netconvert_template(osm_file, scenario_name)
|
||||||
poly_template = load_polyconvert_template(osm_file, 'typemap/osmPolyconvert.typ.xml', scenario_name)
|
poly_template = load_polyconvert_template(osm_file, 'typemap/osmPolyconvert.typ.xml', scenario_name)
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as tmpdirname:
|
with tempfile.TemporaryDirectory() as tmpdirname:
|
||||||
netconfig = os.path.join(tmpdirname, f'{scenario_name}.netcfg')
|
netconfig = os.path.join(tmpdirname, f'{scenario_name}.netcfg')
|
||||||
polyconfig = os.path.join(tmpdirname, f'{scenario_name}.polycfg')
|
polyconfig = os.path.join(tmpdirname, f'{scenario_name}.polycfg')
|
||||||
@ -86,12 +87,27 @@ def generate_mobility(path, name):
|
|||||||
randomTrips.main(randomTrips.get_options(options))
|
randomTrips.main(randomTrips.get_options(options))
|
||||||
|
|
||||||
|
|
||||||
def generate_all(osm_file, output_path):
|
def generate_sumo_configuration(path, scenario_name):
|
||||||
output_dir = os.path.dirname(output_path)
|
sumo_template = load_sumoconfig_template(scenario_name)
|
||||||
simulation_name = os.path.basename(output_path)
|
sumo_template.write(os.path.join(path, f'{scenario_name}.sumocfg'))
|
||||||
generate_scenario(osm_file, output_dir, simulation_name)
|
|
||||||
generate_mobility(output_dir, simulation_name)
|
|
||||||
|
def generate_all(osm_file, output_path, simulation_name):
|
||||||
|
simulation_dir = os.path.join(output_path, simulation_name)
|
||||||
|
logs_dir = os.path.join(simulation_dir, 'log')
|
||||||
|
if not os.path.exists(simulation_dir):
|
||||||
|
os.mkdir(simulation_dir)
|
||||||
|
os.mkdir(logs_dir)
|
||||||
|
generate_scenario(osm_file, simulation_dir, simulation_name)
|
||||||
|
generate_mobility(simulation_dir, simulation_name)
|
||||||
|
generate_sumo_configuration(simulation_dir, simulation_name)
|
||||||
|
# Move all logs to logdir
|
||||||
|
for f in os.listdir(simulation_dir):
|
||||||
|
if os.path.splitext(f)[1] == '.log':
|
||||||
|
shutil.move(os.path.join(simulation_dir, f), logs_dir)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pass
|
path = '/tmp/scenario/'
|
||||||
|
osm = '/tmp/scenario/map.osm'
|
||||||
|
generate_all(osm, path, 'foo')
|
||||||
|
@ -8,13 +8,14 @@
|
|||||||
</input>
|
</input>
|
||||||
|
|
||||||
<output>
|
<output>
|
||||||
<output-prefix value="simul." />
|
<!--<output-prefix value="simul." />-->
|
||||||
<output-file value="net.xml"/>
|
<output-file value="simul.net.xml"/>
|
||||||
</output>
|
</output>
|
||||||
|
|
||||||
<tls_building>
|
<tls_building>
|
||||||
<tls.join value="true"/>
|
<tls.join value="true"/>
|
||||||
<tls.guess-signals value="true"/>
|
<tls.guess-signals value="true"/>
|
||||||
|
<tls.discard-simple value="true" />
|
||||||
<tls.default-type value="actuated"/>
|
<tls.default-type value="actuated"/>
|
||||||
<tls.min-dur value="5"/>
|
<tls.min-dur value="5"/>
|
||||||
<tls.max-dur value="30"/>
|
<tls.max-dur value="30"/>
|
||||||
@ -24,10 +25,15 @@
|
|||||||
<ramps.guess value="true"/>
|
<ramps.guess value="true"/>
|
||||||
</ramp_guessing>
|
</ramp_guessing>
|
||||||
|
|
||||||
|
<junctions>
|
||||||
|
<junctions.join value="true"/>
|
||||||
|
</junctions>
|
||||||
|
|
||||||
<processing>
|
<processing>
|
||||||
<geometry.remove value="true"/>
|
<geometry.remove value="true"/>
|
||||||
<roundabouts.guess value="true"/>
|
<roundabouts.guess value="true"/>
|
||||||
<junctions.join value="true"/>
|
|
||||||
|
<!--
|
||||||
<junctions.limit-turn-speed value="1"/>
|
<junctions.limit-turn-speed value="1"/>
|
||||||
<crossings.guess value="true"/>
|
<crossings.guess value="true"/>
|
||||||
<walkingareas value="false"/>
|
<walkingareas value="false"/>
|
||||||
@ -38,7 +44,7 @@
|
|||||||
<no-internal-links value="false"/>
|
<no-internal-links value="false"/>
|
||||||
<ignore-errors value="false"/>
|
<ignore-errors value="false"/>
|
||||||
<ignore-errors.connections value="false"/>
|
<ignore-errors.connections value="false"/>
|
||||||
<show-errors.connections-first-try value="true"/>
|
<show-errors.connections-first-try value="true"/>-->
|
||||||
</processing>
|
</processing>
|
||||||
|
|
||||||
<building_defaults>
|
<building_defaults>
|
||||||
|
@ -1,30 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
|
||||||
Monaco SUMO Traffic (MoST) Scenario
|
|
||||||
Copyright (C) 2018
|
|
||||||
Lara CODECA
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed static the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/polyconvertConfiguration.xsd">
|
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/polyconvertConfiguration.xsd">
|
||||||
|
|
||||||
<input>
|
<input>
|
||||||
<net-file value="simul.net.xml"/>
|
<net-file value="simul.net.xml"/>
|
||||||
<osm-files value="simul.raw.osm"/>
|
<osm-files value="simul.raw.osm"/>
|
||||||
<osm.keep-full-type value="true"/>
|
<!--<osm.keep-full-type value="true"/>-->
|
||||||
<type-file value="typemap/osmPolyconvert.typ.xml"/>
|
<type-file value="typemap/osmPolyconvert.typ.xml"/>
|
||||||
</input>
|
</input>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user