carla/Docs/adv_ptv.md

67 lines
3.5 KiB
Markdown
Raw Normal View History

2020-04-15 08:51:17 +08:00
# PTV-Vissim co-simulation
2020-04-15 19:35:05 +08:00
CARLA has developed a co-simulation feature with PTV-Vissim. This allows to distribute the tasks at will, and exploit the capabilities of each simulation in favour of the user.
2020-04-15 08:51:17 +08:00
* [__Requisites__](#requisites)
2020-04-15 19:35:05 +08:00
* [__Run a co-simulation__](#run-the-co-simulation)
2020-04-15 23:14:06 +08:00
* [Create a new network](#create-a-new-network)
2020-04-15 08:51:17 +08:00
---
## Requisites
2020-04-15 19:35:05 +08:00
In order to run the co-simulation, two things are necessary.
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
* Buy a license for [__PTV-Vissim simulator__](https://www.ptvgroup.com/en/solutions/products/ptv-vissim/). It is necessary to acquire the Driving Simulator Interface add-on.
* In the PTV-Vissim installation folder, look for a `DrivingSimulatorProxy.dll`. Move it to `C:\Windows\System32`.
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
---
## Run a co-simulation
2020-04-15 08:51:17 +08:00
2020-04-15 23:14:06 +08:00
Everything related with this feature can be found in `Co-Simulation/PTV-Vissim`. CARLA provides some examples that contain networks for __Town01__, and __Town03__.
2020-04-15 08:51:17 +08:00
2020-04-15 23:14:06 +08:00
To run a co-simulation, use the script `PTV-Vissim/run_synchronization.py`. This has one mandatory argument containing the PTV-Vissim network, and some other optional arguments.
2020-04-15 08:51:17 +08:00
2020-04-15 23:14:06 +08:00
* `vissim_network`— The vissim network file. This can be an example or a self-created PTV-Vissim network.
2020-04-15 19:35:05 +08:00
* `--carla-host` *(default: 127.0.0.1)* — IP of the carla host server.
* `--carla-port` *(default: 2000)* TCP port to listen to.
* `--vissim-version` *(default: 2020)* — PTV-Vissim version.
* `--step-length` *(default: 0.05s)* — set fixed delta seconds for the simulation time-step.
* `--simulator-vehicles` *(default: 1)* — number of vehicles that will be spawned in CARLA and passed to PTV-Vissim.
2020-04-15 08:51:17 +08:00
```sh
python3 run_synchronization.py examples/Town03/Town03.inpx
```
2020-04-15 23:14:06 +08:00
!!! Warning
To stop the co-simulation, press `Ctrl+C` in the terminal that run the script.
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
Both simulations will run in synchrony. The actions or events happening in one simulator will propagate to the other. So far, the feature only includes vehicle movement, and spawning. The spawning is limited due to PTV-Vissim types.
2020-04-16 02:52:49 +08:00
* If a vehicle is spawned in CARLA, and the *Vehicle Type* in PTV-Vissim is set to `car`, it will spawn a car. No matter if it as a motorbike in CARLA. In the examples provided, the vehicle type is set to `car`.
2020-04-15 19:35:05 +08:00
* If a vehicle is spawned in PTV-Vissim, CARLA will use a vehicle of the same type. The dimensions and characteristics will be similar, but not exactly the same.
2020-04-15 08:51:17 +08:00
2020-04-15 23:14:06 +08:00
### Create a new network
2020-04-15 08:51:17 +08:00
2020-04-15 23:14:06 +08:00
In order for a new PTV-Vissim network to run with CARLA, there are a few settings to be done.
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
* __Activate the driving simulator__. Go to `Base Data/Network settings/Driving simulator` and enable the option.
* __Specify the vehicle and pedestrian types__. These are the types that will be used in PTV-Vissim to sync with the spawnings done in CARLA. By default are empty.
2020-04-15 23:14:06 +08:00
* __Export the network as `.inpx`__. Create the network, export it, and run the co-simulation with `run_synchronization.py`.
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
![ptv_types](img/ptv_types.png)
<div style="text-align: right"><i>Any vehicle that is spawned in CARLA, will be spawned in PTV-Vissim using these types.</i></div>
2020-04-15 08:51:17 +08:00
2020-04-15 19:35:05 +08:00
!!! Warning
2020-04-15 23:14:06 +08:00
PTV-Vissim will crash if the pedestrian and vehicle types are left empty.
2020-04-15 08:51:17 +08:00
---
That is all there is so far, regarding for the PTV-Vissim co-simulation with CARLA.
Open CARLA and mess around for a while. If there are any doubts, feel free to post these in the forum.
<div class="build-buttons">
<p>
<a href="https://forum.carla.org/" target="_blank" class="btn btn-neutral" title="Go to the CARLA forum">
CARLA forum</a>
</p>
</div>