Skip to main content

SUMO Emission of Vehicles | VANETs

Emission of Gases by Vehicles using SUMO

In this post, we will be discussing how floating cars can emit gases namely 
Carbon Monoxide (CO)
Carbon Dioxide (CO2)
Hydro Carbons (HC)
Particle Matter (PMx)
Nitrous Oxide (NOx)

SUMO generates this emission of gases based on the EU4 norms. How to capture these gases in our simulation? 

The following video contains complete information


Prerequisites

1. SUMO to be installed in Ubuntu  (SUMO installation)
2. Python3 to be installed
3. Knowledge of XML files

The following is the image of the road design I have created, 
there are a totally of 6 junctions ( 0 to 5) and two edges from one junction to another intersection (each edge has two lanes). All the junctions are priority junctions except 2 and 5. These junctions are traffic light junctions.

VANET
Custom road design in SUMO

We are going to design a custom road. 

In our machine, I will store all the files in a folder called 
/home/pradeepkumar/customroad
Step 1: Creation of a node file that contains the information about the junctions
Extension of the file would be .nod.xml

<nodes> <!-- The opening tag -->
  <node id="0" x="400.0" y="700.0" type="priority"/> <!-- def. of node "0" -->
  <node id="1" x="700.0" y="700.0" type="priority"/> <!-- def. of node "1" -->
  <node id="2" x="900.0" y="500.0" type="traffic_light"/> 
  <node id="3" x="700.0" y="300.0" type="priority"/>
  <node id="4" x="400.0" y="300.0" type="priority"/> <!-- def. of node "4" -->
  <node id="5" x="200.0" y="500.0" type="traffic_light"/> 
</nodes> <!-- The closing tag -->

Step 2: Creation of edges (roads connecting the junction).
Extn: .edg.xml

<edges>
  <edge id="l01" from="0" to="1" priority="2" numLanes="2" speed="11.11"/>
  <edge id="r01" from="1" to="0" priority="3" numLanes="2" speed="13.89"/>

  <edge id="u12" from="1" to="2" priority="1" numLanes="2" speed="11.11"/>
  <edge id="d12" from="2" to="1" priority="2" numLanes="2" speed="11.11"/>
 
  <edge id="d23" from="2" to="3" priority="3" numLanes="2" speed="13.89"/>
  <edge id="u23" from="3" to="2" priority="1" numLanes="2" speed="11.11"/>

  <edge id="l43" from="3" to="4" priority="2" numLanes="2" speed="11.11"/>
  <edge id="r43" from="4" to="3" priority="3" numLanes="2" speed="13.89"/>
 
  <edge id="d54" from="5" to="4" priority="1" numLanes="2" speed="11.11"/>
  <edge id="u54" from="4" to="5" priority="2" numLanes="2" speed="11.11"/>
 
  <edge id="d05" from="0" to="5" priority="3" numLanes="2" speed="13.89"/>
  <edge id="u05" from="5" to="0" priority="1" numLanes="2" speed="11.11"/>
 
  <edge id="l52" from="5" to="2" priority="3" numLanes="2" speed="13.89"/>
  <edge id="r52" from="2" to="5" priority="1" numLanes="2" speed="11.11"/>

</edges>

Step 3: create a net.xml file using the node and edge files.

$ netconvert -n file.nod.xml -e file.edg.xml -o file.net.xml
$ The location of the file in my machine is /home/pradeepkumar/customroad/ 

Step 4: Creation of random trips
There is a file called 
tools/randomTrips.py that can generate vehicles on the network

$ python3 ../sumo/tools/randomTrips.py -n file.net.xml -r file.rou.xml -b 0 -e 1000 -l 

Step 5: Create a file called file.sumo.cfg (to run with sumo for air pollution)
<configuration>
<input>
<net-file value="file.net.xml"/> 
<route-files value="file.rou.xml"/>
</input>
<time>
<begin value="0"/>
<end value="1000"/>
<step-length value="0.5"/>
</time>
</configuration>

