Donkey Car — Part Two: Setting up the Jetson Nano

Cyrus Beh
4 min readMay 31, 2019

--

In the Prelude and Part One of this series, I talked about the overall plan, as well as the RC control protocols, respectively. In this post, I am going to go through the setup of the Nvidia Jetson Nano

What is the Jetson Nano?

The Jetson Nano is a machine learning development board released by Nvidia. The purpose of the board is to enable machine learning ‘on-the-edge’, that is, away from servers, and onto the local system. This has the potential to be more secure, though for a long time, the computing power needed made this impracticable. To be fair, it is probably still quite challenging, but the Jetson series is a step in the right direction. As you may know, Big Data and machine learning has begun to permeate every human endeavor — even scientists and engineers like myself, working in ostensibly areas that don’t deal with Big Data, have found it encroaching on familiar territories. I wanted to get some hands-on experience in the field, but have found it hard to get started since bioinformatics (an obvious scientific problem increasingly being tackled by machine learning) is not accessible to me. This project, which is considered physical computing, is much more up my alley.

I will not belabor the specs of the Nano, except to say that it’s a decent, if not spectacular system. At the time of writing, I have yet to do any training on the system. However, I will say that the system is rated at 450+ gigaflops, vs 100 gigaflops for the Intel Movidius-powered Raspberry Pi 3 (take these numbers with a pinch of salt). While not quite a drop-in replacement, the Nano is similar enough to Raspberry Pi to merit mention — it uses the same camera (PiCamera v2, not v1) with identical connectors; also, its 40-pin GPIO has the same pinout as RPi.GPIO. It features one HDMI, one Displayport (who still uses these?? Edit: it seems displayports are really popular. My new GeForce comes with two!), one ethernet, and four USB ports. It does not have any wireless connectivity (an odd omission), though below the Nano module is an M.2 Key E connector for WiFi adapters.

Installing the Nano Software

I started by downloading the disk image from Nvidia, and flashing onto a 64GB microSD card. This is really a straightforward process. Next up, I proceeded to install the Donkey Car related software onto the Nano. I cannot take any credit for this, as I followed a Medium article to the letter to accomplish this. It’s not often that an installation guide worked exactly as planned, so I was really very pleased. I have replicated some of the instructions here, but strongly recommend going to the page to study why and how he did things this way, and also some steps I skipped over.

Installing TensorFlow

sudo apt-get install python3-pip libhdf5-serial-dev hdf5-toolspip3 install --extra-index-url https://developer.download.nvidia.com/compute/redist/jp/v42 tensorflow-gpu==1.13.1+nv19.3 --user

Installing PyTorch

wget https://nvidia.box.com/shared/static/veo87trfaawj5pfwuqvhl6mzc5b55fbj.whl -O torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whlpip3 install numpy torch-1.1.0a0+b457266-cp36-cp36m-linux_aarch64.whl

Installing Keras

sudo apt-get install python3-scipysudo apt-get install python3-keras

At each step, you can test for proper installation by opening python3 and trying to import the module (import tensorflow, torch and keras, respectively).

To access the I2C channel, run the following

sudo usermod -a -G i2c usernamesudo reboot

Check the group setting for the user:

donkey@donkey-desktop:~$ groupsi2c adm cdrom sudo audio dip video plugdev lpadmin gdm sambashare gpio

Lastly, clone the project from the poster of this project.

git clone https://github.com/feicccccccc/donkeycar.gitcd donkeycarpip3 install -e .

For reasons that I will explain in the next post, I also installed Arduino IDE onto the board — just take note to install version 1.6 and above, as the older versions (~1.05) are not full featured. Using the command “apt-get install arduino”, the latter was installed. Instead, download the source from Arduino website and run the install shell script. One last piece of software I found useful was the Eric Python IDE. Sure, you can vim everything, but when you have to cross-reference files, an IDE can’t be beat.

Hardware Considerations for the Nano

As part of the control hardware, I also used the Adafruit PCA9685 I2C servo driver board — basically, this board allows one to control 16 servos with PWM using a single output pin. Pretty handy. Software for this was installed. As it turns out, I also had a Raspberry Pi GPIO T-Cobbler (essentially a breakout) that allows me to connect everything neatly on a breadboard. This was bought for a RPi GPIO project that was never realized. The image below shows all three connected.

Installing Adafruit_PCA9685 Driver

pip3 install Adafruit_PCA9685

Test the connection by running

sudo i2cdetect -y -r 1

in the folder /opt/nvidia. You should see the PCA9685 at 0x40.

Eventually, I will do away with the T-Cobbler to streamline the layout. For now, it is nice to have some breathing room space-wise. As a back-up control system, I also got a PS3 controller, which can connect by bluetooth. Unfortunately, it’s a 3rd party controller and appears to not work. Yikes. Not essential, but I will have to address this at some point.

Conclusion

And that about sums up the Nano setup. As you can see, it is a pretty straightforward process, especially since there is already a guide out there for it. The fact that the board is only about a month old, and already has such traction in the hobbyist field suggests to me that its potential is widely recognized by the community. I am glad that I am entering this at a rather early stage. In the next post, I will talk about how to interface the RC radio to the Nano — or at least, how I plan to do it. Stay tuned!

--

--

Cyrus Beh

I’m a biomedical engineer who dabbles in hobbyist electronics, programming, crafting, woodworking, and photography. I write stuff for absolute noobs like myself