Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include lap time in reward function #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

till2
Copy link

@till2 till2 commented Aug 12, 2023

Hey there,

I ran some experiments with RL and wondered why the reward function does not directly depend on the lap time. I think it makes a lot of sense to shape the reward to encourage staying in the center and driving with high velocity. However, to get a racing policy that sometimes intentionally breaks these rules (e.g. doesn't stay in the center to take a curve optimally) to really optimize the lap time, I think the reward function should include the lap time in the reward calculation (give a bonus for low lap times).

I've added an idea on how to implement this in the attached commit. Here, an additional reward is given that is inversely correlated to the lap time (high lap time = low reward, low lap time = high reward). It can be scaled with a factor that weights this additional reward versus the other rewards. This factor is currently just eyeballed and probably needs to be tuned for optimal results. But even with the current form, it yielded pretty good experimental results.

Link to a video with a trained PPO (the simulator is set to 4x speed and max. throttle=0.4; PPO is trained without action smoothing and without frame stacking - so just a really simple baseline): https://drive.google.com/file/d/1Ucsrfwqm02PzzJlb76ozMVTX_tqMiIjE/view?usp=sharing

Eager to hear what you think.
Best, Till

Add a bonus reward that scales inversely with the lap time (low lap time = high bonus reward). The scaling factor `bonus_coeff` needs to be tuned for optimal results.
@till2 till2 changed the title Improve reward function for racing (minimize lap time) Include lap time in reward function Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant