Tutorial: Learning to Drive

Hey everyone,

We just published a new course for the 5.4 version of Learning Agents. It mainly covers the driving scenario again, and we added extra tutorials which cover the FAQs from the past months.

Course outline

Let us know what you think!

Thanks!

5 Likes

Thank you for this new tutorial.

How do I enable training mode after packaging? Can it be done by manually executing the Python files located in the Engine\Plugins\Experimental\LearningAgents\Content\Python directory?

Do you need to just follow the headless instructions here: Learning Agents (5.4) | Course ?

i found that the spline in the sportcar pawn is not set in the reset to random point function. after adding this node it worked. might be a BP copy paste issue…but i wanted to mention it if others wonder why nothings happens after you press play (just the logfile fills up complaining that this spline is undefined)

1 Like

Yeah this is an annoying part of copying the code samples to UE. Hmm I wonder if I can suggest they fix it.

@Deathcalibur
I tried using the tutorial to try teach a cube on thirdparty template to move along non-closed spline, but it didn’t work as expected, so I switched to vechicle template and this time did step-by-step with the tutorial, but when I run I get this error:

LogLearning: Error: SportsCarTrainer_0: Can't find Python executable "../../../Sandbox/MachineLearning/LearningExamples/Intermediate/PipInstall/Scripts/python.exe".

There were similar errors mentioned above, but on Mac and Linux, but I run windows.
Windows 11, UE5.4.2-33871570

Check this thread: Can't find LearningAgents plugin Content

@Deathcalibur
This thread issue concerns non-editor paths. I have a problem with running in-editor and my paths are default editor paths (same as in the other, cube project, which can run). If I need to edit these editor paths somehow, I don’t know what should I change them to.

../../../Engine/
../../../Sandbox/MachineLearning/LearningExamples/Intermediate/

EDIT: Ok, manually browsing editor intermediate to the intermediate folder kinda fixed it

Oh hmm sorry if I didn’t read your question properly. I’m glad you figured it out.

If we have some time, will think more about if we can fix this issue better as several people run into it.

I would be very interested in seeing a similar reinforcement learning tutorial but for an FPS Unreal Tournament type game. How much of a difference would there be? Any guidance would be much appreciated, thanks!

In my opinion, it’s not too different but I’m obviously super biased to my point of view since we made learning agents haha.

I have not yet trained an agent in a shooter using RL yet (but have done imitation learning). Learning Agents works for it in theory (not that its a perfect library/tool… yet). The part that isn’t really fleshed out well in 5.4 is how to scale out.

You can google around and find the current state of the art:

Brendan

Hi,

I saw on some of the 5.3 replies that people were having issues with the cars learning to accelerate but not turn but couldn’t find a solution.

I’ve followed the 5.4 tutorial exactly I think and they learn to accelerate and learn to steer left (to some extent) but they never make it through a corner unless they are travelling very slowly. Bizarrely they are incapable of turning right too. They have been training for over 2 hours.

I’ve tried the 5.3 and the 5.4 tutorial on their respective engines and saw the same thing on both. Any idea what could be going wrong?

Thanks in advance

I’ve just noticed that ResetToRandomPointOnSpline wasn’t working correctly because I was using variables as opposed to local variables. That is now fixed and I’m running it again. Hopefully this will help.

Thanks for all the feedback everyone. Anytime people find issues or run into challenges, I try to take the time to figure out how to make the tutorials or code better. That’s my intention at least :slight_smile:

Brendan

Hi Brendan,

Can I recommend highlighting the local variables thing as a potential gotcha? Using global as opposed to local variables seems to entirely break the training and it’s very easy to miss.

I’m still training but it’s progressing much better now.

1 Like

@simonbrislin - I added a callout to the tutorial stating to use a local variable. Hopefully that helps other users not run into the same problem. Let me know if I made a mistake; otherwise, thanks for speaking up!

Brendan

@deathcalibur yeah I think that callout helps.

I think the only thing that I am remaining stuck on is that the episodes seem to always end early. I can’t figure out if it’s a too short max episode length or there’s some bug in my blueprints that is causing it to end early. I think this is causing the one remaining issue - which is that the vehicles never seem to go that fast - they top out at about 70kmph.

1 Like

That’s very strange. I don’t have time at the moment to help everyone debug their code (I wish I did!), so the best I can say is let me know if you figure out the problem and then I will definitely do something about it if I can.

Brendan

1 Like

Hi Brendan,

Is there a way to get the current iteration while training? I am trying to do my own saving networks to snapshots and would like to do it at iteration 100, 200, 300 etc. or similar but can’t figure out how to get the iteration number.

Thanks in advance