본문 바로가기
논문 리뷰/Autonomous racing

Outracing Champion Gran Turismo Drivers with Deep Reinforcement Learning

by heesungsung 2024. 3. 2.
https://ai.sony/publications/Outracing-champion-Gran-Turismo-drivers-with-deep-reinforcement-learning/
 

Outracing Champion Gran Turismo Drivers with Deep Reinforcement Learning – Sony AI

Outracing Champion Gran Turismo Drivers with Deep Reinforcement Learning Peter Wurman Samuel Barrett Kenta Kawamoto James MacGlashan Kaushik Subramanian Thomas Walsh Roberto Capobianco Alisa Devlic Franziska Eckert Florian Fuchs Leilani Gilpin Piyush Khand

ai.sony


 

Introduction

1.  [Baseline; Single-race]  “Super-Human Performance in Gran Turismo Sport Using Deep Reinforcement Learning”, Sony AI and RPG in University of Zurich (2021 RA-L)

2.  [+ Vision Input]  “Expert Human-Level Driving in Gran Turismo Sport Using Deep Reinforcement Learning with Image-based Representation”, Sony AI (2021 NeurIPS)

3.  [+ Overtake; Multi-race]  “Autonomous Overtaking in Gran Turismo Sport Using Curriculum Reinforcement Learning”, Sony AI and RPG in University of Zurich (2021 ICRA)

4.  [Current SOTA]  “Outracing Champion Gran Turismo Drivers with Deep Reinforcement Learning”, Sony AI (2022 Nature)

Gran Turismo에서 racing agent를 개발하는 일련의 연구들 중 마지막 편으로, 현재 SOTA를 달성한 Sophy가 소개된 논문이다. (2022 Nature)

 

Methodology

RL agent 개발의 goal은 다음과 같다.

Build champion-level multi-racing agent, “Gran Turismo Sophy”, using model-free, off-policy deep RL.

Input representation

이 논문에서는 모든 feature 값들을 게임에서 직접 취득한 GT 값으로 사용한다. 사실 이런 방식은 Sim2Real 관점에서는 좋은 방향이 아니지만, SOTA를 달성하는데에는 가장 효과적인 것 같다. 유사한 주제의 다른 논문들에 비해 정말 많은 종류의 feature들을 사용하며, 제작사인 SONY AI 이기 때문에 이 정보들을 접근할 수 있었을 것이다.

1. Time-trial features

$$ \mathbf{o}_{time} = [ 
\mathbf{v}_t, \dot{\mathbf{v}_t}, \boldsymbol{\gamma}_t, \mathbf{f}_t^z, \boldsymbol{\alpha}_t, sp_t, \varphi_t, \mathbf{C}_t, f_{fb}, f_{oc}, \mathbf{a}_t^{feedback} ] $$

