CianGrimnir / project3V2V

Project 3, for scalable computing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CS7NS1 Scalable Computing Project 3: V2V Network

Group 17

  • Azin Makaranth
  • Omkar Pramod Padir
  • Rakesh N

Overview

Multiple vehicle instances (vehicle.py) will be running on each pi with 'n' numbers of coupled sensors defined under (sensor_data_generators.py). Each sensor type is associated with a range of possible values and broadcast to the neighbouring vehicles via sockets. The following sensor types with corresponding ranges as defined:

  • pressure (PSI) : [0, 100]
  • speed (km/h) : [40, 80]
  • light : ['day', 'night']
  • Fuel (%) : [40, 80]
  • Proximity (position) : [left, right, front, behind]
  • Brake : [0, 4]
  • heartrate (BPM) : [40, 120]
  • GPS (gps coordinates) : latitude - [-90, 90], longitude - [-180, 180]
  • proximity (m) : [1, 50]

Each Pi can additionally run a single infrastructure instance (vehicle.py --node_type=i) which acts as both a peer (via sockets) to other vehicles. At minimum, conformant endpoints serve a JSON object with speed, wiper speed, tyre pressure and fuel data, as well as a list of other known peers.

Dependencies

All the nodes are implemented in Python 3. Vehicle and sensors nodes uses the standard library,Flask for providing external API, geopy package is used to calculate the distance between two nodes/vehicles/infra, pycryptodome is used for adding encryption to the sending data.

Installation

$ pip3 install -r requirements.txt

Following packages will be installed -

$ Packages to be installed -
    geopy
    flask
    pycryptodome

Running/Automating the Simulation

# For running a vehicle node
$ python3 vehicle.py --listen_port 33535 --sending_port 34535 --vehicle_id 4 --latitude 53.37527718212891 --longitude -6.285589418171051 --api_port 5001
# For running a Infra node
$ python3 vehicle.py --node_type i --listen_port 33555 --sending_port 34555 --vehicle_id 2 --latitude 53.375099182128906 --longitude -6.285900115966797 --api_port 5000 

OR

# run screen script to simulate the v2v network.
$ screen -c simulate_network
# To kill the screen session
Press - Ctrl a+d to detach
$ screen -ls
    There is a screen on:
          49949.pts-5.ranair-VirtualBox	(09/12/21 14:58:45)	(Detached)
    1 Socket in /run/screen/S-ranair.
# kill the session
$ screen -X -S 49949.pts-5.ranair-VirtualBox kill

Running the script should create the following view:

----------------------------------------------
| Infra node       |                         |
|-------------------     Vehicle node        |
| Vehicle node     |-------------------------|
|------------------|     Vehicle node        |
| Vehicle node     |                         |
----------------------------------------------

APIs - For manually controlling the vehicle.

# API to increase the speed.
$ curl -I http://localhost:5000/vehicle/sensor_controls/speed/I

# API to decrease the speed.
$ curl -I http://localhost:5000/vehicle/sensor_controls/speed/D

# API to apply brakes.
$ curl -I http://localhost:5000/vehicle/sensor_controls/brake/A

# API to release brakes.
$ curl -I http://localhost:5000/vehicle/sensor_controls/brake/R

# API to increase blood pressure of the passenger.
$ curl -I http://localhost:5000/vehicle/sensor_controls/hrs/I

# API to decrease blood pressure of the passenger.
$ curl -I http://localhost:5000/vehicle/sensor_controls/hrs/D

# API to increase fuel level.
$ curl -I http://localhost:5000/vehicle/sensor_controls/fuel/I

# API to decrease fuel level.
$ curl -I http://localhost:5000/vehicle/sensor_controls/fuel/D

About

Project 3, for scalable computing

License:GNU General Public License v3.0


Languages

Language:Python 100.0%