Integrating the neural network with Carla
We will now integrate our neural network with Carla, to achieve self-driving.
As before, we start by making a copy of manual_control.py
, which we could call manual_control_drive.py
. For simplicity, I will only write the code that you need to change or add, but you can find the full source code on GitHub.
Please remember that this file should run in the PythonAPI/examples
directory.
In principle, letting our neural network take control of the steering wheel is quite simple, as we just need to analyze the current frame and set the steering. However, we also need to apply some throttle, or the car will not move!
It's also very important that you run the inference phase in the game loop, or that you are really sure that it is running on the client, else the performance will drop substantially and your network will have a hard time driving due to the excess of latency between receiving the frame and sending the instruction to drive...