$$ \begin{align*} \text{where,} \quad
& \mathbf{f}_t^z \in \mathbb{R}^4 : \; \text{load on each tyre} \\
& \boldsymbol{\alpha}_t \in \mathbb{R}^4 : \; \text{slip angle of each tyre} \\
& sp_t \in \mathbb{R} : \; \text{scalar progress of the car along the track} \\
& \varphi_t \in \mathbb{R} : \; \text{local course surface inclination} \\
& \mathbf{C}_t \in \mathbb{R}^{3\times N} : \; \text{orientation w.r.t. course left/center/right points, based on velocity} \\
& f_{fb} \in \mathbb{R} : \; \text{indicator if it contacted a fixed barrier} \\
& f_{oc} \in \mathbb{R} : \; \text{indicator if it considered off-course, i.e. three or more tyres are out of bound} \\
& \mathbf{a}_t^{feedback} \in \mathbb{R}^3 : \; \text{most recent actions in game's view}
\end{align*} $$

2. Racing features

$$ \mathbf{o}_{racing} = [ f_c, f_{ss}, \mathbf{O}_t ] $$

$$ \begin{align*} \text{where,} \quad & f_{c} \in \mathbb{R} : \; \text{car contact flag} \\
& f_{ss} \in \mathbb{R} : \; \text{slipstream scalar} \\
& \mathbf{O}_t \in \mathbb{R}^{3\times M} : \; \text{relative CoM position/velocity/acceleration of nearby cars within fixed distance bound} \\
\end{align*} $$

Output representation

$$ \mathbf{a}_t = [ \delta_t, \omega_t ] $$

$$ \begin{align*} \text{where,} \quad
 & \delta_t \in \left[ -1, 1 \right] : \; \text{steering angle} \\
 & \omega_t \in \left[ -1, 1 \right] : \; \text{throttle-brake signal}
\end{align*} $$

Policy 네트워크에 의해 계산되는 output action은 "Squashed normal distribution"의 형태로 나오게 된다. 즉, 제어 가능한 두 가지 action에 대해 2차원의 mean 값과 2x2 matrix 형태의 covariance 값을 학습하게 된다.

각각에 대해 아래와 같은 제약 조건이 가해지며, covariance bound의 경우 작게 잡을수록 deterministic 한, 크게 잡을수록 random 한 policy를 결과로 내놓게 된다.

$$ \begin{align*} 
 & \text{value bound :} \; [ -1, 1] \\
 & \text{covariance bound :} \; [ e^{-40}, e^4]
\end{align*} $$

Reward function

Multi player 환경에서 주행 가능한 agent를 개발하기 때문에, overtaking과 collision avoidance와 같은 maneuver들도 학습되어야 한다. 하지만, 이 논문에서는 ICRA 논문 (3편) 에서 소개했던 curriculum 방식을 채택하지 않았으며, 대신 굉장히 많은 종류의 reward를 추가하여 각종 maneuver들을 통합하여 학습할 수 있게 의도했다.

사용된 notation 중, ((s)) 는 이전 (1step 직전) state를, ((s')) 은 현재 state를 의미하며, 아래 표는 트랙 별로 사용된 reward function의 가중치이다.

Course progress

$$ R_{cp}(s,s') = s'_l-s_l $$

$$ \begin{align*} \text{where,} \quad & s_l : \; \text{length along centerline from start of track} \end{align*} $$

Off-course penalty

$$ R_{oc}(s, s') = -(s'_o - s_o)(s'_{kph})^n $$

$$ \begin{align*} \text{where,} \quad & s_o : \; \text{cumulative off-course time} \\ & s_{kph} : \; \text{speed} \end{align*} $$

난이도가 낮은 저곡률의 도로에서는 (( n=1 (\text{loc}) )) 로, 난이도가 높고 위험도가 높은 고곡률의 도로에서는 (( n=2 (\text{soc}) )) 로 설정하여 차이점을 두었다고 한다.

Wall penalty

$$ R_{w}(s, s') = -(s'_w - s_w)(s'_{kph})^n $$

$$ \begin{align*} \text{where,} \quad & s_w : \; \text{cumulative wall contact time} \end{align*} $$

Tyre-slip penalty

$$ R_{ts}(s, s') = -\sum_{i=1}^4 (\min(\left| s'_{tsr,i} \right|, 1.0) \left| s'_{ts\theta, i} \right| $$

$$ \begin{align*}  \text{where,} \quad & s_{tsr,i} : \; \text{slip ratio of i-th tyre} \\ & s_{ts\theta, i} : \; \text{slip angle of i-th tyre} \end{align*} $$

Passing bonus

$$ R_{ps}(s, s') = \sum_i (s_{L_i} - s'_{L_i})(\max( \mathbf{1}_{(b,f)}(s_{L_i}), \mathbf{1}_{(b,f)}(s'_{L_i})) $$

$$ \begin{align*}  \text{where,} \quad &  s_{L_i} : \text{signed distance from agent to opponent } i \text{ along centerline} \\
& \mathbf{1}_{(b,f)}(x) : \text{indicator whether opponent is within } b \text{m behind, } f \text{m front of agent}
\end{align*} $$

특이한 점은 내가 상대 차량을 추월할 때 양의 reward를 부여할 뿐만 아니라, 다른 차량이 나를 추월하게 되면 음의 reward를 부여한다는 것이다. 이를 통해 overtake를 장려하고, 아래 3가지 reward를 통해 collision에 대한 penalty를 부여한다. 

Any-collision penalty

$$ R_{c}(s,s') = -max_{i \in N} s'_{c,i} $$

$$ \begin{align*}  \text{where,} \quad & s_{c,i} : \text{indicator whether agent collides w/ oppoenent } i \end{align*} $$

Rear-end penalty

$$ R_{r}(s,s') = -\sigma_i s'_{c,i} \cdot \mathbf{1}_{>0} (s'_{l,i}-s'_l) \cdot \left\| s'_v-s'_{v,i} \right\|_2^2 $$

$$ \begin{align*}  \text{where,} \quad & s_{v,i} : \text{velocity vector of oppoenent } i \end{align*} $$

Unsporting-collision penalty

$$ R_{uc}(s,s') = -max_{i \in N} u(s',i) $$

$$ \begin{align*}
\text{where,} \quad u_{s,i} : \; & \text{indicator only firing when} \\
&1) \; \text{rear-ended} \\
&2) \; \text{sidesliped on straightway} \\
&3) \; \text{collision in curve not caused by oppoenent } i
\end{align*} $$

 

RL training specifications

여기서는 quantile regression (QR) 개념을 도입한 QR-SAC 학습 방식을 사용하고 있다. 즉, ((M)) 개의 quantile distribution을 갖는 Q-function을 사용한다.

Critic network

N-step backup 방식으로 네트워크를 update하며, 두 개의 Q-network를 갖는다. Loss function은 다음과 같이 정의된다.

$$ \mathcal{L}(\theta) = \frac{1}{M^2} \sum_i \sum_j \mathbb{E}_{s_t, a_t, R_t, s_{t+1} \sim D, a' \sim \pi} \rho(\delta_{i,j}) $$

$$ \begin{align*}
 \text{where,} \quad
 & \delta_{i,j} = y_i - Z_{\hat{\tau}_j} (s_t, a_t | \theta) \\
 & y_i = R_t + Z_{\hat{\tau}_i} (s_{t+N}, a' | \theta_k) - \alpha \log \pi (a' | s_{t+N}, \phi) \\
 & k = \underset{m \in \left\{1, 2\right\}}{\arg\min} Q(s_{t+N}, a' | \theta'_m)
\end{align*} $$

여기서, Quantile Huber Loss (( \rho_{\tau}^{\kappa}(u) )) 는 다음과 같다.

$$ \rho_{\tau}^{\kappa}(u) = \left| \tau - \delta_{u<0} \right| \frac{\mathcal{L}_{\kappa}(u)}{\kappa} $$

$$ \begin{align*}
 \text{where,} \quad
 & \mathcal{L}_{\kappa}(u)=\left\{\begin{matrix}
\frac{1}{2} u^2, & \text{if} \; \left| u \right| \leq  \kappa \\
\kappa (\left| u \right| - \frac{1}{2}\kappa), & \text{otherwise} \\
\end{matrix}\right.
\end{align*} $$

Actor network

Actor network 학습에 사용되는 objective는 다음과 같다.

$$ J(\phi) = \mathbb{E}_{s \sim D, a \sim \pi(a|s,\pi)} [\alpha \log \pi(a|s,\phi) - \min_{i \in \left\{1, 2\right\}} Q(s,a|\theta_i)] $$

 

Experiments

Settings

GT Sport 는 PS4에서만 실행되는 게임이며, 60Hz의 dynamic simulation cycle을 갖는다. 그리고, 최대 20대의 차량들이 같은 레이스에 참여할 수 있다.

본 논문에서는 10hz의 주기로 가장 최신의 observation을 취득한 다음, decision을 내리는 과정을 반복한다. 5hz ~ 60hz로 변화시키며 그 성능을 비교한 결과, 10hz 이상은 유의미한 성능 차이가 없었다고 한다.

또한, 실제 사람은 게임을 하면서 gear shifting, TCS on/off, brake balance 등을 조절할 수 있지만, GT API는 이들에 대한 접근이 제한되어 오직 throttle/brake, steering 만을 제어했다고 한다.

학습을 진행한 데스크탑은 NVIDIA V100 (또는 NVIDIA A100 절반) GPU를 사용하였으며, 8개의 vCPU 및 55GiB의 메모리를 보유하고 있다고 한다. 21개의 PS4를 사용하여 21개의 병렬적인 rollout worker들이 존재하며, 그 중 하나의 worker는 새로운 training data를 생성하지 않고 각 순간에서의 policy를 evaluate하는 목적으로 사용되었다.

아래는 hyperparameter 설정이다.

Table 1: Table of parameters for QR-SAC RL algorithm.
Table 2: Table of parameters for the neural network architecture.
Table 3: Table of parameters for the trainer.

학습에는 Adam optimizer가 사용되었으며, Batch size는 1,024로, 각 epoch은 6,000 step을 갖도록 설정되었다. Policy network 학습에는 7~12일이 소요되었다고 한다.

Results

Lap time comparison (Single player)

Extended Data Fig. 1에서 (a)와 (c)는 단일 lap에 대해 best lap time을 비교한 결과이며, (b)와 (d)는 100-lap에 대해 average lap time을 비교한 결과이다. 여러 lap을 주행하면, Sophy가 human expert driver들보다 월등히 좋은 성능을 보이고 있다.

Lap time comparison (Multi player)

Fig. 3는 여러 Sophy agent와 human player들을 경쟁시켰을 때의 결과이며, 마찬가지로 Sophy가 월등히 좋은 기록을 달성한 것을 확인할 수 있다.

Learned driving behavior

 

Overall summary

지금까지 GT Sports 상에서 racing agent를 개발하는 것에 대한 논문을 살펴보았다. 각 논문들의 특징을 정리해보면 다음과 같다.

Publication Paper title Features
2021 RA-L Super-Human Performance in Gran Turismo Sport Using Deep Reinforcement Learning SOTA, Single race, Single maneuver, Use GT data, Design course-progress proxy reward, Conduct robustness tests.
2021 NeurIPS Expert Human-Level Driving in Gran Turismo Sport Using Deep Reinforcement Learning with Image-based Representation Single race, Single maneuver, Use single image data, Not vison-only.
2021 ICRA Autonomous Overtaking in Gran Turismo Sport Using Curriculum Reinforcement Learning Multi-race, Add overtake/avoidance maneuver, Use LiDAR data, Not LiDAR-only, Conduct broad comparison of various RL methods.
2022 Nature Outracing Champion Gran Turismo Drivers with Deep Reinforcement Learning SOTA, Multi-race, United maneuver (via reward design), Use GT data, Adopt continuous actions.