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

Latent Imagination Facilitates Zero-Shot Transfer in Autonomous Racing

by heesungsung 2024. 2. 3.
https://arxiv.org/abs/2103.04909
 

Latent Imagination Facilitates Zero-Shot Transfer in Autonomous Racing

World models learn behaviors in a latent imagination space to enhance the sample-efficiency of deep reinforcement learning (RL) algorithms. While learning world models for high-dimensional observations (e.g., pixel inputs) has become practicable on standar

arxiv.org


 

Introduction

2020 ICLR에서 발표된 model-based RL, "Dreamer" 를 autonomous racing에 접목시킨 연구이다. Dreamer는 high-dimensional observation으로부터 representation learning을 통해 world model을 학습하고, 학습된 환경 내에서 agent는 imagination을 통해 policy를 학습하게 된다. 이러한 방식은 performance, sample efficiency, robustness 측면에서 장점을 갖는다.

이 논문에서는 high-dimensional input으로 LiDAR 정보를 사용했으며, collision 없이 racing task를 수행하는 것을 목표로 했다. Contribution은 다음과 같다.

  • 실차 대상의 알고리즘 개발 및 implementation을 진행할 때, model-based DRL이 model-free에 비해 더 효과적임을 보임.
  • Model-free DRL은 sim2real 과정을 실패하는 반면, model-based는 좋은 transferability를 가진다는 것을 보임.
  • Dreamer의 generalization 능력과 학습 성능은 observation model, state transition probability model, imagination horizon에 크게 의존함을 실험적으로 보임.

 

Problem Definition

World setup

Real-world 환경은 다음의 POMDP로 정의한다.

$$ ( S, A, \Omega, \mathcal{O}, \mathcal{T}, \mathcal{R} ) $$

  • ((S)) / ((A))  / ((\Omega)) :  set of states / actions / observations
  • ((\mathcal{O})) / ((\mathcal{T})) :  stochastic observations / transition functions
  • ((\mathcal{R})) :  deterministic reward function

구체적인 설명은 다음과 같다.

  • ((\mathcal{T} : S \times A \times S \to [0,1]))
    • models the system dynamics including uncertainty.
    • returns the transition probability btw two states by applying actions.
  • ((\mathcal{O} : S \times \Omega \to [0,1]))
    • models system's perception including uncertainty.
    • returns probability of perceiving an observation in a given state.
  • ((\mathcal{R} : S \times A \times S \to \mathbb{R}))
    • models system's reward process.
    • returns the credit assigned to a transition.

Agent setup

  • Observations :  LiDAR (270°의 FOV에 걸쳐 고르게 분포한 1080개의 range 측정 값 데이터)
  • Continuous actions :  (( \mathbf{a} = (F, \alpha)^T ))
    • ((F)) :  motor force applied to reach a fixed target velocity
    • ((\alpha)) :  steering angle

 

Adapting Dreamer for Autonomous Racing

Recall

Dreamer는 다음의 4가지 요소로 구성된다.

$$ \begin{align*} \text{Representation model :} \quad &  p_\theta (s_t | s_{t-1}, a_{t-1}, o_t) \tag{1} \\ \text{Observation model :} \quad & q_\theta (o_t | s_t) \tag{2} \\ \text{Reward model :} \quad & q_\theta (r_t | s_t) \tag{3} \\ \text{Transition model :} \quad & q_\theta (s_t | s_{t-1}, a_{t-1}) \tag{4} \end{align*} $$

Dreamer는 high-dimensional observation으로부터 system dynamics model을 unsupervised 방식으로 학습한다. 이렇게 학습된 환경을 이용하여 latent-state sequence를 생성하고, 이를 통해 actor-critic 방식으로 agent를 학습시킨다.

Latent space의 경우 기존에는 RSSM과 CNN을 이용한 dynamics model을 적용했지만, 여기서는 RGB image가 아닌 LiDAR range measurement를 사용하기 때문에 CNN이 아닌 MLP를 이용했다.

이 모든 요소들은 joint되어 variational lower-bound를 maximize하는 방향으로 최적화된다. Objective는 아래와 같다.

$$ \mathcal{J}_{REC} = \mathbb{E}_p \left [ \sum_t (\mathcal{J}_O^t + \mathcal{J}_R^t  + \mathcal{J}_D^t ) \right ] \tag{5} $$

$$ \begin{align*} \text{where,} \quad & \mathcal{J}_O^t = \ln q(o_t | s_t) \\ & \mathcal{J}_R^t = \ln q(r_t | s_t) \\ & \mathcal{J}_D^t = - \beta \, \text{KL} \left ( p(s_t | s_{t-1}, a_{t-1}, o_t) \| q(s_t | s_{t-1}, o_{t-1}) \right ) \end{align*} $$

