Skip to content
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
# ets2-python-telemetry

ETS2 (Euro Truck Simulator 2) python telemetry reader for nlhans' [ets2-sdk-plugin](https://github.com/nlhans/ets2-sdk-plugin "https://github.com/nlhans/ets2-sdk-plugin") based on nlhans' telemetry client for python applications.

Numpy lib required.
## Installation
> 0. Login steam, download [Euro Truck Simulation2](https://eurotrucksimulator2.com/)
> 1. Hit the [link](https://github.com/nlhans/ets2-sdk-plugin "https://github.com/nlhans/ets2-sdk-plugin") above and follow instructions.
> 2. SDK file (DLL file) must be in `<Euro Truck Simulation2>\bin\<win_x64 or win_x86>\plugins`
> > path would be like this: `C:\steam\steamapps\common\Euro Truck Simulation2\bin\win_x64\plugins`
> > if there is no plugins folder inside of win_x64, make "plugins" folder and put a DLL file in it

## Usage
> 1. clone this repo. type it on terminal.<br>
> ```shell
> $ git clone https://github.com/comeeasy/ets2-python-telemetry.git
> ```
>
> 2. run __Euro Truck Simulation2.exe__
> <br><img src="https://github.com/comeeasy/ets2-python-telemetry/blob/master/imgs/start-sim.png" width="40%" height="30%" title="start ets2" alt="RubberDuck"></img><br>
>
> 3. run code.<br>
> ```shell
> $ cd ets-python-telemetry
> $ python get.py
> ```
>
> <br><img src="https://github.com/comeeasy/ets2-python-telemetry/blob/master/imgs/run.png" width="40%" height="30%" title="running display" alt="RubberDuck"></img><br>

## details

### If you want other telemetry information
then, see [ets2sdkdata.py](https://github.com/comeeasy/ets2-python-telemetry/blob/master/ets2sdkdata.py)
and also here

> most important code in `get.py` is just like below
```python
data = sm.update()
f.wrtie(data)
```

## Go Get some data from ET2!






SCS SDK version implemented : 1.5 / Latest SCS SDK version : 1.9
30 changes: 30 additions & 0 deletions get.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ets2sdktelemetry import Ets2SdkTelemetry
from sharedmemory import SharedMemory
import time
from threading import Timer


def update(sm: SharedMemory, f):
Timer(1, update, [sm, f]).start()
tt0 = time.perf_counter()
data = sm.update()
_format = f"{data.coordinateX},{data.coordinateY},{data.rotationX * 360:.2f},{data.accelerationX},{data.accelerationY},{round(data.speed * 3.6)},{time.ctime(time.time())}\n"

f.write(_format)
print(_format)
tt1 = time.perf_counter()
print(f"{(tt1 - tt0)*1000}ms, time: {time.ctime(time.time())}\n")


if __name__ == "__main__":
t = Ets2SdkTelemetry()
sm = SharedMemory()
sm.connect()

fileName = 'test.csv'
f = open(fileName, 'w+')
f.write("GPS_X,GPS_Y,AZIMUTH,ACCELERATION_X,ACCELERATION_Y,SPEED,TIME\n")
update(sm, f)



Binary file added imgs/run.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/start-sim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.