I coded some deep RL algorithms (DQN and SAC) with tf2/keras to solve an environment where a vehicle needs to follow the track and avoid crashing into one other vehicle (there is only one other vehicle). Whatever I do, the agent is able to follow road in one way or another but nearly always crashes into other vehicle. I use some kinematics information for observation. (the agent only controls steering)
My observation is the kinematics of the agent and the other vehicle. This includes coordinates, velocities, trigonometric headings, lateral and longitudinal offsets to the closest lane, and angular offsets to the lane.
A reward function could be defined to quantify how close is agent to the center. A negative reward (-1) is provided if the agent crashes. A negative reward is provided if the agent runs out off road.
If there is a crash or if the agent goes off-road, the episode is done.
With this information agent is able to follow the road but as soon as it reaches the other vehicle, it crashes into it. I trained 1000 episodes.
What did i try?
- I ran my code in different environments and it works. Code structure is not a problem.
- I added last actions (t and t-1) info to observations.
- Hyper parameter tuning.
- Changed crashing reward to different values.
- Used Stable-Baselines3's PPO algorithm. (Had the same problem.)
- Added the distance and angular between vehicles to the observation space.
- I slowed down the discovery rate reduction in DQN.
- Used PER as buffer in DQN.
None of these solved the crashing problem. Does anyone have any suggestions or ideas to solve this problem?