A toolkit for controlling Euro Truck Simulator 2 with python to develop self-driving algorithms.

Overview

europilot

Overview

Europilot is an open source project that leverages the popular Euro Truck Simulator(ETS2) to develop self-driving algorithms.

alt tag alt tag

A convolutional neural network (CNN) controls the steering wheel inside ETS2.

Think of europilot as a bridge between the game environment, and your favorite deep-learning framework, such as Keras or Tensorflow. With europilot, you can capture the game screen input, and programmatically control the truck inside the simulator.

Europilot can be used in one of two ways: training or testing.

For training, europilot can capture the screen input and output a numpy array in realtime, while simultaenously getting the wheel-joystick values. The mapping between the relevant screenshot and the joystick values is written inside a csv file.

In the csv file, each row has the screenshot filename with the joystick values.

For testing, europilot can create a virtual joystick driver that can be recognized inside the game, which can be used to programmatically control the truck. Using this joystick, you can create a real-time inference network that uses the game screen as the input, and outputs the relevant joystick commands, such as steering.

Click to see an example demo on YouTube.

Click to read a blog post on our motivation behind the project.

Getting Started

First, clone the project

git clone [email protected]:marshq/europilot.git

If you want to install europilot locally,

python setup.py install

You can also install prerequisite libraries and do something directly in this project path.

pip install -r requirements.txt
python
>>> import europilot
>>> europilot.__version__
'0.0.1'

To start generating training data, check out generate_training_data.py in the scripts directory.

NOTE that opencv compiled with opencv_contrib module is required to use screen selection gui.

Otherwise, you should specify a screen area in which will be captured by assigning custom Box object to train.Config.BOX.

After the generation of training data is finished, you may want to manually inspect each image to check if unwanted data was recorded. Check clean_up.ipynb for a simple script to remove unwanted data together with the accompanying row in the csv file. Also check out preprocess.ipynb and get_mean_std.ipynb for an example code to preprocess the data.

PilotNet.ipynb is an implementation of Mariusz Bojarski's End to End Learning for Self-Driving Cars, with slight differences. The demo shown above was created with the following notebook.

For running inference on the model, check out inference.ipynb in the scripts directory.

Sample Training Data

For those interested, a driving dataset consisting of 162,495 images is available here (17G).

General Architecture

Europilot hides the complexity of capturing the screen data and joystick data with a simplified interface. Internally, the joystick datastream is parsed into a machine readable format, which for us was a Logitech G27. If you have a different joystick, modify joystick.py to your needs.

We currently have example notebooks implemented with Keras. We hope to add more examples in other popular frameworks.

A virtual joystick driver is implemented by attaching userspace drivers in the kernel, by outputting events into udev. This driver can be recognized inside ETS2. Please note that the driver must be initialized before the game is started, or else it will not show up in the controller page.

Why Euro Truck Simulator 2?

Europilot captures the screen input, therefore technically it is game agnostic. We chose ETS2 as our first target for several reasons.

  • Multi platform support: ETS2 supports Windows, OS X, and Linux. Developers can run the game in a Macbook, or in a Ubuntu workstation. This put ETS2 ahead of games such as GTAV.

  • Realistic graphics/physics: We looked at open source games, but found that the graphics or physics engine was not realistic enough for our use case. ETS2 afterall, has "simulator" inside its title.

  • Fun: Having a large dataset is critical to developing a good model. Therefore you, as a developer, have to play many hours of whatever game you target. Fortunately, ETS2 is fun to play!

Documentation

For now, refer to the README and the source code.

Compatibility

Europilot runs on linux. It supports python 2.6-2.7 and 3.3+.

How to Contribute

Any contribution regarding new feature, bug fix and documentation is welcomed.

But we highly recommend you to read this guideline before you make a pull request.

Coding convention

We generally follow PEP8 with few additional conventions.

  • Line-length can exceed 79 characters, to 100 in case of comments.
  • Always use single-quoted strings, unless a single-quote occurs within the string.
  • Docstrings use double-quote.

Roadmap

Feature roadmap includes

  • Run ETS2 on virtual machine and train/test a model remotely
  • Web leaderboard
  • Capture custom(ex. left, right side cam) vision data while driving in ETS2
  • Support reinforcement learning workflow which is simliar to openai universe
  • Windows support, if there is demand.

License

This project is licensed under the MIT License.

