The neural network cannot be trained on the Raspberry Pi. The hardware of the Raspberry Pi is simply too weak for training the neural network. Therefore an extra computer should be used for training the pilot, which is much more powerful than the Raspberry Pi. I recommend an Ubuntu installation as operating system and the installation of the Donkey Car Framework on this computer. It is important that the computer has a lot of memory from about 12 GB to 16 GB and that it has a powerful CPU or GPU installed.
In my case I used the CPU for training the pilot. It is a i5 CPU mobile with 2.2 GHZ and this has 12 GB of Ram on the side. Training a pilot took between 8 hours and 12 hours with about 23.000 data pairs.
Software Installation Training Computer
For the following section I assume that a current Ubuntu Versoin is installed and the computer is connected to the Internet. Next, no GPU is used for training. As on the Raspberry Pi, everything is installed into a virtual area. Please execute the following commands (URL: http://docs.donkeycar.com/guide/install_software/#install-donkeycar-on-linux)
Installation of the necessary software on the Ubuntu computer.
Command: sudo apt-get install virtualenv build-essential python3-dev gfortran libhdf5-dev
Setting up the virtual environment named “env”.
Command: virtualenv env -p python3
Activating the Virtual Environment “env”.
Command: source env/bin/activate
Installation of the Tensorflow version 1.8.0
Command: pip install tensorflow==1.8.0
Now everything is installed on the Ubuntu computer and the Donkey Car Framework can be installed. Please execute the following commands which should look familiar from the installation on the Raspberry Pi.
Download and install the Donkey Car Framework. It is important to install exactly the version that is installed on the Donkey Car.
Command: pip install donkeycar==2.5.1
Creating the instance of the Donkey Car Framework.
Command: donkey createcar ~/mycar
From now on your computer is able to train the neural network. You have to copy the many pictures and JSON files in the folder “/home/pi/mycar/data/” from your Raspberry Pi to the Ubuntu computer. You should also copy the pictures and JSON files back into the installation directory of the Donkey Car Framework. It will probably be the same folder as under the Raspberry Pi “/home/<user-name>/mycar/data/”.
It is important that you are in the virtual environment of your Donkey Car installation. If not, you have to start the virtual environment with the command “source env/bin/activate” before you can start the training of the neural network.
The following command starts the calculation of the pilot or neural network on your Ubuntu computer.
Command: python ~/mycar/manage.py train –tub <tub Ordner Namen getrennt durch ein Komma> –model ./models/mypilot
The name of the pilot or trained neural network is “mypilot”. After successful calculation it should be in the folder “/home/<user-name>/mycar/models/”.
Now copy the file “mypilot” to the Raspberry Pi in the folder “/home/pi/mycar/models/” and from now on your Donkey Car is able to drive autonomously. To do this you must now run the following command to make the Donkey Car Framework load the mypilot and control the Donkey Car autonomously.
Command: python manage.py drive –model ~/mycar/models/mypilot
If you are using a PS4 controller you have to disable it in config.py now. Then load the web interface of your donkey car and switch to autopilot mode in the web interface. On the left there is a drop-down menu with the heading “Model & Pilot”. There you have to select the entry “Local Pilot”. Now the Donkey Car should start and be controlled by the trained pilot (see second Youtube video in the following section). To start the web interface open the following URL.
URL: <IP-address of your Donkey Car>:8887
Results – test runs
After I trained different models using four tub folders, I transferred the pilots to the donkeycar and set up a course again in the basement. I was very curious to see how well the robot car autonomously drives the course on the basis of a Raspberry Pi computer. I tested two models which I calculated.
The first model is based on training data where I only drove at medium speed. The result can be seen in the following video. The second model was trained with data where I rode the course at maximum speed. The result looks like that the car with this model drives the course much faster. You can see this in the following two videos.
The second model was trained with data where I was running the course at maximum speed. The result looks like that the car with this model drives the course much faster. You can see this in the following video.
The training of the model with Tensorflow and KERAS worked very well after the software installation. On my laptop with i5 processor I needed one day to calculate several models. As a result I got models that actually let my donkey car drive around the course.
Artikel Übersicht Donkeycar Roboter Auto:Autonom fahrendes Raspberry Pi KI Roboter-Auto – Einleitung
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Chassis
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Elektronik
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Software Installation
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Kalibrierung
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Trainings Vorbereitungen
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Trainingsdaten aufzeichnen
Autonom fahrendes Raspberry Pi KI Roboter-Auto – das Neuronale Netz trainieren
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Donkeycar training in einem Docker Container (optional)
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Donkey Car UNIMOG Upgrade
Autonom fahrendes Raspberry Pi KI Roboter-Auto – Manuelle Short Keys
Autonom fahrendes Raspberry Pi KI Roboter-Auto – IMU Sensor 9-DOF absolute Orientation
Autonom fahrendes Nvidia Jetson Nano AI Roboter-Auto – Vorbereitung
Autonom fahrendes Nvidia Jetson Nano AI Roboter-Auto – Software Installation
Autonom fahrendes Nvidia Jetson Nano AI Roboter-Auto – Konfiguration des Donkey Car Frameworks