Now that the Jetson Nano is configured to boot from the SD card or SSD hard drive, it is time to install the other software required for the donkey car. Again, I have listed all the necessary commands and explained something about what they do.

Software installation:

The Donkey Car Framework is also available especially for the Jetson Nano and so the installation has become very easy since version 3.x of the framework. Of course you should take your time but you don’t always have to sit in front of the computer and watch how the software installation is running. I started the commands one by one and worked on my blog and the reports here.

With the first two commands, the Jetson Nano is once again bearded to the latest software version. Therefore you should always execute these two commands before installing the rest of the software.

Command: sudo apt-get update
Command: sudo apt-get upgrade

Now we will install some more libraries and tools which are needed for the Donkey Car Framework.

Command: sudo apt-get install build-essential python3 python3-dev python3-pip libhdf5-serial-dev hdf5-tools ntp

Restart the NANO with the following command now before you continue with the software installation.

Command: sudo reboot

Setting Up the Virtual Environment

Now the virtual environment in which the Donkey Car Framework will be installed is set up. This makes sense, as it allows you to delete this environment in case of problems and reinstall it without having to repeat the entire installation of the Jetson Nano.

Command: pip3 install virtualenv
Command: python3 -m virtualenv -p python3 env –system-site-packages

This command ensures that whenever you log on with your user, the virtual environment is started directly.

Command: echo “source env/bin/activate” >> ~/.bashrc

Now the virtual environment is started manually for the first time with the following command.

Command: source ~/.bashrc

If you want to leave the virtual environment you have to call the following command.

Command: deactivate

Now that the virtual environment is set up, the installation can continue.

Setting up OpenCV

Currently, the Jetson Nano Images always include a working OpenCV version. However, Nvidia would like to change this in the future and then you would have to complicate OpenCV yourself. So please check if OpenCV is available on your Jetson Nano. To do this, please change to the following path “/usr/lib/python3.6/dist-packages/” and see if the file “cv2.cpython-36m-aarch64-linux-gnu.so” is there.

With the Midnight Commander you can easily navigate through the Linux installation directories of the Jetson Nano.

If the file “cv2.cpython-36m-aarch64-linux-gnu.so” is available then you can copy this file into the mycar folder. The required commands come one after the other.

First the folder mycar is created. The Donkey Car Framework will later be set up in this.

Command: mkdir ~/mycar

Now the OpenCV file is copied to the mycar folder with the following command.

Command:cp /usr/lib/python3.6/dist-packages/cv2.cpython-36m-aarch64-linux-gnu.so ~/mycar/

Please change to the mycar folder because now a small test is performed to see if OpenCV can be imported.

Command: cd ~/mycar

Now OpenCV is imported into Python with the following command. There should be no message after the command has been executed. Then we’re all good.

Command: python -c “import cv2”

If I get an error message, I can only refer to the Donkey Car Slack Channel or the NVIDIA Developer Board. I never had a mistake at that point.

Compiling OpenCV yourself

In case you have to compile OpenCV yourself, I recommend the following instructions which I found on PyImageSearch. But I have not tried this manual myself yet. But also on the Donkey Car page itself the procedure how to compile OpenCV is described.

Install Donkey Car Framework

Now all preparations are done and the Donkey Car Framework for the Jetson Nano can be downloaded from GitHub. It is best to save everything in a folder called “projects” in your home directory.

Command: mkdir ~/projects

Now change in the projects folder with the following command.

Command: cd ~/projects

From GitHub you still need to download the Donkey Car Framework. This works with the following commands.

Command: git clone https://github.com/autorope/donkeycar

Command: cd donkeycar

Command: git checkout master

Now the Donkey Car Framwork for the Jetson Nano must be installed. Therefore [nano] is appended as parameter at the end of the call

Command: pip install -e .[nano]

Finally Tensorflow is installed with the following command.

Command: pip install –extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3

The last step is to create a Donkey Car instance on your Jetson Nano. I always  put these on in the Ornder mycar. You already created the folder mycar at the point with the OpenCV file.

Command: mkdir ~/mycar

The following command creates a Donkey Car instance in the mycar folder.

Command: donkey createcar –path ~/mycar

Now all the software needed for the donkey car is installed on the Jetson Nano. The next step is to modify the myconfig.py file with your own parameters. More about this in the next article.

Summary:

I really like the Jetson Nano and the great computing power it provides in my Donkey Car. Simply put, it is a compact board with a lot of GPU power. Also the software installation went very well and I had no problems. A big thanks to the makers and the community behind the Donkey Car Framework.

Donkey Car article series

Autonomously driving Nvidia Jetson Nano AI robot car – preparation

Autonomously driving Nvidia Jetson Nano AI robot car – software installation

Autonomously driving Nvidia Jetson Nano AI robot car – configuration of the Donkey Car Framework