Comments
  • Unable to use keyboard for generating training data

    Unable to use keyboard for generating training data

    I am unable to generate data using keyboard instead of joystick. What are the steps to be followed for using the code with a keyboard. Is the training data publicly available or will be made available in future.

    opened by thanif 5
  • is it possible to using [mouse+keyboard] instead of using [Logitech G27] ?

    is it possible to using [mouse+keyboard] instead of using [Logitech G27] ?

    Thanks to you, I can follow everything of europilot except the joystick [Logitech G27]. Even though this problem, I think that this repository is good change to me.

    As mentioned in General Architecture on README.md , " If you have a different joystick, modify joystick.py to your needs. "

    is it possible to using [mouse+keyboard] instead of using [Logitech G27] ? Because it's hard to buy the joystick [Logitech G27] for me.

    I guess that you have experienced about this joystick Can you any guide or answer to me about [mouse+keyboard] alternatives ?

    If I know the alternatives and implemented, then I will PR on this repository.

    ----In Korean----

    제가 영어가 짧아서 위에 간략하게 적었습니다. 한글로 적어 보겠습니다.

    여기 저장소 덕분에 europilot 을 알게 되었고, joystick 에서 문제를 만났지만 좋은 도전이 될 것 같다는 생각에는 변함이 없습니다.

    README.md 에서도 언급했지만 [Logitech G27]을 사용할 수 없다면 직접 joystick.py를 수정하라고 명시되어 있습니다.

    제가 [Logitech G27]을 구입하려했지만 비싸서 대안으로 [mouse+keyboard]로 사용가능한지 문의드립니다.

    제 추측으로는 여기에서 구현한 joystick 을 만들면서 충분히 고민하고 경험을 했을것 같습니다. [mouse+keyboard]에 대한 참고할만한 가이드 또는 볼만한 링크라도 알고 계시면 답변 부탁드립니다.

    만일 제가 대안을 알게 되고, 구현 한다면 여기에 PR 올리도록 하겠습니다.

    opened by wooheaven 3
  • "Getting Started" should explain how to get started

    You know... Let's say I've downloaded ETS2 via Steam and pip installed europilot. Now what? How do I get to what you show in the gif? Do I need to configure something? Do I need to run my own training before I can use it?

    opened by erikbsap 2
  • Windows Version

    Windows Version

    I don't know about anyone else but I would LOVE a windows version of this since it's my usual OS. Works flawlessly on my virtual machine. I understand Windows support is on your roadmap, but I believe it would be great to get this out to Windows users to use! Cheers.

    opened by Alexr03 2
  • values are not saved in. csv

    values are not saved in. csv

    Hy, i have tried running europilot, and in. csv file pictures were saved but al other values were 0. when i run joystick. py the output whas UNKNOWN: b'200': some number.

    I fixed that, and now it sayd wheel-axis some_number. But it doesnt save the value in. csv

    opened by ZvonimirKucis 2
  • Virtual controller setup

    Virtual controller setup

    Hi,

    I was wondering what the following sentence mean? "Please note that the driver must be initialized before the game is started, or else it will not show up in the controller page."

    Does it mean that the G27 has to be plugged in so it shows up in the devices? If yes, is there a way to initialize the driver without actually having G27 ?

    opened by vadbut 1
  • Balancing raw data

    Balancing raw data

    Is there any need to undersample data which is available more often than other? (It‘s likely to get more data driving with a steering angle close to 0). Wouldn‘t the trained network go simply straight because of the data? But the only thing I found was the notebook which calculated the mean and std.

    Is that enough? I would be happy for any explanation!

    opened by sschertler 1
  • Unable to create LinuxVirtualJoystick instance on Mac OS Sierra

    Unable to create LinuxVirtualJoystick instance on Mac OS Sierra

    Hi, I was trying to use this awesome project on Mac OS Sierra. While following 05.inference, I got stuck here.

    
    NameError                                 Traceback (most recent call last)
    <ipython-input-12-2280f39a9193> in <module>()
          3 box = Box(x1, y1, x2, y2)
          4 
    ----> 5 joy = LinuxVirtualJoystick()
    
    ~/tensorflow/lib/python3.6/site-packages/europilot-0.0.1-py3.6.egg/europilot/joystick.py in __init__(self, name, bustype, vendor, product, version, events)
        210             events = (
        211                 # EV_KEY
    --> 212                 uinput.BTN_TRIGGER,
        213                 uinput.BTN_THUMB,
        214                 uinput.BTN_THUMB2,
    
    NameError: name 'uinput' is not defined
    

    I went through the source code and found that uinput is imported only for linux. I tried installing python-uinput but looks like it is not supported on Mac.

    Is there anything which I am missing? How should I create VirtualJoystick on Mac?

    opened by aryarohit07 1
  • ETS2 Game EULA

    ETS2 Game EULA

    Dear

    Thank you for the great work!

    You mentioned that:

    "With europilot, you can capture the game screen input, and programmatically control the truck inside the simulator."

    Is it allowed by the ETS2 EULA?

    Best Regards

    opened by IbrahimSobh 1
  • Modifying underlying CNN

    Modifying underlying CNN

    Hi,

    I am wondering if it is possible to modify the underlying CNN with a different CNN structure (say, adding more filters) and rebuild the package myself to achieve different results from the same training data. Let me know if this is feasible.

    Thanks, Lou

    opened by apclypsr 1
  • car

    car

    I was interested in the Euro Pilot. But I have some questions. In a video, a car follows a lane perfectly. But does the car stop when it is red? I would like to ask if it is possible to adjust the distance of the front car. Finally, I wonder if car can reach its destination!

    opened by Learningbug04 1
Owner
We are bringing self-driving technology to the commercial trucking industry.
null
UAV-Networks-Routing is a Python simulator for experimenting routing algorithms and mac protocols on unmanned aerial vehicle networks.

UAV-Networks Simulator - Autonomous Networking - A.A. 20/21 UAV-Networks-Routing is a Python simulator for experimenting routing algorithms and mac pr

null 0 Nov 13, 2021
An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects different compression algorithms have.

ImageCompressionSimulation An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects o

James Park 1 Dec 11, 2021
Self Driving RC Car Code

Derp Learning Derp Learning is a Python package that collects data, trains models, and then controls an RC car for track racing. Hardware You will nee

Not Karol 39 Dec 7, 2022
Self-Supervised Pillar Motion Learning for Autonomous Driving (CVPR 2021)

Self-Supervised Pillar Motion Learning for Autonomous Driving Chenxu Luo, Xiaodong Yang, Alan Yuille Self-Supervised Pillar Motion Learning for Autono

QCraft 101 Dec 5, 2022
Open source hardware and software platform to build a small scale self driving car.

Donkeycar is minimalist and modular self driving library for Python. It is developed for hobbyists and students with a focus on allowing fast experimentation and easy community contributions.

Autorope 2.4k Jan 4, 2023
Simulation of Self Driving Car

In this repository, the code to use Udacity's self driving car simulator as a testbed for training an autonomous car are provided.

Shyam Das Shrestha 1 Nov 21, 2021
Graph Self-Attention Network for Learning Spatial-Temporal Interaction Representation in Autonomous Driving

GSAN Introduction Code for paper GSAN: Graph Self-Attention Network for Learning Spatial-Temporal Interaction Representation in Autonomous Driving, wh

YE Luyao 6 Oct 27, 2022
Reinforcement learning for self-driving in a 3D simulation

SelfDrive_AI Reinforcement learning for self-driving in a 3D simulation (Created using UNITY-3D) 1. Requirements for the SelfDrive_AI Gym You need Pyt

Surajit Saikia 17 Dec 14, 2021
Action Recognition for Self-Driving Cars

Action Recognition for Self-Driving Cars This repo contains the codes for the 2021 Fall semester project "Action Recognition for Self-Driving Cars" at

VITA lab at EPFL 3 Apr 7, 2022
Self-driving car env with PPO algorithm from stable baseline3

Self-driving car with RL stable baseline3 Most of the project develop from https://github.com/GerardMaggiolino/Gym-Medium-Post Please check it out! Th

Sornsiri.P 7 Dec 22, 2022
(CVPR 2022) A minimalistic mapless end-to-end stack for joint perception, prediction, planning and control for self driving.

LAV Learning from All Vehicles Dian Chen, Philipp Krähenbühl CVPR 2022 (also arXiV 2203.11934) This repo contains code for paper Learning from all veh

Dian Chen 300 Dec 15, 2022
A PyTorch-based open-source framework that provides methods for improving the weakly annotated data and allows researchers to efficiently develop and compare their own methods.

Knodle (Knowledge-supervised Deep Learning Framework) - a new framework for weak supervision with neural networks. It provides a modularization for se

null 93 Nov 6, 2022
A program that uses computer vision to detect hand gestures, used for controlling movie players.

HandGestureDetection This program uses a Haar Cascade algorithm to detect the presence of your hand, and then passes it on to a self-created and self-

null 2 Nov 22, 2022
The codes reproduce the figures and statistics in the paper, "Controlling for multiple covariates," by Mark Tygert.

The accompanying codes reproduce all figures and statistics presented in "Controlling for multiple covariates" by Mark Tygert. This repository also pr

Meta Research 1 Dec 2, 2021
Controlling the MicriSpotAI robot from scratch

Project-MicroSpot-AI Controlling the MicriSpotAI robot from scratch Colaborators Alexander Dennis Components from MicroSpot The MicriSpotAI has the fo

Dennis Núñez-Fernández 5 Oct 20, 2022
Controlling the MicriSpotAI robot from scratch

Abstract: The SpotMicroAI project is designed to be a low cost, easily built quadruped robot. The design is roughly based off of Boston Dynamics quadr

Florian Wilk 405 Jan 5, 2023
Controlling Hill Climb Racing with Hand Tacking

Controlling Hill Climb Racing with Hand Tacking Opened Palm for Gas Closed Palm for Brake

Rohit Ingole 3 Jan 18, 2022
Controlling a game using mediapipe hand tracking

These scripts use the Google mediapipe hand tracking solution in combination with a webcam in order to send game instructions to a racing game. It features 2 methods of control

null 3 May 17, 2022
Use VITS and Opencpop to develop singing voice synthesis; Maybe it will VISinger.

Init Use VITS and Opencpop to develop singing voice synthesis; Maybe it will VISinger. 本项目基于 https://github.com/jaywalnut310/vits https://github.com/S

AmorTX 107 Dec 23, 2022