Hexus-One / ets2_autopilot2

A project to automate driving in SCS Software's Euro Truck Simulator 2.
GNU General Public License v3.0
18 stars 0 forks source link
ai artificial-intelligence autonomous-driving autonomous-vehicles computer-vision control-systems motion-planning python self-driving-car simulator triangulation triangulation-delaunay

ETS2 Autopilot (WIP)

About

A program to automate driving in SCS Software's Euro Truck Simulator 2.

This mainly relies on the HUD GPS with an active route to determine the road ahead, to save effort and computation that's normally required to infer the lanes from the main view. This also allows the program to negogiate more complex situations like turns and intersections, with the goal to navigate from end-to-end with no interventions.

Youtube Demo

Development Status

Requirements

Getting Started

Preparing Euro Truck Simulator 2

  1. Install RenCloud's SCS Telemetry plugin.
  2. (For Windows users) Find the controls.sii file corresponding to your save file, located in

    • C:\Users\{YOURUSERNAME}\Documents\Euro Truck Simulator 2\profiles\{some hexcode}\controls.sii or
    • C:\Users\{YOURUSERNAME}\Documents\Euro Truck Simulator 2\steam_profiles\{some hexcode}\controls.sii

    and edit the following lines:

config_lines[0]: "device keyboard `di8.keyboard`"
config_lines[1]: "device mouse `fusion.mouse`"

to

config_lines[0]: "device keyboard `sys.keyboard`"
config_lines[1]: "device mouse `sys.mouse`"
  1. Install our icon mod - Minimal GPS Truck Icon - from the Steam Workshop and enable it in-game.
  2. In the game, go to Options->Controls and set the control device to Keyboard + Mouse Steering.
  3. Set the Steering sensitivity to 0.40 and Steering non-linearity to 0.00
  4. In Options->Graphics, disable Fullscreen mode and set the screen resolution to 1920x1080.
  5. Make sure your truck is left-hand drive (so the GPS will show in the bottom-right corner)

Installing the program

  1. Clone the project to your local desktop.
  2. Install Python 3.11.4 - releases available here.
    • Optionally setup a virtual environment with venv or a package manager of your preference.
  3. Install the required Python packages with:
pip install -r requirements.txt
  1. Clone drufat's Triangle module and build it from source. You may need the triangle-c submodule if your download doesn't include it already.

    git clone --recurse-submodules https://github.com/drufat/triangle.git 
    cd triangle 
    pip install .

    Running the program

  2. Launch Euro Truck Simulator 2.

  3. Run main.py (inside your virtual environment if needed) to start the program.

The program will open three preview windows to show the 1. screenshot area 2. masked route line and 3. warped perspective with centreline overlay. It will auto-steer via mouse input when the following conditions are fulfilled:

To stop the auto-steer, you can break one of these conditions, e.g. alt-tab out of the game, pause the game, change the GPS zoom, or hide the GPS by changing the Route Advisor to another page. The last two methods allow you to manually steer the truck while the program is running.

Contributing

Any contributions are welcome. We use Black to autoformat our code.

Roadmap

See Development Status

Known bugs

For more info see Development Status

License

This project is licensed under the GNU General Public License version 3.0. For the complete license text, see the file LICENSE. This license applies to all files in this distribution.