Dynamics learning

Dreamer에서는 dynamics learning 과정에서 representation model을 학습할 때, latent state로부터 observation을 reconstruction하는 과정을 사용한 바 있다. 본 논문에서도 이 과정을 사용했으며, 두 가지 observation model을 제안했다.

Fig. 3: Observation models and their reconstruction methods. Observations are in agent coordinates. Row 1: bird-view of the racecar in simulation, Row 2: LiDAR scan in racecar coordinates, Row 3: reconstructed LiDAR scan, Row 4: reconstructed local occupancy map

Distance reconstuction model

첫 번째 model은 original LiDAR scan 결과를 reconstruct 하는 것이다. MLP 네트워크를 사용하여 구성되며, latent state로부터 각 LiDAR ray 별 distance measurement의 Gaussian distribution을 predict한다. 

학습 과정에서, original observation은 representation model의 input과 ouput (label) 으로 사용된다. 여기서는 이렇게 reconstruct된 distance를 "Dreamer-Distance"라고 부른다.

Occupancy reconstuction model

두 번째 model은 occupancy map을 reconstruct 하는 것이다. 현재 latent state로부터 agent 주변의 occupancy map을 predict하며, 구체적으로는 multivariate Bernoulli distribution의 parameter를 생성하게 된다. 즉, pixel 단위로 점유 유무에 대한 probability 값이 output으로 나오게 되며, 별도의 transposed conv. 네트워크로 구성된 2D grayscale image construction 모델을 거쳐 occupancy grid map을 형성하게 된다.

학습 과정에서, input은 original observation을 주고, output (label) 로는 true occupancy grid map patch를 제공한다. 여기서는 이렇게 reconstruct된 occupancy map을 "Dreamer-Occupancy"라고 부른다.

Behavior learning

Action-Value model

위에서 학습된 representation model을 사용하여 이제 agent는 imagination을 통해 policy를 학습하게 된다. Dreamer는 actor-critic 방식을 사용하며, action 및 value model은 다음과 같이 정의된다.

$$ \begin{align*} \text{Action model :} \quad &  q_\phi (a_t | s_t) \tag{6} \\ \text{Value model :} \quad & q_\psi (v_t | s_t) \tag{7} \end{align*} $$

Action model은 agent의 best action을 predict하는 policy를 학습하고, value model은 각 latent state 별 value를 추정한다. Value 추정 과정에서 bias와 variance 간 trade-off를 위해 Dreamer에서는 exponentially weighted sum ((V_\lambda(s_\tau) )) 을 사용하였으며, 본 논문에서도 이를 적용했다.

Reward shaping

RL agent의 behavior는 reward 함수를 어떻게 구성하는지에 큰 영향을 받는다. 여기서는 Gran Turismo Sport 상에서 SAC 기반의 RL agent를 개발한 논문 (Fuchs et al., 2021 RA-L) 에서 제안한 progress reward signal을 사용하고 있다.

$$ c \times | p_t - p_{t-1} | = c \triangle p_t \tag{8} $$

Fig. 4: Top-view of the race tracks and relative Progress Maps adopted for reward design. Austria (length = 79.45m), Columbia (61.2m), Treitlstrasse (51.65m) are used for training, Barcelona (201m) is used only for evaluation. Red circles indicate difficult parts of the track. The red circles show where all model-free agents fail to improve their performance.

주행 중에 wall 또는 다른 object와의 collision이 발생되면, penalty (-1) 을 부여하고 episode를 종료한다. Progress value의 경우 map 별로 사전에 정의되며, Fig. 4에서 보이는 바와 같이 0 (light) 부터 1 (dark) 까지의 값을 갖는다. (Progress reward가 1이면 한 번의 full lap을 완료한 것이다!)

Overview of racing agent setup

 

Experiments

Setup

Simulation에서 training 한 다음, 실차로 transfer하여 sim2real manner로 실험을 진행했다.

  • Simulation :  PyBullet engine, URDF vehicle model
  • Real :  F1TETNTH platform, Hokuyo UST-10LX LiDAR, NVIDIA Jetson TX2 (Ubuntu 18.04 + ROS)

Training specification

  • 매 episode마다 agent는 track에 random하게 소환됨.
  • 각 epdisode는 최대 2,000 timestep (20s).
  • Observation과 action은 normalization 수행.

학습을 진행한 track들의 specification은 다음과 같다.

Evaluation

Learning curve

Dreamer와 model-free DRL baselines 사이의 학습 성능을 비교했다.

