Skip to content

Autopilot for American Truck Simulator made with convolutional neural network.

Notifications You must be signed in to change notification settings

boris-ns/ats-autopilot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autopilot for American Truck Simulator

Simple lane tracking assistant for American Truck Simulator.
The goal is to keep the truck inside its lane.

NOTE: Currently only works on Windows.
NOTE: This project should also work on Euro Truck Simulator 2, since those two games are based on the same engine.

Demo

Driving on the highway.

Driving on the highway 2.

Driving on the country road.

Driving on the country road 2.

How to use

Python 3.6 is required for this project to run. Install vJoy and vJoy DLL file.

Download the project and install necessary dependencies. If you want you can create a virtual environment before running pip3 install -r requirements.txt.

git clone https://github.com/boris-ns/ats-autopilot
cd ats-autopilot
pip3 install -r requirements.txt

This project contains 3 python scripts:

  • main.py - main script that loads trained model and makes predictions and steers the wheel
  • train.py (new_train.py) - scripts for training
  • generate_dataset.py - script that is used for recording the screen and saving images and steering angle

main.py

Inside main.py you can configure these variables according to your needs:

  • SCREEN_GRAB_BOX = (x, y, w, h) - screen image grab of the road in front of the truck
  • MODEL_PATH = "../models/autopilot.h5" - path to the trained model file
  • STEER_STEP = 0.005 - step for smooth steering, you can leave it like this (the smaller number, the smoother steering). Also, before running this script make sure you set vJoy as controller inside the game.
cd src
python main.py

new_train.py

train.py and new_train.py are very similar. For training it's better to use new_train.py. In main() method you need to configure model_path and dataset_paths variables. You can use multiple dataset folders, as long as all of them contain it's own data.csv file.
Then, just run:

cd src
python new_train.py

generate_dataset.py

In config section set values according to your needs.

This will start saving images from 0.

cd src
python generate_dataset.py

If you want you can pass an integer as command line argument, and the script will just continue saving images from that number into the existing dataset folder.

cd src
python generate_dataset.py 1234

The script is configured to use Joystick button 0 as a command to start or pause recording.

Trained models

You can find two trained models here.

  • autopilot2.h5 is made with 40k images dataset with no image processing.
  • autopilot_canny.h5 is made with 40k images dataset with canny edge detection.

About

Autopilot for American Truck Simulator made with convolutional neural network.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages