Jetson Nano as Companion Computer

Jetson Nano

          NVIDIA Jetson Nano Developer Kit B-02 is a small, powerful computer which supports running of multiple neural networks in parallel for applications such as image classification, object detection, segmentation, and speech processing with reasonably affordable price. With performance comes excellent power management and the option to run in less than 5 watts. It delivers 472 GFLOPS for running modern AI algorithms fast, with a quad-core 64-bit ARM CPU, a 128-core integrated NVIDIA GPU, as well as 4GB LPDDR4 memory. It has the ability to processes several high-resolution sensors simultaneously. So, for drones running Artificial Intelligence and computer vision specific roles, Jetson Nano is the choice of companion computer. The Jetson Nano will be running the Ubuntu 16.04 LTS with Jetpack 4.5.1.

Preparing Jetson Nano

          Preparing SD Card for Jetson Nano         

Step 1   Download the latest sd-blob-b01.img latest from  https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit#write which is the official site.

Downloading OS for Jetson Nano from official website
Downloading OS for Jetson Nano from official website

Use any SD card flashing software like Balena Etcher or Pi imager to flash sd card of 8/16/32 Gb.

Flashing SD card for Jetson Nano using Raspberry Pi Imager
Flashing SD card for Jetson Nano using Raspberry Pi Imager

Step 2.    Boot Jetson Nano from SD Card and connect with ethernet cable to local LAN with internet.Connect Monitor via HDMI port to    do the startup process. Configure your Ubuntu installation progress (language, keyboard type, location, username & password etc.). Connect Jetson Nano to the internet to create username and password just like any Ubuntu startup and update/upgrade OS.

Configuring Ubuntu Operating System profile
Configuring Ubuntu Operating System profile

sudo apt-get update  
sudo apt-get upgrade

Use ifconfig command to check IP Address allotted to Jetson Nano over local LAN. This is now used for taking ssh also. The point to note is that Jetson Nano does not have an inbuilt wifi and requires ethernet based connection for internet access. So, any access over local network using ssh will require physical ethernet connection to Jetson Nano. Later I will explain how we can use USB to Wi-Fi adaptor to connect Jetson Nano over internet at startup in headless mode just like Raspberry Pi4. By default, Wi-Fi isn’t enabled on Jetson Nano unless user logins to his/her profile. This problem has been solved later in the document as it’s an important requirement for Jetson Nano as companion computer onboard drone. Username and password are defined by user during startup process. The same is required for taking ssh later on.

Installation of VPN as a service

To install VPN, the process is similar to the once explained in Chapter4.

Step1. First install Open VPN application on Jetson Nano.

sudo apt-get install openvpn

Use WinSCP application on windows to transport the folder VPN_Folder that contains all my .ovpn files. Let me remind you that the VPN_Folder contains .ovpn files for FCU, Companion computer and Ground Control Station (GCS). I only need .ovpn file that I created for Jetson Nano from the folder. However, I am transporting the entire folder just for the ease of it. I have done the same process for Raspberry Pi 4 in Chapter 5 above Please note the relevant file in VPN_Folder for me is jetson.ovpn which I renamed after download from OpenVPN website as shown in Chapter 4. The folder was first copied to location /home/yash being default directory as shown below:-

Now move the folder from /home/yash to /etc/openvpn for execution

sudo mv /home/yash/VPN_Folder /etc/openvpn/

Step 2.     Create systemd file for startup at boot

sudo nano /etc/systemd/system/vpn.service

Creating vpn.service at location /etc/systemd/system in Ubuntu Operating System (OS)
Creating vpn.service at location /etc/systemd/system in Ubuntu Operating System (OS)

[Unit]
Description=VPN Service
After=networking.service
StartLimitIntervalSec=0

[Service]
Type=idle
ExecStart=/usr/sbin/openvpn etc/openvpn/VPN_Folder/jetson.ovpn
Restart=on-failure
RestartSec=1

[Install]
WantedBy=multi-user.target

Creating content of vpn.service for enabling VPN services on startup
Creating content of vpn.service for enabling VPN services on startup

sudo systemctl enable vpn.service
sudo systemctl start vpn.service
sudo systemctl status vpn.service
sudo systemctl daemon-reload
(only to reload service incase some changes are made)