Fig. 5: Left: Learning curves of model-free methods (top row) over 8𝑀 steps and Dreamers (bottom row) over 2𝑀 steps. The dashed lines report the maximum performance obtained by the other algorithms as baselines. Performance averages over 5 runs. Right: Maximum progress and lap time of trained models over different tracks in simulation. The bars show the result averaged over 10 episodes on each track. The delimiters show the minimum and maximum achieved. For Lap-Time results, we consider the best episode that finished one full lap.

Fig. 5의 왼쪽을 보면, Columbia와 같은 간단한 map 외에 다른 복잡한 map들에 대해서 model-free DRL 알고리즘들은 성공적으로 한 lap 주행을 성공하지 못한 것을 확인할 수 있다. 그러나, Dreamer는 트랙의 복잡도와 관련 없이 task를 완수한다. 또한, model-free model들과 유사하거나 더 좋은 성능을 보이고 있다.

Dreamer의 두 가지 observation model 사이의 비교 결과를 살펴보면, Austria와 Columbia map에 대해서는 distance와 occupancy reconstruction이 비슷한 성능을 보였다. 하지만, Treitlstrasse에서는 occupancy가 더 좋은 성능을 보였다. 이 논문에서는 occupancy-map reconstruction 방식이 학습 속도를 높이지만 bias가 더 많이 발생되어 generalization 성능은 떨어진다고 말한다.

Generalization ability

한 가지 track에 대해 학습된 model을 다른 track들에 대해 주행했을 때의 성능을 확인한 실험이며, Fig. 5의 오른쪽에 나타나있다. COL과 같은 간단한 map에 대해서는 model-free와 model-based 알고리즘 모두 성공한 것을 볼 수 있다. 하지만, 그 외에 복잡한 map들에 대해서는 Dreamer만 완주에 성공했으며, model-based 알고리즘이 generalization 측면에서 더 우월한 성능을 보임을 증명하고 있다.

마찬가지로 distance와 occupancy 간의 결과를 비교하면, occupancy가 더 낮은 generalization 성능을 보임을 확인할 수 있다. Occupancy-map을 사용했을 때 agent는 더 aggresive한 성향을 보였으며, 학습을 진행한 track에 더 overfitted 되었다. 즉, 학습 속도는 빨라지지만 domain 변화에 대한 robustness는 떨어진다.

Influence of imagination horizon

Fig. 6: Dreamer’s performance vs. imagination horizon. Batch length = 50, and action repeat = 4. n = 5.

일반적으로 imagination horizon을 증가시킬수록 성능이 좋아졌다. 하지만, 너무 길어졌을 때는 horizon 동안 compounding model error가 너무 커지기 때문에 오히려 성능이 떨어지는 현상이 나타난다.

Influence of action regularization

Fig. 7: Impact of action regularization on TRT. The first row reports the steering command’s distributions under various regularization weights. The second row reports the continuous command over a single simulation snapshot. n=5

이번에는 학습된 agent의 운전 특성을 살펴보았다. Fig. 7의 파란색 선은 steering angle cmd.로 on-off control과 유사한 제어 특성을 보이고 있다. 이로 인해 실제로는 불필요한 curvy trajectory들이 나타나기 때문에 다음의 action regularization을 진행했다.

Regularized action model의 objective는 다음과 같다.

$$ \mathbb{E}_{p_\theta, q_\phi} \left [ \sum_{t=0}^H \gamma^t \left ( V_\lambda(s_t) - \mu_1 \|a_t\|_2^2 - \mu_2 \|a_t - a_{t-1} \|_2^2 \right ) \right ] $$

$$ \begin{align*} \text{where, } \quad & V_\lambda(s_t) : \; \text{original value esimation term} \\ & \mu_1 : \; \text{control effort coefficient} \\ & \mu_2 : \; \text{temporal smoothing coefficent} \end{align*} $$

실제로 smoothing을 했을 때와 아닐 때의 성능을 비교해보면, smoothing을 하지 않았을 때가 성능이 제일 좋다고 한다... (실차 implementation 측면에서는 필요할 수도 있지만, 성능은 original이 더 좋다!)

Sim2Real transfer

Experiment video link (Click!)

Simulation에서 개발한 Dreamer model은 real car로 deploy되어 test를 진행했다. 그 결과는 위의 유투브 링크에서 확인할 수 있다.

Generalization capability에 대해 다음의 두 가지 실험이 수행되었다.

  • Test in reversed direction
  • Place two obstacles after most challenging turn

두 경우 모두 충돌 없이 성공적으로 lap 주행을 완료했다고 한다.