$ sumo-gui file.sumo.cfg

Here is the screenshot of the roads and the traffic light junctions
SUMO
SUMO

SUMO VANET
SUMO Traffic light junction


$ sumo -c file.sumo.cfg --emission-output emission.xml --emission-output.geo --battery-output battery.xml --fcd-output car.xml --summary-output summary.xml --collision-output collision.xml --statistic-output stats.xml 

To convert the XML files into CSV files, here is the step

Convert the emission.xml to emission.csv file

$ python3 ../sumo/tools/xml/xml2csv.py emission.xml -o emission.csv

Here is the file content of the emission.csv file. Using these data, we can predict or analyze various results of the emission of gases to counter air pollution. These kinds of systems can be demonstrated as Automotive cyber-physical systems 

emission
Emission data of floating cars from SUMO simulation


This example shows the emission data of floating cars in SUMO simulation. 

The roads are user-designed roads. 

Thanks for watching 

https://github.com/tspradeepkumar
https://www.nsnam.com

Comments

Popular posts from this blog

Installing ns3 in Ubuntu 22.04 | Complete Instructions

In this post, we are going to see how to install ns-3.36.1 in Ubuntu 22.04. You can follow the video for complete details Tools used in this simulation: NS3 version ns-3.36.1  OS Used: Ubuntu 22.04 LTS Installation of NS3 (ns-3.36.1) There are some changes in the ns3 installation procedure and the dependencies. So open a terminal and issue the following commands Step 1:  Prerequisites $ sudo apt update In the following packages, all the required dependencies are taken care and you can install all these packages for the complete use of ns3. $ sudo apt install g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libc...

Installation of NS2 (ns-2.35) in Ubuntu 20.04

Installation of NS2 (ns-2.35) in Ubuntu 20.04 LTS Step 1: Install the basic libraries like      $] sudo apt install build-essential autoconf automake libxmu-dev Step 2: install gcc-4.8 and g++-4.8 open the file using sudo mode $] sudo nano /etc/apt/sources.list Include the following line deb http://in.archive.ubuntu.com/ubuntu bionic main universe $] sudo apt update $] sudo apt install gcc-4.8 g++-4.8 Step 3:  Unzip the ns2 packages to home folder $] tar zxvf ns-allinone-2.35.tar.gz $] cd ns-allinone-2.35/ns-2.35 Modify the following make files. ~ns-2.35/Makefile.in Change @CC@ to gcc-4.8 change @CXX@ to g++-4.8 ~nam-1.15/Makefile.in ~xgraph-12.2/Makefile.in ~otcl-1.14/Makefile.in Change in all places  @CC@ to gcc-4.8 @CPP@ or @CXX@ to g++-4.8 open the file: ~ns-2.35/linkstate/ls.h Change at the Line no 137  void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to This void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } All changes ...

Installation of NS2 in Ubuntu 22.04 | NS2 Tutorial 2

NS-2.35 installation in Ubuntu 22.04 This post shows how to install ns-2.35 in Ubuntu 22.04 Operating System Since ns-2.35 is too old, it needs the following packages gcc-4.8 g++-4.8 gawk and some more libraries Follow the video for more instructions So, here are the steps to install this software: To download and extract the ns2 software Download the software from the following link http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.35/ns-allinone-2.35.tar.gz/download Extract it to home folder and in my case its /home/pradeepkumar (I recommend to install it under your home folder) $ tar zxvf ns-allinone-2.35.tar.gz or Right click over the file and click extract here and select the home folder. $ sudo apt update $ sudo apt install build-essential autoconf automake libxmu-dev gawk To install gcc-4.8 and g++-4.8 $ sudo gedit /etc/apt/sources.list make an entry in the above file deb http://in.archive.ubuntu.com/ubuntu/ bionic main universe $ sudo apt update Since, it...