Skip to content
Ioannis Mavromatis edited this page Jul 6, 2020 · 4 revisions

Welcome to the DRIVE Simulation Framework wiki!

This wiki contains a quick guide of how to import a map from OpenStreetMap, generate a scenario with SUMO traffic generator, and import that scenario in DRIVE. It is assumed that a working SUMO installation exists in the user's system and that MATLAB is already installed. For more information about SUMO installation, please refer to the official documentation and the Eclipse SUMO website. Similarly, for MATLAB refer to MATLAB Support webpage

There are many different ways of exporting OpenStreetMap maps and generating SUMO scenarios. Over here, we will show one of them as an example. For more information, the documentation pages from OpenStreetMap and SUMO can be consulted.

More information about the DRIVE framework, how to modify the different scenario parameters, and the existing functionalities can be found in the User Manual, provided within the official repository.

Step 1: Download a map from OpenStreetMap

  1. Navigate to the desired map within OpenStreetMap Export Tool.
  2. Manually select the desired map area to be exported.
  3. Click the export button to download the map in an XML file format.

Step 2: Generate a scenario with SUMO traffic generator

  1. Convert the OpenStreetMap XML file into a SUMO network file. This file could be named as map.net.xml. An example command is:
netconvert --osm-files map.osm.xml --output-file map.net.xml --no-turnarounds --osm.elevation --sidewalks.guess --crossings.guess --remove-edges.by-vclass rail,rail_electric,bicycle,tram,rail_urban,bus --junctions.join
  1. Generate the buildings and foliage polygons from the OpenStreetMap XML file and the SUMO network file. This file could be named as map.poly.xml. An example command is:
polyconvert --osm-files map.osm.xml --net-file map.net.xml -o map.poly.xml
  1. In a text editor, create a file that contains all the vehicle types that will be used during the simulation time. This file could be named as additional.type.xml and it should look like this:
 <additional>
    <vTypeDistribution id="typedist1">
        <vType id="pas" vClass="passenger" impatience="0" probability="0.85" laneChangeModel="SL2015" maxSpeed="10" speedFactor="normc(1,0.1,0.2,2)" lcSublane="100"/>
        <vType id="amb" vClass="emergency" impatience="10" probability="0.15" laneChangeModel="SL2015" maxSpeed="20" speedFactor="2" color="1,0,0" lcStrategic="100" lcSpeedGain="100" lcSublane="100" lcPushy="1" lcImpatience="1"/>
    </vTypeDistribution>
 </additional>
  1. Generate the mobility traces for all the vehicle types defined before. This file could be named as mapVehicles.rou.xml. An example command is:
randomTrips.py --net-file=map.net.xml --additional-files=additional.type.xml --output-trip-file=map.trips.xml --route-file=map.rou.xml --begin=0 --end=2000 --verbose --trip-attributes="type=\"typedist\" departLane=\"best\" departSpeed=\"max\" departPos=\"random\""
  1. Generate the mobility traces for all the pedestrians. This file could be named as mapPedestrian.rou.xml. An example command is:
randomTrips.py --net-file=map.net.xml --additional-files=additional.type.xml --output-trip-file=mapPedestrian.trips.xml --route-file=mapPedestrian.rou.xml --begin=0 --end=2000 --verbose --pedestrians
  1. For all the above-generated files, create a SUMO configuration file. This file could be named as map.sumocfg. An example configuration file should look like this:
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/sumoConfiguration.xsd">
    <input>
        <net-file value="map.net.xml"/>
        <route-files value="mapVehicles.rou.xml,mapPedestrians.rou.xml"/>
		<additional-files value="map.poly.xml"/>
    </input>
    <processing>
        <ignore-route-errors value="true"/>
    </processing>
    <routing>
        <device.rerouting.adaptation-steps value="180"/>
    </routing>
</configuration>

Step 3: Install TraCI4Matlab

  1. Download TraCI4Matlab from MathWorks File Exchange website.
  2. Unzip downloaded zip file and add TraCI4Matlab folder to the MATLAB path.
  3. In a text editor, create a text file containing the path to the traci4matlab. jar file, as follows: TRACI4MATLABHOME/ traci4matlab. jar, where TRACI4MATLABHOME is the root folder of the downloaded TraCI4Matlab.
  4. Save the file with the name javaclasspath.txt in the preferences directory of Matlab. This can be identified using the prefdir command on the MATLAB command window.
  5. Restart MATLAB, so that the new static Java path takes effect.

Step 4: Compile MEX files

One of the external libraries used by DRIVE (segment_intersection), utilises several functions written in MEX C. These functions should be compiled as binary MEX files before the execution. To do that:

  1. Navigate to the root folder of DRIVE.
  2. Run the commands:
mex -v ./externalToolbox/segment_intersection/segment_intersect_test.c
mex -v ./externalToolbox/segment_intersection/segments_intersect_test.c
mex -v ./externalToolbox/segment_intersection/segments_intersect_test_vector.c

Step 5: Configure DRIVE simulation framework

  1. Download DRIVE from the official repository.
  2. Modify the simSettings.m file in the root folder of DRIVE:
    • SIMULATOR.sumoPath should point to the SUMO_HOME path, as configured during SUMO's installation.
    • SIMULATOR.scenario can be modified to show to the required scenario function (currently being found in modeToolbox directory).
    • SIMULATOR.parallelRun can be modified to choose parallel or serial execution of the framework.
    • sumo.routeFile should point to map.sumocfg SUMO configuration file generated in Step 2.6.
    • map.file should point to the OpenStreetMap XML file downloaded in Step 1.3.
    • The rest of the configuration parameters can be changed accordingly to the user's requirements.
  3. In simSettings.m file, change the sumo.vehicleTypes and sumo.vehicleTypeAbbreviation based on the vehicle types generated in Step 2.3.
  4. Add the different communication planes that will be used during the simulation:
    • All the communication planes should be either femtocell or macrocell planes.
    • All the configuration files should be added in the ratToolbox/available/ directory.
    • Downloading DRIVE from the official repository, one template for each communication plane can be found. These templates can be used as starting points and modified accordingly.

Step 6: Run the simulation

  1. In order to run the simulation, the runSimulator.m should be called from the DRIVE root folder.