Installation of MAVPROXY (Command Line Ground Control Station) as a service

            MAVPROXY is the command line Ground Control Station (GCS) to be installed in companion computer. This MAVPROXY will receive MAVlink data (link between Ardupilot running on FCU i.e Beagle Bone Blue and companion computer) over serial interface and relay it back to the ground control station i.e Mission Planner running over laptop/PC. The MAVlink is installed over secure VPN using UDP protocol over internet connection extended by 4G LTE Modem.  Kindly note that the serial port in Jetson Nano is identified as /dev/ttyTSH0

Installing dependencies for MAVPROXY

sudo apt-get install python3-dev python3-opencv python3-wxgtk4.0 python3-pip python3-matplotlib python3-lxml python3-pygame
pip3 install PyYAML mavproxy --user
echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc

Incase user permission issues (optional)
sudo usermod -a -G dialout <username>

To update an existing installation with the current release on Python 3 based systems
pip3 install mavproxy --user –upgrade

Interfacing with Beagle Bone Blue Flight Controller Unit (FCU)

        Connectivity Diagram Jetson Nano serial interface will connect with UART1 of Beagle Bone Blue as mentioned below: –         

Connectivity diagram for physical interfacing of Jetson Nano as companion computer with Beagle Bone Blue as FCU
Connectivity diagram for physical interfacing of Jetson Nano as companion computer with Beagle Bone Blue as FCU

               Testing MAVlink over MAVPROXY               Testing MAVlink though MAVPROXY Command Line GCS. In order to test the configuration, the below mentioned command will have to be run in Terminal window of Jetson Nano 4. Both Beagle Bone Blue and Jetson Nano have to be configured as explained till now to be able to test it.

(a)           Both Companion computer and GCS on local LAN, then use
sudo python3 $HOME/.local/bin/mavproxy.py --master=/dev/ttyTSH0 –out=udp:192.168.1.7:14550

(b)          VPN Command Example.
sudo python3 $HOME/.local/bin/mavproxy.py --master=/dev/ttyTSH0 –out=udp:100.96.1.34:1194

Kindly note that the Raspberry Pi’s serial port will now be usable on /dev/ttyTSH0 and 1194 is port for VPN while local LAN use 14550. IP Address 192.168.1.7 is local LAN IP Address while 100.96.1.34 is the VPN IP Address of GCS. Replace with your own IP Address to test.

Running WIFI on headless startup (peculiar to Jetson Nano)

            Unlike Raspberry Pi 4, the Jetson Nano does not have an inbuilt wifi and requires external adaptor (USB Wifi). In our case, the 4G LTE Modem is on Beagle Bone Blue, hence Jetson Nano is required to connect to internet on wifi on startup. We want Jetson Nano to connect with wifi onboard drone as an when the drone starts and allow us to take remote ssh over VPN and also establish MAVlink over VPN. Thus, we require to disable power saving mode and allow wifi connection on startup through below steps:-

Step 1.    Update the Ubuntu OS on Jetson Nano first
sudo apt-get update

Step 2.    Install dependencies
sudo apt-get install git linux-headers-generic build-essential dkms

Step 3.    Git clone repository
git clone https://github.com/pvaret/rtl8192cu-fixes.git

The list of wifi adaptors supported for Jetson Nano

ASUSTek USB-N13 rev. B1 (0b05:17ab)
Belkin N300 (050d:2103)
D-Link DWA-121 802.11n Wireless N 150 Pico Adapter [RTL8188CUS]
Edimax EW-7811Un (7392:7811)
Kootek -RPWF (0bda:8176)
OurLink 150M 802.11n (0bda:8176)
Plugable USB 2.0 Wireless N 802.11n (0bda:8176)
TP-Link TL-WN725N (0bda:8176)
TP-Link TL-WN821Nv4 (0bda:8178)
TP-Link TL-WN822N (0bda:8178)
TP-Link TL-WN823N (only models that use the rtl8192cu chip)
TRENDnet TEW-648UBM N150

sudo dkms add ./rtl8192cu-fixes
sudo dkms install 8192cu/1.11
sudo depmod -a
sudo cp ./rtl8192cu-fixes/blacklist-native-rtl8192.conf /etc/modprobe.d/
sudo echo options rtl8xxxu ht40_2g=1 dma_aggregation=1 | sudo tee
/etc/modprobe.d/rtl8xxxu.conf

Now we need to enable auto login. This ensures that wifi will not lose connectivity on ssh.
sudo nano /etc/gdm3/custom.conf

In this file, uncomment the following:
AutomaticLoginEnable = true
AutomaticLogin = user // put your user name here e.g. jetson
sudo reboot now

                

About the Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also like these