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.
Driving on the country road 2.
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 wheeltrain.py (new_train.py)
- scripts for traininggenerate_dataset.py
- script that is used for recording the screen and saving images and steering angle
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 truckMODEL_PATH = "../models/autopilot.h5"
- path to the trained model fileSTEER_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
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
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.
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.