... | ... | @@ -2,30 +2,48 @@ |
|
|
|
|
|
This is the traffic simulator global wiki.
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
# Installation
|
|
|
### Client
|
|
|
The client can be a windows or a linux computer, and you will need to install the following softwares :
|
|
|
* [SUMO](https://sumo.dlr.de/wiki/Downloads), the traffic simulator. Once you have installed it, make sure that the installation folder is added in the system path variable (it should be added by default). To make sure that SUMO is correctly installed, open a command prompt and type `sumo-gui`, it should open a window. If not, please make sure that the installation process went ok.
|
|
|
* [Unity](https://store.unity.com/download), the game engine for visualisation.
|
|
|
|
|
|
Once those softwares are installed, you have two repositories to clone :
|
|
|
* The [Unity project](https://gitlab.orbit-lab.org/traffic-simulator/sumo-unity-lfs). It uses git-lfs for large files, so make sure to have it installed. Do those commands to clone it :
|
|
|
* `git clone https://gitlab.orbit-lab.org/traffic-simulator/sumo-unity-lfs.git`
|
|
|
* `cd sumo-unity-lfs`
|
|
|
* `git lfs install`
|
|
|
* `git lfs pull`
|
|
|
* The [SUMO files](https://gitlab.orbit-lab.org/traffic-simulator/sumo-simulator). Clone it using `git clone https://gitlab.orbit-lab.org/traffic-simulator/sumo-simulator.git`. Go to the folder where you have cloned it and open the file named `config.sumo.cfg`.
|
|
|
|
|
|
### Server
|
|
|
The server programs are designed to be used on a linux machine. You may have to adapt them if you need to make them run on a different machine. You will need the following softwares :
|
|
|
* [Python 3](https://www.python.org/) for running the different scripts. It should be already installed by default on your linux distribution. If not, try downloading it through your package manager. You also need to have the following additional packages for python :
|
|
|
* [pika](https://pika.readthedocs.io/en/stable/) by running `pip3 install pika`
|
|
|
* [pyserial](https://pythonhosted.org/pyserial/) by running `pip3 install pyserial`. You may have to run `apt-get install python3-pyserial` or `dnf install python3-pyserial` if you encounter the error "no module named Serial" at some point.
|
|
|
* [RabbitMQ](https://www.rabbitmq.com/download.html), the software handling the connection between Unity and the cars.
|
|
|
|
|
|
Once those software are installed, there is also some git repository to clone. Here, you only have to clone the [pubsub](https://gitlab.orbit-lab.org/traffic-simulator/pubsub) repository by doing `git clone https://gitlab.orbit-lab.org/traffic-simulator/pubsub.git`.
|
|
|
|
|
|
You may encounter problems on cloning some of the repositories because it ask you your username and password. Enter your gitlab.orbit-lab.org credentials, which are supposed to be your orbit account credentials. You can however download all the repositories as zip files, but you must do the cloning steps for the unity project, including the git lfs pull, because it contains large files that would not be included if you only did download as zip.
|
|
|
|
|
|
# Run
|
|
|
When you have every software and files needed, you can start running all that is needed.
|
|
|
### Server
|
|
|
On the server side, you have some modifications to do. Go to the folder where you cloned the pubub repository, and go to the python_rpc folder.
|
|
|
* Open the file `rpc_client.py`, and modify `(HOST, PORT)` to whatever you want the rpc_client script to run on.
|
|
|
* Open the file `tl.py`, and modify `HOST, PORT` to whatever you want the traffic light script to run on. Choose a different port than rpc_client.py.
|
|
|
|
|
|
You can the launch RabbitMQ by launching `sudo rabbitmq-server start` and then launching those scripts :
|
|
|
* `./rpc_client.py`
|
|
|
* `./rpc_server.py [car ID] [RabbitMQ IP address] [subscriptions]` by replacing [car ID] by a name/number of your choice, [RabbitMQ IP address] by the ip address where RabbitMQ is running (normally, it should be localhost), and finally [subscriptions] by whatever you want the car to be subscribed to. An example would then be : `./rpc_serv.py car1 localhost *.side`.
|
|
|
* `./tl.py`
|
|
|
|
|
|
### Client
|
|
|
The client runs [SUMO](https://sumo.dlr.de/wiki/Downloads) as a traffic simulator and [Unity](https://store.unity.com/download). (To download Unity on linux, click [here](http://beta.unity3d.com/download/292b93d75a2c/UnitySetup-2019.1.0f2)). Install both of them by following the instruction on their website. After having installed SUMO, make sure that its installation folder is added to your PATH variable (typically `C:\Users\native\Desktop\sumo-1.2.0\bin` on Windows).
|
|
|
|
|
|
The gitlab repository [sumo](https://gitlab.orbit-lab.org/traffic-simulator/sumo) contains the full Unity project and sumo files.
|
|
|
You have two options to get the files needed for the Unity project :
|
|
|
* Clone [this repository](https://gitlab.orbit-lab.org/traffic-simulator/sumo) to a folder on your computer : `git clone --recurse-submodules https://gitlab.orbit-lab.org/traffic-simulator/sumo.git`.
|
|
|
* If somehow the cloning fails, you can also download the 2 sub-repositories here : [sumo-unity](https://gitlab.orbit-lab.org/traffic-simulator/sumo-unity) and [sumo-simulator](https://gitlab.orbit-lab.org/traffic-simulator/sumo-simulator) and unzip them to a location of your choice.
|
|
|
|
|
|
Once you have these files, you can open Unity Hub and add a new project as the folder where sumo-unity is located on your computer. The scene named "scene" is the main scene you will be interacting with. Under the hierarchy, open the game object SumoConnection. On the inspector, open the section SumoSettings and make sure that the setting `Sumo Config File` is set to `<path-to-sumo>\sumo-simulator\config.sumo.cfg` (choose your sumo-simulator clone or download folder). You also have to edit this config.sumo.cfg file to modify the path of net-file, route-file and additional-files to where those files are connected on your computer, normally on the same folder as config.sumo.cfg.
|
|
|
|
|
|
### Central server
|
|
|
This part of the system is supposed to run on a different computer than the one where Unity and SUMO runs. It is designed primarily to run on a linux machine. You first have to clone the [PubSub](https://gitlab.orbit-lab.org/traffic-simulator/pubsub) repository to get all the scripts : `git clone https://gitlab.orbit-lab.org/traffic-simulator/pubsub`
|
|
|
The central server runs [RabbitMQ](https://www.rabbitmq.com/download.html) as the message broker. On top of that the different scripts are running on [python 3](https://www.python.org/download/releases/3.0/) and needs the following additional packages :
|
|
|
* [pika](https://pika.readthedocs.io/en/stable/) for the connection with RabbitMQ.
|
|
|
* [pyserial](https://pypi.org/project/pyserial/) for the communication on USB.
|
|
|
|
|
|
Make sure to install them using pip3 and additional libraries if required by these packages.
|
|
|
|
|
|
### Cars
|
|
|
Similarly to the central server, you will need to have to clone the [PubSub](https://gitlab.orbit-lab.org/traffic-simulator/pubsub) repository for the scripts, and have to install python 3 and pika.
|
|
|
|
|
|
## Run
|
|
|
Firstly, you have to run the scripts on the server and cars. On the central server you have to run the rpc_client.py and tl.py scripts (located on the python_rpc folder in the pubsub repository). On the machine that the cars are running on you have to run the rpc_server.py script (the syntax is `./rpc_server.py [car id] [host] [subscriptions...]`, for example `./rpc_server.py car1 localhost *.side`).
|
|
|
You can then go to the Unity scene and open again the SumoConnection game object. On the inspector, open the section RabbitMQ Settings and change the IP and port to whatever address the rpc_client.py script is running on.
|
|
|
Then, go to the script my_script/SimulationObjects/TrafficLightObject.cs and modify host and port to whatever addresses the tl.py script is running on. The ports on RabbitMQ settings and on the traffic light script are NOT supposed to be the same if the ip addresses are identical.
|
|
|
Once those scripts are running, you can start the Unity scene, making sure that all IP addresses and ports are correctly set up. |
|
|
\ No newline at end of file |
|
|
When those scripts are running, you have some modifications to make to your local unity project. Open a new unity project into the folder where you cloned the repository sumo-unity-lfs. When Unity is opened, open the scene named "Scene" and import TMP-Essentials as asked.
|
|
|
* Open the game object named **SumoConnection** and under **Sumo Settings** make sure that **Sumo Config File** is set to where the `sumo.config.cfg` file is.
|
|
|
* Under **RabbitMQ Settings**, make sure that the IP and port are corresponding to the one you put on the rpc_client.py script.
|
|
|
* Open the file named `TrafficLightObject.cs` under `Assets/my_scripts/SimulationObjects/` and modify the host and port to the one you put on the tl.py script.
|
|
|
|
|
|
You are good to go, launch the project and everything should be up and running. Make sure that you receive messages on the different python scripts, and if not, check the different steps again. |
|
|
\ No newline at end of file |