All Projects → araffin → learning-to-drive-in-5-minutes

araffin / learning-to-drive-in-5-minutes

Licence: MIT License
Implementation of reinforcement learning approach to make a car learn to drive smoothly in minutes

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to learning-to-drive-in-5-minutes

proto
Proto-RL: Reinforcement Learning with Prototypical Representations
Stars: ✭ 67 (-70.48%)
Mutual labels:  gym, rl, sac, soft-actor-critic
CartPole
Run OpenAI Gym on a Server
Stars: ✭ 16 (-92.95%)
Mutual labels:  openai, gym, rl
omd
JAX code for the paper "Control-Oriented Model-Based Reinforcement Learning with Implicit Differentiation"
Stars: ✭ 43 (-81.06%)
Mutual labels:  gym, sac, soft-actor-critic
Pytorch-RL-CPP
A Repository with C++ implementations of Reinforcement Learning Algorithms (Pytorch)
Stars: ✭ 73 (-67.84%)
Mutual labels:  openai, gym, vae
Uselfdrivingsimulator
Self-Driving Car Simulator
Stars: ✭ 48 (-78.85%)
Mutual labels:  simulator, self-driving-car
Duckietown.jl
Differentiable Duckietown
Stars: ✭ 29 (-87.22%)
Mutual labels:  simulator, self-driving-car
Airsim
Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
Stars: ✭ 12,528 (+5418.94%)
Mutual labels:  simulator, self-driving-car
mujoco-benchmark
Provide full reinforcement learning benchmark on mujoco environments, including ddpg, sac, td3, pg, a2c, ppo, library
Stars: ✭ 101 (-55.51%)
Mutual labels:  rl, sac
Atari
AI research environment for the Atari 2600 games 🤖.
Stars: ✭ 174 (-23.35%)
Mutual labels:  gym, rl
Awesome Carla
👉 CARLA resources such as tutorial, blog, code and etc https://github.com/carla-simulator/carla
Stars: ✭ 246 (+8.37%)
Mutual labels:  simulator, self-driving-car
jax-rl
JAX implementations of core Deep RL algorithms
Stars: ✭ 61 (-73.13%)
Mutual labels:  sac, soft-actor-critic
Carla
Open-source simulator for autonomous driving research.
Stars: ✭ 7,012 (+2988.99%)
Mutual labels:  simulator, self-driving-car
Matterport3dsimulator
AI Research Platform for Reinforcement Learning from Real Panoramic Images.
Stars: ✭ 260 (+14.54%)
Mutual labels:  simulator, rl
Simulator
A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Stars: ✭ 1,260 (+455.07%)
Mutual labels:  simulator, self-driving-car
behavioral cloning
No description or website provided.
Stars: ✭ 26 (-88.55%)
Mutual labels:  simulator, self-driving-car
Autonomous-RC-Car
Self-driving RC Car ROS Software
Stars: ✭ 17 (-92.51%)
Mutual labels:  self-driving-car, donkey-car
continuous Bernoulli
There are C language computer programs about the simulator, transformation, and test statistic of continuous Bernoulli distribution. More than that, the book contains continuous Binomial distribution and continuous Trinomial distribution.
Stars: ✭ 22 (-90.31%)
Mutual labels:  simulator, vae
Stable Baselines
Mirror of Stable-Baselines: a fork of OpenAI Baselines, implementations of reinforcement learning algorithms
Stars: ✭ 115 (-49.34%)
Mutual labels:  gym, rl
Rl Baselines3 Zoo
A collection of pre-trained RL agents using Stable Baselines3, training and hyperparameter optimization included.
Stars: ✭ 161 (-29.07%)
Mutual labels:  gym, rl
road-simulator
🛣️ Easy-to-use road simulator for little self-driving cars
Stars: ✭ 23 (-89.87%)
Mutual labels:  simulator, self-driving-car

Learning to Drive Smoothly in Minutes

Learning to drive smoothly in minutes, using a reinforcement learning algorithm -- Soft Actor-Critic (SAC) -- and a Variational AutoEncoder (VAE) in the Donkey Car simulator.

Blog post on Medium: link

Video: https://www.youtube.com/watch?v=iiuKh0yDyKE

Level-0 Level-1
result result
Download VAE Download VAE
Download pretrained agent Download pretrained agent

Note: the pretrained agents must be saved in logs/sac/ folder (you need to pass --exp-id 6 (index of the folder) to use the pretrained agent).

Quick Start

  1. Download simulator here or build it from source
  2. Install dependencies (cf requirements.txt)
  3. (optional but recommended) Download pre-trained VAE: VAE Level 0 VAE Level 1
  4. Train a control policy for 5000 steps using Soft Actor-Critic (SAC)
python train.py --algo sac -vae path-to-vae.pkl -n 5000
  1. Enjoy trained agent for 2000 steps
python enjoy.py --algo sac -vae path-to-vae.pkl --exp-id 0 -n 2000

To train on a different level, you need to change LEVEL = 0 to LEVEL = 1 in config.py

Train the Variational AutoEncoder (VAE)

  1. Collect images using the teleoperation mode:
python -m teleop.teleop_client --record-folder path-to-record/folder/
  1. Train a VAE:
python -m vae.train --n-epochs 50 --verbose 0 --z-size 64 -f path-to-record/folder/

Train in Teleoparation Mode

python train.py --algo sac -vae logs/vae.pkl -n 5000 --teleop

Test in Teleoparation Mode

python -m teleop.teleop_client --algo sac -vae logs/vae.pkl --exp-id 0

Explore Latent Space

python -m vae.enjoy_latent -vae logs/level-0/vae-8.pkl

Reproducing Results

To reproduce the results shown in the video, you have to check different values in config.py.

Level 0

config.py:

MAX_STEERING_DIFF = 0.15 # 0.1 for very smooth control, but it requires more steps
MAX_THROTTLE = 0.6 # MAX_THROTTLE = 0.5 is fine, but we can go faster
MAX_CTE_ERROR = 2.0 # only used in normal mode, set it to 10.0 when using teleoperation mode
LEVEL = 0

Train in normal mode (smooth control), it takes ~5-10 minutes:

python train.py --algo sac -n 8000 -vae logs/vae-level-0-dim-32.pkl

Train in normal mode (very smooth control with MAX_STEERING_DIFF = 0.1), it takes ~20 minutes:

python train.py --algo sac -n 20000 -vae logs/vae-level-0-dim-32.pkl

Train in teleoperation mode (MAX_CTE_ERROR = 10.0), it takes ~5-10 minutes:

python train.py --algo sac -n 8000 -vae logs/vae-level-0-dim-32.pkl --teleop

Level 1

Note: only teleoperation mode is available for level 1

config.py:

MAX_STEERING_DIFF = 0.15
MAX_THROTTLE = 0.5 # MAX_THROTTLE = 0.6 can work but it's harder to train due to the sharpest turn
LEVEL = 1

Train in teleoperation mode, it takes ~10 minutes:

python train.py --algo sac -n 15000 -vae logs/vae-level-1-dim-64.pkl --teleop

Note: although the size of the VAE is different between level 0 and 1, this is not an important factor.

Record a Video of the on-board camera

You need a trained model. For instance, for recording 1000 steps with the last trained SAC agent:

python -m utils.record_video --algo sac --vae-path logs/level-0/vae-32-2.pkl -n 1000

Citing the Project

To cite this repository in publications:

@misc{drive-smoothly-in-minutes,
  author = {Raffin, Antonin and Sokolkov, Roma},
  title = {Learning to Drive Smoothly in Minutes},
  year = {2019},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/araffin/learning-to-drive-in-5-minutes/}},
}

Credits

Related Paper: "Learning to Drive in a Day".

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].